X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FMulti.java;fp=src%2Fcom%2Fstevesoft%2Fpat%2FMulti.java;h=1fe197d5c864356a02b6c5ecce92a264565b900a;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=14b3a068d0b36a17723032589803b85b7de2fd81;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/com/stevesoft/pat/Multi.java b/src/com/stevesoft/pat/Multi.java index 14b3a06..1fe197d 100755 --- a/src/com/stevesoft/pat/Multi.java +++ b/src/com/stevesoft/pat/Multi.java @@ -1,85 +1,90 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** Matches any number of instances of sub Pattern - this was the hardest method to write. It implements - '+', '*', '?', "{0,10}", "{5,}", "{5}", etc. - @see pat.Multi_stage2 - @see pat.MultiMin - */ -class Multi - extends PatternSub -{ - patInt a, b; - public patInt minChars() - { - return a.mul(p.countMinChars()); - } - - public patInt maxChars() - { - return b.mul(p.countMaxChars()); - } - - Pattern p; - Multi_stage2 st2; - public boolean matchFewest = false; - /** - @param a The fewest number of times the sub pattern can match. - @param b The maximum number of times the sub pattern can match. - @param p The sub pattern. - @see Multi_stage2 - @see MultiMin - */ - public Multi(patInt a, patInt b, Pattern p) - throws RegSyntax - { - this.a = a; - this.b = b; - this.p = p; - st2 = new Multi_stage2(a, b, p); - st2.parent = this; - sub = st2.sub; - } - - public String toString() - { - st2.matchFewest = matchFewest; - return st2.toString(); - } - - public int matchInternal(int pos, Pthings pt) - { - try - { - st2 = new Multi_stage2(a, b, p); - } - catch (RegSyntax r__) - {} - st2.matchFewest = matchFewest; - st2.parent = this; - return st2.matchInternal(pos, pt); - } - - public Pattern clone1(Hashtable h) - { - try - { - Multi m = new Multi(a, b, ( (Pattern) p).clone(h)); - m.matchFewest = matchFewest; - return m; - } - catch (RegSyntax rs) - { - return null; - } - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * Matches any number of instances of sub Pattern this was the hardest method to + * write. It implements '+', '*', '?', "{0,10}", "{5,}", "{5}", etc. + * + * @see pat.Multi_stage2 + * @see pat.MultiMin + */ +class Multi extends PatternSub +{ + patInt a, b; + + public patInt minChars() + { + return a.mul(p.countMinChars()); + } + + public patInt maxChars() + { + return b.mul(p.countMaxChars()); + } + + Pattern p; + + Multi_stage2 st2; + + public boolean matchFewest = false; + + /** + * @param a + * The fewest number of times the sub pattern can match. + * @param b + * The maximum number of times the sub pattern can match. + * @param p + * The sub pattern. + * @see Multi_stage2 + * @see MultiMin + */ + public Multi(patInt a, patInt b, Pattern p) throws RegSyntax + { + this.a = a; + this.b = b; + this.p = p; + st2 = new Multi_stage2(a, b, p); + st2.parent = this; + sub = st2.sub; + } + + public String toString() + { + st2.matchFewest = matchFewest; + return st2.toString(); + } + + public int matchInternal(int pos, Pthings pt) + { + try + { + st2 = new Multi_stage2(a, b, p); + } catch (RegSyntax r__) + { + } + st2.matchFewest = matchFewest; + st2.parent = this; + return st2.matchInternal(pos, pt); + } + + public Pattern clone1(Hashtable h) + { + try + { + Multi m = new Multi(a, b, ((Pattern) p).clone(h)); + m.matchFewest = matchFewest; + return m; + } catch (RegSyntax rs) + { + return null; + } + } +};