JAL-1807 test
[jalviewjs.git] / bin / com / stevesoft / pat / DotMulti.js
1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.DotMulti", null, function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.fewestMatches = null;
5 this.mostMatches = null;
6 this.matchFewest = false;
7 this.src = null;
8 this.srclength = 0;
9 this.dotDoesntMatchCR = true;
10 Clazz.instantialize (this, arguments);
11 }, com.stevesoft.pat, "DotMulti", com.stevesoft.pat.PatternSub);
12 Clazz.overrideMethod (c$, "minChars", 
13 function () {
14 return this.fewestMatches;
15 });
16 Clazz.overrideMethod (c$, "maxChars", 
17 function () {
18 return this.mostMatches;
19 });
20 Clazz.makeConstructor (c$, 
21 function (a, b) {
22 Clazz.superConstructor (this, com.stevesoft.pat.DotMulti, []);
23 this.fewestMatches = a;
24 this.mostMatches = b;
25 }, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt");
26 Clazz.overrideMethod (c$, "toString", 
27 function () {
28 return ".{" + this.fewestMatches + "," + this.mostMatches + "}" + (this.matchFewest ? "?" : "") + "(?# <= dot multi)" + this.nextString ();
29 });
30 Clazz.defineMethod (c$, "submatchInternal", 
31 function (pos, pt) {
32 if (pos < this.srclength) {
33 if (this.dotDoesntMatchCR) {
34 if (this.src.charAt (pos) != '\n') {
35 return 1 + pos;
36 }} else {
37 return 1 + pos;
38 }}return -1;
39 }, "~N,com.stevesoft.pat.Pthings");
40 Clazz.overrideMethod (c$, "matchInternal", 
41 function (pos, pt) {
42 var m = -1;
43 var i = pos;
44 this.src = pt.src;
45 this.srclength = this.src.length ();
46 this.dotDoesntMatchCR = pt.dotDoesntMatchCR;
47 if (this.matchFewest) {
48 var nMatches = 0;
49 while (this.fewestMatches.intValue () > nMatches) {
50 i = this.submatchInternal (i, pt);
51 if (i < 0) {
52 return -1;
53 }nMatches++;
54 }
55 if (i < 0) {
56 return -1;
57 }var ii = this.nextMatch (i, pt);
58 if (ii >= 0) {
59 return ii;
60 }if (!this.mostMatches.finite ()) {
61 while (i >= 0) {
62 i = this.submatchInternal (i, pt);
63 if (i < 0) {
64 return -1;
65 }ii = this.nextMatch (i, pt);
66 if (ii >= 0) {
67 return ii;
68 }}
69 } else {
70 while (i > 0) {
71 i = this.submatchInternal (i, pt);
72 if (i < 0) {
73 return -1;
74 }nMatches++;
75 if (nMatches > this.mostMatches.intValue ()) {
76 return -1;
77 }ii = this.nextMatch (i, pt);
78 if (ii >= 0) {
79 return ii;
80 }}
81 }return -1;
82 }var nMatches = 0;
83 while (this.fewestMatches.intValue () > nMatches) {
84 i = this.submatchInternal (i, pt);
85 if (i >= 0) {
86 nMatches++;
87 } else {
88 return -1;
89 }}
90 m = i;
91 if (this.mostMatches.finite ()) {
92 while (nMatches < this.mostMatches.intValue ()) {
93 i = this.submatchInternal (i, pt);
94 if (i >= 0) {
95 m = i;
96 nMatches++;
97 } else {
98 break;
99 }}
100 } else {
101 while (true) {
102 i = this.submatchInternal (i, pt);
103 if (i >= 0) {
104 m = i;
105 nMatches++;
106 } else {
107 break;
108 }}
109 }while (m >= pos) {
110 var r = this.nextMatch (m, pt);
111 if (r >= 0) {
112 return r;
113 }m -= 1;
114 nMatches--;
115 if (nMatches < this.fewestMatches.intValue ()) {
116 return -1;
117 }}
118 return -1;
119 }, "~N,com.stevesoft.pat.Pthings");
120 Clazz.overrideMethod (c$, "clone1", 
121 function (h) {
122 var dm =  new com.stevesoft.pat.DotMulti (this.fewestMatches, this.mostMatches);
123 dm.matchFewest = this.matchFewest;
124 return dm;
125 }, "java.util.Hashtable");
126 Clazz.defineStatics (c$,
127 "step", 1,
128 "idcount", 1);
129 });