JAL-1807 still testing
[jalviewjs.git] / bin / com / stevesoft / pat / FastBracket.js
index d26c009..0e7d38a 100644 (file)
-Clazz.declarePackage ("com.stevesoft.pat");
-Clazz.load (["com.stevesoft.pat.Bracket"], "com.stevesoft.pat.FastBracket", ["com.stevesoft.pat.Range", "$.oneChar", "java.util.BitSet", "$.Vector"], function () {
-c$ = Clazz.decorateAsClass (function () {
-this.$min = 0;
-this.$max = 0;
-this.bs = null;
-Clazz.instantialize (this, arguments);
-}, com.stevesoft.pat, "FastBracket", com.stevesoft.pat.Bracket);
-c$.process = Clazz.defineMethod (c$, "process", 
-function (b, ignc) {
-var v = b.v;
-b.pv = null;
-try {
-var nv = v;
-if (ignc) {
-nv =  new java.util.Vector ();
-for (var i = 0; i < v.size (); i++) {
-var p = v.elementAt (i);
-nv.addElement (p);
-if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) {
-var oc = p;
-nv.addElement ( new com.stevesoft.pat.oneChar (oc.altc));
-} else if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
-var ra = p;
-nv.addElement ( new com.stevesoft.pat.Range (ra.altlo, ra.althi));
-}}
-}v = nv;
-for (var i = 0; i < v.size () - 1; i++) {
-for (var j = 0; j < v.size () - 1; j++) {
-var c1 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j));
-var c2 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j + 1));
-if (c2 < c1) {
-var o = v.elementAt (j);
-v.setElementAt (v.elementAt (j + 1), j);
-v.setElementAt (o, j + 1);
-}}
-}
-nv =  new java.util.Vector ();
-var p = v.elementAt (0);
-nv.addElement (p);
-for (var i = 1; i < v.size (); i++) {
-if ((com.stevesoft.pat.FastBracket.geth (p)).charCodeAt (0) + 1 >= (com.stevesoft.pat.FastBracket.getl (v.elementAt (i))).charCodeAt (0)) {
-var p2 = v.elementAt (i);
-var lo = com.stevesoft.pat.FastBracket.min (com.stevesoft.pat.FastBracket.getl (p), com.stevesoft.pat.FastBracket.getl (p2));
-var hi = com.stevesoft.pat.FastBracket.max (com.stevesoft.pat.FastBracket.geth (p), com.stevesoft.pat.FastBracket.geth (p2));
-nv.setElementAt (p = com.stevesoft.pat.FastBracket.mkelem (lo, hi), nv.size () - 1);
-} else {
-p = v.elementAt (i);
-nv.addElement (p);
-}}
-b.v = v = nv;
-} catch (e) {
-if (Clazz.exceptionOf (e, com.stevesoft.pat.RegSyntax)) {
-e.printStackTrace ();
-} else {
-throw e;
-}
-}
-var negv = com.stevesoft.pat.FastBracket.neg (v);
-if (v.size () == 1) {
-return b;
-}if (negv.size () == 1) {
-b.v = negv;
-b.neg = !b.neg;
-return b;
-}var fb = com.stevesoft.pat.FastBracket.newbrack (v, b.neg);
-if (fb == null) {
-fb = com.stevesoft.pat.FastBracket.newbrack (negv, !b.neg);
-}if (fb != null) {
-fb.parent = b.parent;
-fb.next = b.next;
-return fb;
-}return b;
-}, "com.stevesoft.pat.Bracket,~B");
-c$.newbrack = Clazz.defineMethod (c$, "newbrack", 
-function (v, neg) {
-var fb =  new com.stevesoft.pat.FastBracket (neg);
-fb.v = v;
-if (v.size () == 0) {
-return null;
-}fb.$min = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0);
-fb.$max = (com.stevesoft.pat.FastBracket.geth (v.elementAt (v.size () - 1))).charCodeAt (0);
-if (fb.$max - fb.$min <= 256) {
-fb.bs =  new java.util.BitSet (fb.$max - fb.$min + 1);
-for (var i = 0; i < v.size (); i++) {
-var o = v.elementAt (i);
-var min0 = (com.stevesoft.pat.FastBracket.getl (o)).charCodeAt (0) - fb.$min;
-var max0 = (com.stevesoft.pat.FastBracket.geth (o)).charCodeAt (0) - fb.$min;
-for (var j = min0; j <= max0; j++) {
-fb.bs.set (j);
-}
-}
-return fb;
-}return null;
-}, "java.util.Vector,~B");
-c$.neg = Clazz.defineMethod (c$, "neg", 
-function (v) {
-try {
-var nv =  new java.util.Vector ();
-if (v.size () == 0) {
-nv.addElement ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (65535)));
-return nv;
-}var p0 = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0);
-if (p0 != 0) {
-nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (0), String.fromCharCode (p0 - 1)));
-}for (var i = 0; i < v.size () - 1; i++) {
-var hi = (com.stevesoft.pat.FastBracket.getl (v.elementAt (i + 1))).charCodeAt (0) - 1;
-var lo = (com.stevesoft.pat.FastBracket.geth (v.elementAt (i))).charCodeAt (0) + 1;
-nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (lo), String.fromCharCode (hi)));
-}
-var pN = (com.stevesoft.pat.FastBracket.geth (v.lastElement ())).charCodeAt (0);
-if (pN != 65535) {
-nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (pN + 1), String.fromCharCode (65535)));
-}return nv;
-} catch (rs) {
-if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) {
-return null;
-} else {
-throw rs;
-}
-}
-}, "java.util.Vector");
-c$.mkelem = Clazz.defineMethod (c$, "mkelem", 
-function (lo, hi) {
-return lo == hi ? ( new com.stevesoft.pat.oneChar (lo)) : ( new com.stevesoft.pat.Range (lo, hi));
-}, "~S,~S");
-c$.min = Clazz.defineMethod (c$, "min", 
-function (a, b) {
-return a < b ? a : b;
-}, "~S,~S");
-c$.max = Clazz.defineMethod (c$, "max", 
-function (a, b) {
-return a > b ? a : b;
-}, "~S,~S");
-c$.getl = Clazz.defineMethod (c$, "getl", 
-function (o) {
-var p = o;
-if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
-return (p).lo;
-}return (p).c;
-}, "~O");
-c$.geth = Clazz.defineMethod (c$, "geth", 
-function (o) {
-var p = o;
-if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
-return (p).hi;
-}return (p).c;
-}, "~O");
-Clazz.overrideMethod (c$, "matchInternal", 
-function (pos, pt) {
-if (pos >= pt.src.length () || this.Masked (pos, pt)) {
-return -1;
-}var c = pt.src.charAt (pos);
-return ( new Boolean (this.neg ^ (c.charCodeAt (0) >= this.$min && c.charCodeAt (0) <= this.$max && this.bs.get (c.charCodeAt (0) - this.$min))).valueOf ()) ? this.nextMatch (pos + 1, pt) : -1;
-}, "~N,com.stevesoft.pat.Pthings");
-});
+Clazz.declarePackage ("com.stevesoft.pat");\r
+Clazz.load (["com.stevesoft.pat.Bracket"], "com.stevesoft.pat.FastBracket", ["com.stevesoft.pat.Range", "$.oneChar", "java.util.BitSet", "$.Vector"], function () {\r
+c$ = Clazz.decorateAsClass (function () {\r
+this.$min = 0;\r
+this.$max = 0;\r
+this.bs = null;\r
+Clazz.instantialize (this, arguments);\r
+}, com.stevesoft.pat, "FastBracket", com.stevesoft.pat.Bracket);\r
+c$.process = Clazz.defineMethod (c$, "process", \r
+function (b, ignc) {\r
+var v = b.v;\r
+b.pv = null;\r
+try {\r
+var nv = v;\r
+if (ignc) {\r
+nv =  new java.util.Vector ();\r
+for (var i = 0; i < v.size (); i++) {\r
+var p = v.elementAt (i);\r
+nv.addElement (p);\r
+if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) {\r
+var oc = p;\r
+nv.addElement ( new com.stevesoft.pat.oneChar (oc.altc));\r
+} else if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {\r
+var ra = p;\r
+nv.addElement ( new com.stevesoft.pat.Range (ra.altlo, ra.althi));\r
+}}\r
+}v = nv;\r
+for (var i = 0; i < v.size () - 1; i++) {\r
+for (var j = 0; j < v.size () - 1; j++) {\r
+var c1 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j));\r
+var c2 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j + 1));\r
+if (c2 < c1) {\r
+var o = v.elementAt (j);\r
+v.setElementAt (v.elementAt (j + 1), j);\r
+v.setElementAt (o, j + 1);\r
+}}\r
+}\r
+nv =  new java.util.Vector ();\r
+var p = v.elementAt (0);\r
+nv.addElement (p);\r
+for (var i = 1; i < v.size (); i++) {\r
+if ((com.stevesoft.pat.FastBracket.geth (p)).charCodeAt (0) + 1 >= (com.stevesoft.pat.FastBracket.getl (v.elementAt (i))).charCodeAt (0)) {\r
+var p2 = v.elementAt (i);\r
+var lo = com.stevesoft.pat.FastBracket.min (com.stevesoft.pat.FastBracket.getl (p), com.stevesoft.pat.FastBracket.getl (p2));\r
+var hi = com.stevesoft.pat.FastBracket.max (com.stevesoft.pat.FastBracket.geth (p), com.stevesoft.pat.FastBracket.geth (p2));\r
+nv.setElementAt (p = com.stevesoft.pat.FastBracket.mkelem (lo, hi), nv.size () - 1);\r
+} else {\r
+p = v.elementAt (i);\r
+nv.addElement (p);\r
+}}\r
+b.v = v = nv;\r
+} catch (e) {\r
+if (Clazz.exceptionOf (e, com.stevesoft.pat.RegSyntax)) {\r
+e.printStackTrace ();\r
+} else {\r
+throw e;\r
+}\r
+}\r
+var negv = com.stevesoft.pat.FastBracket.neg (v);\r
+if (v.size () == 1) {\r
+return b;\r
+}if (negv.size () == 1) {\r
+b.v = negv;\r
+b.neg = !b.neg;\r
+return b;\r
+}var fb = com.stevesoft.pat.FastBracket.newbrack (v, b.neg);\r
+if (fb == null) {\r
+fb = com.stevesoft.pat.FastBracket.newbrack (negv, !b.neg);\r
+}if (fb != null) {\r
+fb.parent = b.parent;\r
+fb.next = b.next;\r
+return fb;\r
+}return b;\r
+}, "com.stevesoft.pat.Bracket,~B");\r
+c$.newbrack = Clazz.defineMethod (c$, "newbrack", \r
+function (v, neg) {\r
+var fb =  new com.stevesoft.pat.FastBracket (neg);\r
+fb.v = v;\r
+if (v.size () == 0) {\r
+return null;\r
+}fb.$min = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0);\r
+fb.$max = (com.stevesoft.pat.FastBracket.geth (v.elementAt (v.size () - 1))).charCodeAt (0);\r
+if (fb.$max - fb.$min <= 256) {\r
+fb.bs =  new java.util.BitSet (fb.$max - fb.$min + 1);\r
+for (var i = 0; i < v.size (); i++) {\r
+var o = v.elementAt (i);\r
+var min0 = (com.stevesoft.pat.FastBracket.getl (o)).charCodeAt (0) - fb.$min;\r
+var max0 = (com.stevesoft.pat.FastBracket.geth (o)).charCodeAt (0) - fb.$min;\r
+for (var j = min0; j <= max0; j++) {\r
+fb.bs.set (j);\r
+}\r
+}\r
+return fb;\r
+}return null;\r
+}, "java.util.Vector,~B");\r
+c$.neg = Clazz.defineMethod (c$, "neg", \r
+function (v) {\r
+try {\r
+var nv =  new java.util.Vector ();\r
+if (v.size () == 0) {\r
+nv.addElement ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (65535)));\r
+return nv;\r
+}var p0 = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0);\r
+if (p0 != 0) {\r
+nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (0), String.fromCharCode (p0 - 1)));\r
+}for (var i = 0; i < v.size () - 1; i++) {\r
+var hi = (com.stevesoft.pat.FastBracket.getl (v.elementAt (i + 1))).charCodeAt (0) - 1;\r
+var lo = (com.stevesoft.pat.FastBracket.geth (v.elementAt (i))).charCodeAt (0) + 1;\r
+nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (lo), String.fromCharCode (hi)));\r
+}\r
+var pN = (com.stevesoft.pat.FastBracket.geth (v.lastElement ())).charCodeAt (0);\r
+if (pN != 65535) {\r
+nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (pN + 1), String.fromCharCode (65535)));\r
+}return nv;\r
+} catch (rs) {\r
+if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) {\r
+return null;\r
+} else {\r
+throw rs;\r
+}\r
+}\r
+}, "java.util.Vector");\r
+c$.mkelem = Clazz.defineMethod (c$, "mkelem", \r
+function (lo, hi) {\r
+return lo == hi ? ( new com.stevesoft.pat.oneChar (lo)) : ( new com.stevesoft.pat.Range (lo, hi));\r
+}, "~S,~S");\r
+c$.min = Clazz.defineMethod (c$, "min", \r
+function (a, b) {\r
+return a < b ? a : b;\r
+}, "~S,~S");\r
+c$.max = Clazz.defineMethod (c$, "max", \r
+function (a, b) {\r
+return a > b ? a : b;\r
+}, "~S,~S");\r
+c$.getl = Clazz.defineMethod (c$, "getl", \r
+function (o) {\r
+var p = o;\r
+if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {\r
+return (p).lo;\r
+}return (p).c;\r
+}, "~O");\r
+c$.geth = Clazz.defineMethod (c$, "geth", \r
+function (o) {\r
+var p = o;\r
+if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {\r
+return (p).hi;\r
+}return (p).c;\r
+}, "~O");\r
+Clazz.overrideMethod (c$, "matchInternal", \r
+function (pos, pt) {\r
+if (pos >= pt.src.length () || this.Masked (pos, pt)) {\r
+return -1;\r
+}var c = pt.src.charAt (pos);\r
+return ( new Boolean (this.neg ^ (c.charCodeAt (0) >= this.$min && c.charCodeAt (0) <= this.$max && this.bs.get (c.charCodeAt (0) - this.$min))).valueOf ()) ? this.nextMatch (pos + 1, pt) : -1;\r
+}, "~N,com.stevesoft.pat.Pthings");\r
+});\r