1 Clazz.declarePackage ("com.stevesoft.pat");
\r
2 Clazz.load (["com.stevesoft.pat.Skip"], "com.stevesoft.pat.SkipBMH", ["com.stevesoft.pat.CaseMgr", "com.stevesoft.pat.wrap.StringWrap"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
12 Clazz.instantialize (this, arguments);
\r
13 }, com.stevesoft.pat, "SkipBMH", com.stevesoft.pat.Skip);
\r
14 Clazz.prepareFields (c$, function () {
\r
15 this.skip = Clazz.newCharArray (64, '\0');
\r
17 Clazz.defineMethod (c$, "exact",
\r
19 return (this.ign && this.anyc (c)) || c == this.x;
\r
21 Clazz.defineMethod (c$, "anyc",
\r
23 return c == this.uc || c == this.lc || c == this.tc;
\r
25 Clazz.makeConstructor (c$,
\r
26 function (pt, ign) {
\r
27 this.construct (pt, ign, 0);
\r
29 Clazz.makeConstructor (c$,
\r
31 this.construct (pt, false, 0);
\r
33 Clazz.makeConstructor (c$,
\r
34 function (pt, ign, offset) {
\r
35 Clazz.superConstructor (this, com.stevesoft.pat.SkipBMH, [pt, ign, offset]);
\r
36 for (var k = 0; k < 64; k++) {
\r
37 this.skip[k] = String.fromCharCode (this.src.length);
\r
39 this.sm1 = this.src.length - 1;
\r
40 this.x = this.src.charAt (this.sm1);
\r
41 this.uc = com.stevesoft.pat.CaseMgr.toUpperCaseC (this.x);
\r
42 this.lc = com.stevesoft.pat.CaseMgr.toLowerCaseC (this.x);
\r
43 this.tc = com.stevesoft.pat.CaseMgr.toTitleCaseC (this.x);
\r
44 for (var k = 0; k < this.src.length - 1; k++) {
\r
45 var x_ = this.src.charAt (k);
\r
47 var uc_ = com.stevesoft.pat.CaseMgr.toUpperCaseC (x_);
\r
48 var lc_ = com.stevesoft.pat.CaseMgr.toLowerCaseC (x_);
\r
49 var tc_ = com.stevesoft.pat.CaseMgr.toTitleCaseC (x_);
\r
50 this.skip[uc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1);
\r
51 this.skip[lc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1);
\r
52 this.skip[tc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1);
\r
54 this.skip[x_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1);
\r
56 this.jump_ahead = this.src.length - 1;
\r
57 for (var k = 0; k < this.src.length - 1; k++) {
\r
58 var y = this.src.charAt (this.sm1 - k - 1);
\r
59 if (this.exact (y)) {
\r
60 this.jump_ahead = k;
\r
64 Clazz.defineMethod (c$, "searchRegion",
\r
65 function (s, start, end) {
\r
66 return this.find (s, start, end);
\r
68 Clazz.defineMethod (c$, "searchFrom",
\r
69 function (s, start) {
\r
70 return this.find (s, start, s.length);
\r
72 Clazz.defineMethod (c$, "search",
\r
74 return this.find (s, 0, s.length);
\r
76 Clazz.defineMethod (c$, "find",
\r
77 function (s, start, end) {
\r
78 start += this.$offset + this.sm1;
\r
79 var vend = com.stevesoft.pat.Skip.min (s.length - 1, end + this.sm1 + this.$offset);
\r
81 var vend1 = vend - this.jump_ahead;
\r
83 for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) {
\r
84 if (this.anyc (s.charAt (k))) {
\r
85 if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) {
\r
86 return k - this.sm1 - this.$offset;
\r
87 }k += this.jump_ahead;
\r
89 for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) {
\r
90 if (this.anyc (s.charAt (k))) {
\r
91 if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) {
\r
92 return k - this.sm1 - this.$offset;
\r
93 }k += this.jump_ahead;
\r
98 for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) {
\r
99 if (this.x == s.charAt (k)) {
\r
100 if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) {
\r
101 return k - this.sm1 - this.$offset;
\r
102 }k += this.jump_ahead;
\r
104 for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) {
\r
105 if (this.x == s.charAt (k)) {
\r
106 if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) {
\r
107 return k - this.sm1 - this.$offset;
\r
108 }k += this.jump_ahead;
\r
114 Clazz.defineMethod (c$, "find",
\r
115 function (s, start, end) {
\r
116 if (Clazz.instanceOf (s, com.stevesoft.pat.wrap.StringWrap)) {
\r
117 return this.find (s.toString (), start, end);
\r
118 }start += this.$offset + this.sm1;
\r
119 var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.sm1 + this.$offset);
\r
121 var vend1 = vend - this.jump_ahead;
\r
123 for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) {
\r
124 if (this.anyc (s.charAt (k))) {
\r
125 if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) {
\r
126 return k - this.sm1 - this.$offset;
\r
127 }k += this.jump_ahead;
\r
129 for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) {
\r
130 if (this.anyc (s.charAt (k))) {
\r
131 if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) {
\r
132 return k - this.sm1 - this.$offset;
\r
133 }k += this.jump_ahead;
\r
138 for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) {
\r
139 if (this.x == s.charAt (k)) {
\r
140 if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) {
\r
141 return k - this.sm1 - this.$offset;
\r
142 }k += this.jump_ahead;
\r
144 for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) {
\r
145 if (this.x == s.charAt (k)) {
\r
146 if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) {
\r
147 return k - this.sm1 - this.$offset;
\r
148 }k += this.jump_ahead;
\r
153 }, "com.stevesoft.pat.StringLike,~N,~N");
\r