1 Clazz.declarePackage ("com.stevesoft.pat");
\r
2 Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.FastMulti", ["com.stevesoft.pat.RegSyntaxError", "$.patInt"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.fewestMatches = null;
\r
5 this.mostMatches = null;
\r
6 this.matchFewest = false;
\r
8 Clazz.instantialize (this, arguments);
\r
9 }, com.stevesoft.pat, "FastMulti", com.stevesoft.pat.PatternSub);
\r
10 Clazz.overrideMethod (c$, "minChars",
\r
12 return this.sub.countMinChars ().mul (this.fewestMatches);
\r
14 Clazz.overrideMethod (c$, "maxChars",
\r
16 return this.sub.countMaxChars ().mul (this.mostMatches);
\r
18 Clazz.makeConstructor (c$,
\r
19 function (a, b, p) {
\r
20 Clazz.superConstructor (this, com.stevesoft.pat.FastMulti, []);
\r
22 com.stevesoft.pat.RegSyntaxError.endItAll ("Null length pattern followed by *, +, or other Multi.");
\r
23 }this.fewestMatches = a;
\r
24 this.mostMatches = b;
\r
26 this.step = p.countMinChars ().intValue ();
\r
27 this.sub.setParent (null);
\r
28 }, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern");
\r
29 Clazz.defineMethod (c$, "toString",
\r
31 return this.sub.toString () + "{" + this.fewestMatches + "," + this.mostMatches + "}" + (this.matchFewest ? "?" : "") + "(?# <= fast multi)" + this.nextString ();
\r
33 Clazz.defineMethod (c$, "matchInternal",
\r
34 function (pos, pt) {
\r
37 var endstr = pt.src.length () - this.step;
\r
38 var matches = new com.stevesoft.pat.patInt (0);
\r
39 if (this.matchFewest) {
\r
40 if (this.fewestMatches.lessEq (matches)) {
\r
41 var ii = this.nextMatch (i, pt);
\r
44 }}while (i >= 0 && i <= endstr) {
\r
45 i = this.sub.matchInternal (i, pt);
\r
48 if (this.fewestMatches.lessEq (matches)) {
\r
49 var ii = this.nextMatch (i, pt);
\r
52 }}if (matches.equals (this.mostMatches)) {
\r
57 while (this.fewestMatches.intValue () > nMatches) {
\r
58 i = this.sub.matchInternal (i, pt);
\r
65 if (this.mostMatches.finite ()) {
\r
66 while (nMatches < this.mostMatches.intValue ()) {
\r
67 i = this.sub.matchInternal (i, pt);
\r
76 i = this.sub.matchInternal (i, pt);
\r
84 var r = this.nextMatch (m, pt);
\r
89 if (nMatches < this.fewestMatches.intValue ()) {
\r
93 }, "~N,com.stevesoft.pat.Pthings");
\r
94 Clazz.overrideMethod (c$, "clone1",
\r
97 var fm = new com.stevesoft.pat.FastMulti (this.fewestMatches, this.mostMatches, this.sub.clone (h));
\r
98 fm.matchFewest = this.matchFewest;
\r
101 if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) {
\r
107 }, "java.util.Hashtable");
\r