Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / com / stevesoft / pat / Replacer.js
index 847b11c..996de92 100644 (file)
-Clazz.declarePackage ("com.stevesoft.pat");\r
-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 () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.me = null;\r
-this.prev = null;\r
-Clazz.instantialize (this, arguments);\r
-}, com.stevesoft.pat, "RegHolder");\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.pos = 0;\r
-this.code = '\0';\r
-Clazz.instantialize (this, arguments);\r
-}, com.stevesoft.pat, "CodeVal");\r
-Clazz.makeConstructor (c$, \r
-function (p, c) {\r
-this.pos = p;\r
-this.code = c;\r
-}, "~N,~S");\r
-Clazz.overrideMethod (c$, "toString", \r
-function () {\r
-return "(" + this.pos + "," + this.code + ")";\r
-});\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.first = false;\r
-this.rh = null;\r
-this.sb = null;\r
-this.src = null;\r
-this.pos = 0;\r
-this.want_more_text = false;\r
-this.want_more_text_enable = false;\r
-this.$lastMatchedTo = 0;\r
-Clazz.instantialize (this, arguments);\r
-}, com.stevesoft.pat, "Replacer");\r
-Clazz.prepareFields (c$, function () {\r
-this.rh =  new com.stevesoft.pat.RegHolder ();\r
-});\r
-Clazz.makeConstructor (c$, \r
-function () {\r
-});\r
-Clazz.defineMethod (c$, "replaceFirstRegion", \r
-function (s, r, start, end) {\r
-return this.replaceFirstRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end);\r
-}, "~S,com.stevesoft.pat.Regex,~N,~N");\r
-Clazz.defineMethod (c$, "replaceFirstRegion", \r
-function (s, r, start, end) {\r
-this.first = true;\r
-this.rh.me = r;\r
-this.rh.prev = null;\r
-return this.dorep (s, start, end);\r
-}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N");\r
-Clazz.defineMethod (c$, "replaceFirst", \r
-function (s) {\r
-return this.replaceFirstRegion (s, 0, s.length ());\r
-}, "com.stevesoft.pat.StringLike");\r
-Clazz.defineMethod (c$, "replaceFirstFrom", \r
-function (s, start) {\r
-return this.replaceFirstRegion (s, start, s.length ());\r
-}, "com.stevesoft.pat.StringLike,~N");\r
-Clazz.defineMethod (c$, "replaceFirstRegion", \r
-function (s, start, end) {\r
-this.first = true;\r
-return this.dorep (s, start, end);\r
-}, "com.stevesoft.pat.StringLike,~N,~N");\r
-Clazz.defineMethod (c$, "replaceAllRegion", \r
-function (s, r, start, end) {\r
-return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end);\r
-}, "~S,com.stevesoft.pat.Regex,~N,~N");\r
-Clazz.defineMethod (c$, "replaceAllRegion", \r
-function (s, r, start, end) {\r
-this.first = false;\r
-this.rh.me = r;\r
-this.rh.prev = null;\r
-return this.dorep (s, start, end);\r
-}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N");\r
-Clazz.defineMethod (c$, "replaceAll", \r
-function (s) {\r
-return this.replaceAllRegion (s, 0, s.length ());\r
-}, "com.stevesoft.pat.StringLike");\r
-Clazz.defineMethod (c$, "replaceAllFrom", \r
-function (s, start) {\r
-return this.replaceAllRegion (s, start, s.length ());\r
-}, "com.stevesoft.pat.StringLike,~N");\r
-Clazz.defineMethod (c$, "replaceAllRegion", \r
-function (s, start, end) {\r
-this.first = false;\r
-return this.dorep (s, start, end);\r
-}, "com.stevesoft.pat.StringLike,~N,~N");\r
-Clazz.defineMethod (c$, "replaceAll", \r
-function (s) {\r
-return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), 0, s.length).toString ();\r
-}, "~S");\r
-Clazz.defineMethod (c$, "replaceAllFrom", \r
-function (s, start) {\r
-return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), start, s.length).toString ();\r
-}, "~S,~N");\r
-Clazz.defineMethod (c$, "replaceAllRegion", \r
-function (s, start, end) {\r
-this.first = false;\r
-return this.dorep ( new com.stevesoft.pat.wrap.StringWrap (s), start, end).toString ();\r
-}, "~S,~N,~N");\r
-Clazz.defineMethod (c$, "isSpecial", \r
-function (x) {\r
-while (x != null) {\r
-if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule) || (Clazz.instanceOf (x, com.stevesoft.pat.RuleHolder) && Clazz.instanceOf ((x).held, com.stevesoft.pat.SpecialRule))) {\r
-return true;\r
-}x = x.next;\r
-}\r
-return false;\r
-}, "com.stevesoft.pat.ReplaceRule");\r
-Clazz.defineMethod (c$, "apply1", \r
-function (rr) {\r
-rr.charsMatched_++;\r
-this.apply (rr, null);\r
-rr.charsMatched_--;\r
-}, "com.stevesoft.pat.RegRes");\r
-Clazz.defineMethod (c$, "dorep", \r
-function (s, start, end) {\r
-var ret = s;\r
-this.want_more_text = false;\r
-this.$lastMatchedTo = 0;\r
-if (this.rh.me == null) {\r
-throw  new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.replace_null_regex_pointer"));\r
-}if (this.rh.me._searchLike (s, start, end)) {\r
-var rmn = this.rh.me.matchedTo ();\r
-if (this.rh.me.charsMatched () == 0 && !this.isSpecial (this.rh.me.getReplaceRule ())) {\r
-this.apply1 (this.rh.me);\r
-rmn++;\r
-}this.apply (this.rh.me);\r
-if (!this.first) {\r
-for (var i = rmn; !this.want_more_text && this.rh.me._searchLike (s, i, end); i = rmn) {\r
-rmn = this.rh.me.matchedTo ();\r
-if (this.rh.me.charsMatched () == 0) {\r
-if (!this.isSpecial (this.rh.me.getReplaceRule ())) {\r
-this.apply1 (this.rh.me);\r
-}rmn++;\r
-}this.apply (this.rh.me);\r
-}\r
-}ret = this.finish ();\r
-ret = ret == null ? s : ret;\r
-}return ret;\r
-}, "com.stevesoft.pat.StringLike,~N,~N");\r
-Clazz.defineMethod (c$, "apply", \r
-function (r, rp) {\r
-if (rp == null || (rp.next == null && Clazz.instanceOf (rp, com.stevesoft.pat.AmpersandRule))) {\r
-return;\r
-}if (r.didMatch ()) {\r
-if (this.src == null) {\r
-this.src = r.getStringLike ();\r
-}if (this.sb == null) {\r
-this.sb =  new com.stevesoft.pat.StringBufferLike (this.src.newStringBufferLike ());\r
-}var rmf = r.matchedFrom ();\r
-for (var ii = this.pos; ii < rmf; ii++) {\r
-this.sb.appendC (this.src.charAt (ii));\r
-}\r
-for (var x = rp; x != null; x = x.next) {\r
-x.apply (this.sb, r);\r
-if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule)) {\r
-if (Clazz.instanceOf (x, com.stevesoft.pat.WantMoreTextReplaceRule) && this.want_more_text_enable) {\r
-this.want_more_text = true;\r
-} else if (Clazz.instanceOf (x, com.stevesoft.pat.PushRule)) {\r
-var rh2 =  new com.stevesoft.pat.RegHolder ();\r
-rh2.me = (x).NewRule;\r
-rh2.prev = this.rh;\r
-this.rh = rh2;\r
-} else if (Clazz.instanceOf (x, com.stevesoft.pat.PopRule)) {\r
-if (this.rh.prev != null) {\r
-this.rh = this.rh.prev;\r
-}} else if (Clazz.instanceOf (x, com.stevesoft.pat.ChangeRule)) {\r
-this.rh.me = (x).NewRule;\r
-}}}\r
-if (!this.want_more_text) {\r
-this.pos = r.matchedTo ();\r
-}}}, "com.stevesoft.pat.RegRes,com.stevesoft.pat.ReplaceRule");\r
-Clazz.defineMethod (c$, "WantMoreText", \r
-function () {\r
-return this.want_more_text;\r
-});\r
-Clazz.defineMethod (c$, "apply", \r
-function (r) {\r
-this.apply (r, r.getReplaceRule ());\r
-}, "com.stevesoft.pat.Regex");\r
-Clazz.defineMethod (c$, "finish", \r
-function () {\r
-if (this.src == null) {\r
-return null;\r
-}var s_end = this.src.length ();\r
-for (var ii = this.pos; ii < s_end; ii++) {\r
-this.sb.appendC (this.src.charAt (ii));\r
-}\r
-this.src = null;\r
-this.$lastMatchedTo = this.pos;\r
-this.pos = 0;\r
-var retstr = this.sb.toStringLike ();\r
-this.sb = null;\r
-return retstr;\r
-});\r
-Clazz.overrideMethod (c$, "clone", \r
-function () {\r
-var r =  new com.stevesoft.pat.Replacer ();\r
-r.first = this.first;\r
-r.src = this.src;\r
-r.sb = this.sb;\r
-r.pos = this.pos;\r
-r.$lastMatchedTo = this.$lastMatchedTo;\r
-r.want_more_text = this.want_more_text;\r
-r.want_more_text_enable = this.want_more_text_enable;\r
-r.rh.me = this.rh.me;\r
-r.rh.prev = this.rh.prev;\r
-return r;\r
-});\r
-Clazz.defineMethod (c$, "lastMatchedTo", \r
-function () {\r
-return this.$lastMatchedTo;\r
-});\r
-Clazz.defineMethod (c$, "getRegex", \r
-function () {\r
-return this.rh.me;\r
-});\r
-Clazz.defineMethod (c$, "setSource", \r
-function (sl) {\r
-this.src = sl;\r
-}, "com.stevesoft.pat.StringLike");\r
-Clazz.defineMethod (c$, "setBuffer", \r
-function (sbl) {\r
-this.sb = sbl;\r
-}, "com.stevesoft.pat.StringBufferLike");\r
-Clazz.defineMethod (c$, "setPos", \r
-function (pos) {\r
-this.pos = pos;\r
-}, "~N");\r
-});\r
+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");
+});