1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (["com.stevesoft.pat.Bracket"], "com.stevesoft.pat.FastBracket", ["com.stevesoft.pat.Range", "$.oneChar", "java.util.BitSet", "$.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
7 Clazz.instantialize (this, arguments);
8 }, com.stevesoft.pat, "FastBracket", com.stevesoft.pat.Bracket);
9 c$.process = Clazz.defineMethod (c$, "process",
16 nv = new java.util.Vector ();
17 for (var i = 0; i < v.size (); i++) {
18 var p = v.elementAt (i);
20 if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) {
22 nv.addElement ( new com.stevesoft.pat.oneChar (oc.altc));
23 } else if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
25 nv.addElement ( new com.stevesoft.pat.Range (ra.altlo, ra.althi));
28 for (var i = 0; i < v.size () - 1; i++) {
29 for (var j = 0; j < v.size () - 1; j++) {
30 var c1 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j));
31 var c2 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j + 1));
33 var o = v.elementAt (j);
34 v.setElementAt (v.elementAt (j + 1), j);
35 v.setElementAt (o, j + 1);
38 nv = new java.util.Vector ();
39 var p = v.elementAt (0);
41 for (var i = 1; i < v.size (); i++) {
42 if ((com.stevesoft.pat.FastBracket.geth (p)).charCodeAt (0) + 1 >= (com.stevesoft.pat.FastBracket.getl (v.elementAt (i))).charCodeAt (0)) {
43 var p2 = v.elementAt (i);
44 var lo = com.stevesoft.pat.FastBracket.min (com.stevesoft.pat.FastBracket.getl (p), com.stevesoft.pat.FastBracket.getl (p2));
45 var hi = com.stevesoft.pat.FastBracket.max (com.stevesoft.pat.FastBracket.geth (p), com.stevesoft.pat.FastBracket.geth (p2));
46 nv.setElementAt (p = com.stevesoft.pat.FastBracket.mkelem (lo, hi), nv.size () - 1);
53 if (Clazz.exceptionOf (e, com.stevesoft.pat.RegSyntax)) {
59 var negv = com.stevesoft.pat.FastBracket.neg (v);
62 }if (negv.size () == 1) {
66 }var fb = com.stevesoft.pat.FastBracket.newbrack (v, b.neg);
68 fb = com.stevesoft.pat.FastBracket.newbrack (negv, !b.neg);
74 }, "com.stevesoft.pat.Bracket,~B");
75 c$.newbrack = Clazz.defineMethod (c$, "newbrack",
77 var fb = new com.stevesoft.pat.FastBracket (neg);
81 }fb.$min = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0);
82 fb.$max = (com.stevesoft.pat.FastBracket.geth (v.elementAt (v.size () - 1))).charCodeAt (0);
83 if (fb.$max - fb.$min <= 256) {
84 fb.bs = new java.util.BitSet (fb.$max - fb.$min + 1);
85 for (var i = 0; i < v.size (); i++) {
86 var o = v.elementAt (i);
87 var min0 = (com.stevesoft.pat.FastBracket.getl (o)).charCodeAt (0) - fb.$min;
88 var max0 = (com.stevesoft.pat.FastBracket.geth (o)).charCodeAt (0) - fb.$min;
89 for (var j = min0; j <= max0; j++) {
95 }, "java.util.Vector,~B");
96 c$.neg = Clazz.defineMethod (c$, "neg",
99 var nv = new java.util.Vector ();
100 if (v.size () == 0) {
101 nv.addElement ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (65535)));
103 }var p0 = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0);
105 nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (0), String.fromCharCode (p0 - 1)));
106 }for (var i = 0; i < v.size () - 1; i++) {
107 var hi = (com.stevesoft.pat.FastBracket.getl (v.elementAt (i + 1))).charCodeAt (0) - 1;
108 var lo = (com.stevesoft.pat.FastBracket.geth (v.elementAt (i))).charCodeAt (0) + 1;
109 nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (lo), String.fromCharCode (hi)));
111 var pN = (com.stevesoft.pat.FastBracket.geth (v.lastElement ())).charCodeAt (0);
113 nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (pN + 1), String.fromCharCode (65535)));
116 if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) {
122 }, "java.util.Vector");
123 c$.mkelem = Clazz.defineMethod (c$, "mkelem",
125 return lo == hi ? ( new com.stevesoft.pat.oneChar (lo)) : ( new com.stevesoft.pat.Range (lo, hi));
127 c$.min = Clazz.defineMethod (c$, "min",
129 return a < b ? a : b;
131 c$.max = Clazz.defineMethod (c$, "max",
133 return a > b ? a : b;
135 c$.getl = Clazz.defineMethod (c$, "getl",
138 if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
142 c$.geth = Clazz.defineMethod (c$, "geth",
145 if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
149 Clazz.overrideMethod (c$, "matchInternal",
151 if (pos >= pt.src.length () || this.Masked (pos, pt)) {
153 }var c = pt.src.charAt (pos);
154 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;
155 }, "~N,com.stevesoft.pat.Pthings");