JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / com / stevesoft / pat / Skip2.js
1 Clazz.declarePackage ("com.stevesoft.pat");\r
2 Clazz.load (["com.stevesoft.pat.Skip"], "com.stevesoft.pat.Skip2", ["com.stevesoft.pat.CaseMgr"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.c1 = 0;\r
5 this.mask1 = 0;\r
6 Clazz.instantialize (this, arguments);\r
7 }, com.stevesoft.pat, "Skip2", com.stevesoft.pat.Skip);\r
8 Clazz.makeConstructor (c$, \r
9 function (s, ign, offset) {\r
10 Clazz.superConstructor (this, com.stevesoft.pat.Skip2, [s, ign, offset]);\r
11 this.c1 = s.charCodeAt (1);\r
12 this.m1 = 2 == s.length;\r
13 if (ign) {\r
14 this.mask1 = com.stevesoft.pat.Skip.mkmask (this.c1);\r
15 } else {\r
16 this.mask1 = 0;\r
17 }}, "~S,~B,~N");\r
18 Clazz.defineMethod (c$, "find", \r
19 function (s, start, end) {\r
20 if (start > end) {\r
21 return -1;\r
22 }start += this.$offset;\r
23 var vend = com.stevesoft.pat.Skip.min (s.length () - 2, end + this.$offset);\r
24 for (var i = start; i <= vend; i++) {\r
25 if (0 == (s.charCodeAt (i) & this.mask) && 0 == (s.charCodeAt (i + 1) & this.mask1)) {\r
26 if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) {\r
27 return i - this.$offset;\r
28 }}}\r
29 return -1;\r
30 }, "com.stevesoft.pat.StringLike,~N,~N");\r
31 });\r