X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fcom%2Fstevesoft%2Fpat%2FReplacer.js;h=996de92c12fd800ee831306923489f2ad37cc375;hp=847b11c055cd5422b4c849f41b61f868c71a2a46;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/site/j2s/com/stevesoft/pat/Replacer.js b/site/j2s/com/stevesoft/pat/Replacer.js index 847b11c..996de92 100644 --- a/site/j2s/com/stevesoft/pat/Replacer.js +++ b/site/j2s/com/stevesoft/pat/Replacer.js @@ -1,230 +1,230 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, ["com.stevesoft.pat.RegHolder", "$.Replacer", "$.CodeVal"], ["com.stevesoft.pat.AmpersandRule", "$.ChangeRule", "$.MessageManager", "$.PopRule", "$.PushRule", "$.RuleHolder", "$.SpecialRule", "$.StringBufferLike", "$.WantMoreTextReplaceRule", "com.stevesoft.pat.wrap.StringWrap", "java.lang.NullPointerException"], function () { -c$ = Clazz.decorateAsClass (function () { -this.me = null; -this.prev = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RegHolder"); -c$ = Clazz.decorateAsClass (function () { -this.pos = 0; -this.code = '\0'; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "CodeVal"); -Clazz.makeConstructor (c$, -function (p, c) { -this.pos = p; -this.code = c; -}, "~N,~S"); -Clazz.overrideMethod (c$, "toString", -function () { -return "(" + this.pos + "," + this.code + ")"; -}); -c$ = Clazz.decorateAsClass (function () { -this.first = false; -this.rh = null; -this.sb = null; -this.src = null; -this.pos = 0; -this.want_more_text = false; -this.want_more_text_enable = false; -this.$lastMatchedTo = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Replacer"); -Clazz.prepareFields (c$, function () { -this.rh = new com.stevesoft.pat.RegHolder (); -}); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "replaceFirstRegion", -function (s, r, start, end) { -return this.replaceFirstRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end); -}, "~S,com.stevesoft.pat.Regex,~N,~N"); -Clazz.defineMethod (c$, "replaceFirstRegion", -function (s, r, start, end) { -this.first = true; -this.rh.me = r; -this.rh.prev = null; -return this.dorep (s, start, end); -}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N"); -Clazz.defineMethod (c$, "replaceFirst", -function (s) { -return this.replaceFirstRegion (s, 0, s.length ()); -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "replaceFirstFrom", -function (s, start) { -return this.replaceFirstRegion (s, start, s.length ()); -}, "com.stevesoft.pat.StringLike,~N"); -Clazz.defineMethod (c$, "replaceFirstRegion", -function (s, start, end) { -this.first = true; -return this.dorep (s, start, end); -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, r, start, end) { -return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end); -}, "~S,com.stevesoft.pat.Regex,~N,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, r, start, end) { -this.first = false; -this.rh.me = r; -this.rh.prev = null; -return this.dorep (s, start, end); -}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N"); -Clazz.defineMethod (c$, "replaceAll", -function (s) { -return this.replaceAllRegion (s, 0, s.length ()); -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "replaceAllFrom", -function (s, start) { -return this.replaceAllRegion (s, start, s.length ()); -}, "com.stevesoft.pat.StringLike,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, start, end) { -this.first = false; -return this.dorep (s, start, end); -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "replaceAll", -function (s) { -return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), 0, s.length).toString (); -}, "~S"); -Clazz.defineMethod (c$, "replaceAllFrom", -function (s, start) { -return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), start, s.length).toString (); -}, "~S,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, start, end) { -this.first = false; -return this.dorep ( new com.stevesoft.pat.wrap.StringWrap (s), start, end).toString (); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "isSpecial", -function (x) { -while (x != null) { -if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule) || (Clazz.instanceOf (x, com.stevesoft.pat.RuleHolder) && Clazz.instanceOf ((x).held, com.stevesoft.pat.SpecialRule))) { -return true; -}x = x.next; -} -return false; -}, "com.stevesoft.pat.ReplaceRule"); -Clazz.defineMethod (c$, "apply1", -function (rr) { -rr.charsMatched_++; -this.apply (rr, null); -rr.charsMatched_--; -}, "com.stevesoft.pat.RegRes"); -Clazz.defineMethod (c$, "dorep", -function (s, start, end) { -var ret = s; -this.want_more_text = false; -this.$lastMatchedTo = 0; -if (this.rh.me == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.replace_null_regex_pointer")); -}if (this.rh.me._searchLike (s, start, end)) { -var rmn = this.rh.me.matchedTo (); -if (this.rh.me.charsMatched () == 0 && !this.isSpecial (this.rh.me.getReplaceRule ())) { -this.apply1 (this.rh.me); -rmn++; -}this.apply (this.rh.me); -if (!this.first) { -for (var i = rmn; !this.want_more_text && this.rh.me._searchLike (s, i, end); i = rmn) { -rmn = this.rh.me.matchedTo (); -if (this.rh.me.charsMatched () == 0) { -if (!this.isSpecial (this.rh.me.getReplaceRule ())) { -this.apply1 (this.rh.me); -}rmn++; -}this.apply (this.rh.me); -} -}ret = this.finish (); -ret = ret == null ? s : ret; -}return ret; -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "apply", -function (r, rp) { -if (rp == null || (rp.next == null && Clazz.instanceOf (rp, com.stevesoft.pat.AmpersandRule))) { -return; -}if (r.didMatch ()) { -if (this.src == null) { -this.src = r.getStringLike (); -}if (this.sb == null) { -this.sb = new com.stevesoft.pat.StringBufferLike (this.src.newStringBufferLike ()); -}var rmf = r.matchedFrom (); -for (var ii = this.pos; ii < rmf; ii++) { -this.sb.appendC (this.src.charAt (ii)); -} -for (var x = rp; x != null; x = x.next) { -x.apply (this.sb, r); -if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule)) { -if (Clazz.instanceOf (x, com.stevesoft.pat.WantMoreTextReplaceRule) && this.want_more_text_enable) { -this.want_more_text = true; -} else if (Clazz.instanceOf (x, com.stevesoft.pat.PushRule)) { -var rh2 = new com.stevesoft.pat.RegHolder (); -rh2.me = (x).NewRule; -rh2.prev = this.rh; -this.rh = rh2; -} else if (Clazz.instanceOf (x, com.stevesoft.pat.PopRule)) { -if (this.rh.prev != null) { -this.rh = this.rh.prev; -}} else if (Clazz.instanceOf (x, com.stevesoft.pat.ChangeRule)) { -this.rh.me = (x).NewRule; -}}} -if (!this.want_more_text) { -this.pos = r.matchedTo (); -}}}, "com.stevesoft.pat.RegRes,com.stevesoft.pat.ReplaceRule"); -Clazz.defineMethod (c$, "WantMoreText", -function () { -return this.want_more_text; -}); -Clazz.defineMethod (c$, "apply", -function (r) { -this.apply (r, r.getReplaceRule ()); -}, "com.stevesoft.pat.Regex"); -Clazz.defineMethod (c$, "finish", -function () { -if (this.src == null) { -return null; -}var s_end = this.src.length (); -for (var ii = this.pos; ii < s_end; ii++) { -this.sb.appendC (this.src.charAt (ii)); -} -this.src = null; -this.$lastMatchedTo = this.pos; -this.pos = 0; -var retstr = this.sb.toStringLike (); -this.sb = null; -return retstr; -}); -Clazz.overrideMethod (c$, "clone", -function () { -var r = new com.stevesoft.pat.Replacer (); -r.first = this.first; -r.src = this.src; -r.sb = this.sb; -r.pos = this.pos; -r.$lastMatchedTo = this.$lastMatchedTo; -r.want_more_text = this.want_more_text; -r.want_more_text_enable = this.want_more_text_enable; -r.rh.me = this.rh.me; -r.rh.prev = this.rh.prev; -return r; -}); -Clazz.defineMethod (c$, "lastMatchedTo", -function () { -return this.$lastMatchedTo; -}); -Clazz.defineMethod (c$, "getRegex", -function () { -return this.rh.me; -}); -Clazz.defineMethod (c$, "setSource", -function (sl) { -this.src = sl; -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "setBuffer", -function (sbl) { -this.sb = sbl; -}, "com.stevesoft.pat.StringBufferLike"); -Clazz.defineMethod (c$, "setPos", -function (pos) { -this.pos = pos; -}, "~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, ["com.stevesoft.pat.RegHolder", "$.Replacer", "$.CodeVal"], ["com.stevesoft.pat.AmpersandRule", "$.ChangeRule", "$.MessageManager", "$.PopRule", "$.PushRule", "$.RuleHolder", "$.SpecialRule", "$.StringBufferLike", "$.WantMoreTextReplaceRule", "com.stevesoft.pat.wrap.StringWrap", "java.lang.NullPointerException"], function () { +c$ = Clazz.decorateAsClass (function () { +this.me = null; +this.prev = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RegHolder"); +c$ = Clazz.decorateAsClass (function () { +this.pos = 0; +this.code = '\0'; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "CodeVal"); +Clazz.makeConstructor (c$, +function (p, c) { +this.pos = p; +this.code = c; +}, "~N,~S"); +Clazz.overrideMethod (c$, "toString", +function () { +return "(" + this.pos + "," + this.code + ")"; +}); +c$ = Clazz.decorateAsClass (function () { +this.first = false; +this.rh = null; +this.sb = null; +this.src = null; +this.pos = 0; +this.want_more_text = false; +this.want_more_text_enable = false; +this.$lastMatchedTo = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Replacer"); +Clazz.prepareFields (c$, function () { +this.rh = new com.stevesoft.pat.RegHolder (); +}); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "replaceFirstRegion", +function (s, r, start, end) { +return this.replaceFirstRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end); +}, "~S,com.stevesoft.pat.Regex,~N,~N"); +Clazz.defineMethod (c$, "replaceFirstRegion", +function (s, r, start, end) { +this.first = true; +this.rh.me = r; +this.rh.prev = null; +return this.dorep (s, start, end); +}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N"); +Clazz.defineMethod (c$, "replaceFirst", +function (s) { +return this.replaceFirstRegion (s, 0, s.length ()); +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "replaceFirstFrom", +function (s, start) { +return this.replaceFirstRegion (s, start, s.length ()); +}, "com.stevesoft.pat.StringLike,~N"); +Clazz.defineMethod (c$, "replaceFirstRegion", +function (s, start, end) { +this.first = true; +return this.dorep (s, start, end); +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, r, start, end) { +return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end); +}, "~S,com.stevesoft.pat.Regex,~N,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, r, start, end) { +this.first = false; +this.rh.me = r; +this.rh.prev = null; +return this.dorep (s, start, end); +}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N"); +Clazz.defineMethod (c$, "replaceAll", +function (s) { +return this.replaceAllRegion (s, 0, s.length ()); +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "replaceAllFrom", +function (s, start) { +return this.replaceAllRegion (s, start, s.length ()); +}, "com.stevesoft.pat.StringLike,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, start, end) { +this.first = false; +return this.dorep (s, start, end); +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "replaceAll", +function (s) { +return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), 0, s.length).toString (); +}, "~S"); +Clazz.defineMethod (c$, "replaceAllFrom", +function (s, start) { +return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), start, s.length).toString (); +}, "~S,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, start, end) { +this.first = false; +return this.dorep ( new com.stevesoft.pat.wrap.StringWrap (s), start, end).toString (); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "isSpecial", +function (x) { +while (x != null) { +if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule) || (Clazz.instanceOf (x, com.stevesoft.pat.RuleHolder) && Clazz.instanceOf ((x).held, com.stevesoft.pat.SpecialRule))) { +return true; +}x = x.next; +} +return false; +}, "com.stevesoft.pat.ReplaceRule"); +Clazz.defineMethod (c$, "apply1", +function (rr) { +rr.charsMatched_++; +this.apply (rr, null); +rr.charsMatched_--; +}, "com.stevesoft.pat.RegRes"); +Clazz.defineMethod (c$, "dorep", +function (s, start, end) { +var ret = s; +this.want_more_text = false; +this.$lastMatchedTo = 0; +if (this.rh.me == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.replace_null_regex_pointer")); +}if (this.rh.me._searchLike (s, start, end)) { +var rmn = this.rh.me.matchedTo (); +if (this.rh.me.charsMatched () == 0 && !this.isSpecial (this.rh.me.getReplaceRule ())) { +this.apply1 (this.rh.me); +rmn++; +}this.apply (this.rh.me); +if (!this.first) { +for (var i = rmn; !this.want_more_text && this.rh.me._searchLike (s, i, end); i = rmn) { +rmn = this.rh.me.matchedTo (); +if (this.rh.me.charsMatched () == 0) { +if (!this.isSpecial (this.rh.me.getReplaceRule ())) { +this.apply1 (this.rh.me); +}rmn++; +}this.apply (this.rh.me); +} +}ret = this.finish (); +ret = ret == null ? s : ret; +}return ret; +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "apply", +function (r, rp) { +if (rp == null || (rp.next == null && Clazz.instanceOf (rp, com.stevesoft.pat.AmpersandRule))) { +return; +}if (r.didMatch ()) { +if (this.src == null) { +this.src = r.getStringLike (); +}if (this.sb == null) { +this.sb = new com.stevesoft.pat.StringBufferLike (this.src.newStringBufferLike ()); +}var rmf = r.matchedFrom (); +for (var ii = this.pos; ii < rmf; ii++) { +this.sb.appendC (this.src.charAt (ii)); +} +for (var x = rp; x != null; x = x.next) { +x.apply (this.sb, r); +if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule)) { +if (Clazz.instanceOf (x, com.stevesoft.pat.WantMoreTextReplaceRule) && this.want_more_text_enable) { +this.want_more_text = true; +} else if (Clazz.instanceOf (x, com.stevesoft.pat.PushRule)) { +var rh2 = new com.stevesoft.pat.RegHolder (); +rh2.me = (x).NewRule; +rh2.prev = this.rh; +this.rh = rh2; +} else if (Clazz.instanceOf (x, com.stevesoft.pat.PopRule)) { +if (this.rh.prev != null) { +this.rh = this.rh.prev; +}} else if (Clazz.instanceOf (x, com.stevesoft.pat.ChangeRule)) { +this.rh.me = (x).NewRule; +}}} +if (!this.want_more_text) { +this.pos = r.matchedTo (); +}}}, "com.stevesoft.pat.RegRes,com.stevesoft.pat.ReplaceRule"); +Clazz.defineMethod (c$, "WantMoreText", +function () { +return this.want_more_text; +}); +Clazz.defineMethod (c$, "apply", +function (r) { +this.apply (r, r.getReplaceRule ()); +}, "com.stevesoft.pat.Regex"); +Clazz.defineMethod (c$, "finish", +function () { +if (this.src == null) { +return null; +}var s_end = this.src.length (); +for (var ii = this.pos; ii < s_end; ii++) { +this.sb.appendC (this.src.charAt (ii)); +} +this.src = null; +this.$lastMatchedTo = this.pos; +this.pos = 0; +var retstr = this.sb.toStringLike (); +this.sb = null; +return retstr; +}); +Clazz.overrideMethod (c$, "clone", +function () { +var r = new com.stevesoft.pat.Replacer (); +r.first = this.first; +r.src = this.src; +r.sb = this.sb; +r.pos = this.pos; +r.$lastMatchedTo = this.$lastMatchedTo; +r.want_more_text = this.want_more_text; +r.want_more_text_enable = this.want_more_text_enable; +r.rh.me = this.rh.me; +r.rh.prev = this.rh.prev; +return r; +}); +Clazz.defineMethod (c$, "lastMatchedTo", +function () { +return this.$lastMatchedTo; +}); +Clazz.defineMethod (c$, "getRegex", +function () { +return this.rh.me; +}); +Clazz.defineMethod (c$, "setSource", +function (sl) { +this.src = sl; +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "setBuffer", +function (sbl) { +this.sb = sbl; +}, "com.stevesoft.pat.StringBufferLike"); +Clazz.defineMethod (c$, "setPos", +function (pos) { +this.pos = pos; +}, "~N"); +});