X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fcom%2Fstevesoft%2Fpat%2FSkipBMH.js;fp=site%2Fj2s%2Fcom%2Fstevesoft%2Fpat%2FSkipBMH.js;h=ac81e43379105aa1857e28317df0dc4959fac75d;hp=9ea41165e49c5934855ac85e9e2af3f286c72593;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/com/stevesoft/pat/SkipBMH.js b/site/j2s/com/stevesoft/pat/SkipBMH.js index 9ea4116..ac81e43 100644 --- a/site/j2s/com/stevesoft/pat/SkipBMH.js +++ b/site/j2s/com/stevesoft/pat/SkipBMH.js @@ -1,154 +1,154 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Skip"], "com.stevesoft.pat.SkipBMH", ["com.stevesoft.pat.CaseMgr", "com.stevesoft.pat.wrap.StringWrap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.MAX_CHAR = 64; -this.skip = null; -this.sm1 = 0; -this.jump_ahead = 0; -this.uc = '\0'; -this.lc = '\0'; -this.tc = '\0'; -this.x = '\0'; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "SkipBMH", com.stevesoft.pat.Skip); -Clazz.prepareFields (c$, function () { -this.skip = Clazz.newCharArray (64, '\0'); -}); -Clazz.defineMethod (c$, "exact", -function (c) { -return (this.ign && this.anyc (c)) || c == this.x; -}, "~S"); -Clazz.defineMethod (c$, "anyc", -function (c) { -return c == this.uc || c == this.lc || c == this.tc; -}, "~S"); -Clazz.makeConstructor (c$, -function (pt, ign) { -this.construct (pt, ign, 0); -}, "~S,~B"); -Clazz.makeConstructor (c$, -function (pt) { -this.construct (pt, false, 0); -}, "~S"); -Clazz.makeConstructor (c$, -function (pt, ign, offset) { -Clazz.superConstructor (this, com.stevesoft.pat.SkipBMH, [pt, ign, offset]); -for (var k = 0; k < 64; k++) { -this.skip[k] = String.fromCharCode (this.src.length); -} -this.sm1 = this.src.length - 1; -this.x = this.src.charAt (this.sm1); -this.uc = com.stevesoft.pat.CaseMgr.toUpperCaseC (this.x); -this.lc = com.stevesoft.pat.CaseMgr.toLowerCaseC (this.x); -this.tc = com.stevesoft.pat.CaseMgr.toTitleCaseC (this.x); -for (var k = 0; k < this.src.length - 1; k++) { -var x_ = this.src.charAt (k); -if (ign) { -var uc_ = com.stevesoft.pat.CaseMgr.toUpperCaseC (x_); -var lc_ = com.stevesoft.pat.CaseMgr.toLowerCaseC (x_); -var tc_ = com.stevesoft.pat.CaseMgr.toTitleCaseC (x_); -this.skip[uc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); -this.skip[lc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); -this.skip[tc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); -} else { -this.skip[x_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); -}} -this.jump_ahead = this.src.length - 1; -for (var k = 0; k < this.src.length - 1; k++) { -var y = this.src.charAt (this.sm1 - k - 1); -if (this.exact (y)) { -this.jump_ahead = k; -break; -}} -}, "~S,~B,~N"); -Clazz.defineMethod (c$, "searchRegion", -function (s, start, end) { -return this.find (s, start, end); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "searchFrom", -function (s, start) { -return this.find (s, start, s.length); -}, "~S,~N"); -Clazz.defineMethod (c$, "search", -function (s) { -return this.find (s, 0, s.length); -}, "~S"); -Clazz.defineMethod (c$, "find", -function (s, start, end) { -start += this.$offset + this.sm1; -var vend = com.stevesoft.pat.Skip.min (s.length - 1, end + this.sm1 + this.$offset); -var k; -var vend1 = vend - this.jump_ahead; -if (this.ign) { -for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.anyc (s.charAt (k))) { -if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -}} -for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.anyc (s.charAt (k))) { -if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -if (k > vend) { -return -1; -}}} -} else { -for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.x == s.charAt (k)) { -if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -}} -for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.x == s.charAt (k)) { -if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -if (k > vend) { -return -1; -}}} -}return -1; -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "find", -function (s, start, end) { -if (Clazz.instanceOf (s, com.stevesoft.pat.wrap.StringWrap)) { -return this.find (s.toString (), start, end); -}start += this.$offset + this.sm1; -var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.sm1 + this.$offset); -var k; -var vend1 = vend - this.jump_ahead; -if (this.ign) { -for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.anyc (s.charAt (k))) { -if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -}} -for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.anyc (s.charAt (k))) { -if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -if (k > vend) { -return -1; -}}} -} else { -for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.x == s.charAt (k)) { -if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -}} -for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.x == s.charAt (k)) { -if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -if (k > vend) { -return -1; -}}} -}return -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Skip"], "com.stevesoft.pat.SkipBMH", ["com.stevesoft.pat.CaseMgr", "com.stevesoft.pat.wrap.StringWrap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.MAX_CHAR = 64; +this.skip = null; +this.sm1 = 0; +this.jump_ahead = 0; +this.uc = '\0'; +this.lc = '\0'; +this.tc = '\0'; +this.x = '\0'; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "SkipBMH", com.stevesoft.pat.Skip); +Clazz.prepareFields (c$, function () { +this.skip = Clazz.newCharArray (64, '\0'); +}); +Clazz.defineMethod (c$, "exact", +function (c) { +return (this.ign && this.anyc (c)) || c == this.x; +}, "~S"); +Clazz.defineMethod (c$, "anyc", +function (c) { +return c == this.uc || c == this.lc || c == this.tc; +}, "~S"); +Clazz.makeConstructor (c$, +function (pt, ign) { +this.construct (pt, ign, 0); +}, "~S,~B"); +Clazz.makeConstructor (c$, +function (pt) { +this.construct (pt, false, 0); +}, "~S"); +Clazz.makeConstructor (c$, +function (pt, ign, offset) { +Clazz.superConstructor (this, com.stevesoft.pat.SkipBMH, [pt, ign, offset]); +for (var k = 0; k < 64; k++) { +this.skip[k] = String.fromCharCode (this.src.length); +} +this.sm1 = this.src.length - 1; +this.x = this.src.charAt (this.sm1); +this.uc = com.stevesoft.pat.CaseMgr.toUpperCaseC (this.x); +this.lc = com.stevesoft.pat.CaseMgr.toLowerCaseC (this.x); +this.tc = com.stevesoft.pat.CaseMgr.toTitleCaseC (this.x); +for (var k = 0; k < this.src.length - 1; k++) { +var x_ = this.src.charAt (k); +if (ign) { +var uc_ = com.stevesoft.pat.CaseMgr.toUpperCaseC (x_); +var lc_ = com.stevesoft.pat.CaseMgr.toLowerCaseC (x_); +var tc_ = com.stevesoft.pat.CaseMgr.toTitleCaseC (x_); +this.skip[uc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); +this.skip[lc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); +this.skip[tc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); +} else { +this.skip[x_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); +}} +this.jump_ahead = this.src.length - 1; +for (var k = 0; k < this.src.length - 1; k++) { +var y = this.src.charAt (this.sm1 - k - 1); +if (this.exact (y)) { +this.jump_ahead = k; +break; +}} +}, "~S,~B,~N"); +Clazz.defineMethod (c$, "searchRegion", +function (s, start, end) { +return this.find (s, start, end); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "searchFrom", +function (s, start) { +return this.find (s, start, s.length); +}, "~S,~N"); +Clazz.defineMethod (c$, "search", +function (s) { +return this.find (s, 0, s.length); +}, "~S"); +Clazz.defineMethod (c$, "find", +function (s, start, end) { +start += this.$offset + this.sm1; +var vend = com.stevesoft.pat.Skip.min (s.length - 1, end + this.sm1 + this.$offset); +var k; +var vend1 = vend - this.jump_ahead; +if (this.ign) { +for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.anyc (s.charAt (k))) { +if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +}} +for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.anyc (s.charAt (k))) { +if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +if (k > vend) { +return -1; +}}} +} else { +for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.x == s.charAt (k)) { +if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +}} +for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.x == s.charAt (k)) { +if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +if (k > vend) { +return -1; +}}} +}return -1; +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "find", +function (s, start, end) { +if (Clazz.instanceOf (s, com.stevesoft.pat.wrap.StringWrap)) { +return this.find (s.toString (), start, end); +}start += this.$offset + this.sm1; +var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.sm1 + this.$offset); +var k; +var vend1 = vend - this.jump_ahead; +if (this.ign) { +for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.anyc (s.charAt (k))) { +if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +}} +for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.anyc (s.charAt (k))) { +if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +if (k > vend) { +return -1; +}}} +} else { +for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.x == s.charAt (k)) { +if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +}} +for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.x == s.charAt (k)) { +if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +if (k > vend) { +return -1; +}}} +}return -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +});