X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FOr.java;h=05981aa9ef8cdaec867975928667b21b2f14dc63;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=9791c741c2f093bca7c8fece221164bbaf7018ad;hpb=dd74fc4938723fe5ec48d4e5fdcfbe58ac42a48d;p=jalview.git diff --git a/src/com/stevesoft/pat/Or.java b/src/com/stevesoft/pat/Or.java index 9791c74..05981aa 100755 --- a/src/com/stevesoft/pat/Or.java +++ b/src/com/stevesoft/pat/Or.java @@ -12,70 +12,116 @@ import java.util.*; /** This class implements the (?: ... ) extended Pattern. It provides a base class from which we derive the [ ... ], ( ... ), (?! ... ), and (?= ... ) patterns. */ -class Or extends Pattern { - Vector v; - Pattern[] pv = null; - Or() { v = new Vector(); } - String leftForm() { return "(?:"; } - String rightForm() { return ")"; } - String sepForm() { return "|"; } - public Or addOr(Pattern p) { - pv = null; - v.addElement(p); - p.setParent(this); - return this; +class Or + extends Pattern +{ + Vector v; + Pattern[] pv = null; + Or() + { + v = new Vector(); + } + + String leftForm() + { + return "(?:"; + } + + String rightForm() + { + return ")"; + } + + String sepForm() + { + return "|"; + } + + public Or addOr(Pattern p) + { + pv = null; + v.addElement(p); + p.setParent(this); + return this; + } + + public String toString() + { + int i; + StringBuffer sb = new StringBuffer(); + sb.append(leftForm()); + if (v.size() > 0) + { + sb.append( ( (Pattern) v.elementAt(0)).toString()); + } + for (i = 1; i < v.size(); i++) + { + sb.append(sepForm()); + sb.append( ( (Pattern) v.elementAt(i)).toString()); } - public String toString() { - int i; - StringBuffer sb = new StringBuffer(); - sb.append(leftForm()); - if(v.size()>0) - sb.append( ((Pattern)v.elementAt(0)).toString() ); - for(i=1;i= 0) + { + return r; + } + } + return -1; + } + + public patInt minChars() + { + if (v.size() == 0) + { + return new patInt(0); } - public int matchInternal(int pos,Pthings pt) { - if(pv == null) { - pv = new Pattern[v.size()]; - v.copyInto(pv); - } - for(int i=0;i= 0) - return r; - } - return -1; + patInt m = ( (Pattern) v.elementAt(0)).countMinChars(); + for (int i = 1; i < v.size(); i++) + { + Pattern p = (Pattern) v.elementAt(i); + m.mineq(p.countMinChars()); } - public patInt minChars() { - if(v.size()==0) return new patInt(0); - patInt m = ((Pattern)v.elementAt(0)).countMinChars(); - for(int i=1;i