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