JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / com / stevesoft / pat / Pattern.js
1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (null, "com.stevesoft.pat.Pattern", ["com.stevesoft.pat.MessageManager", "$.patInf", "$.patInt", "java.lang.Error", "$.StringBuffer"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.next = null;
5 this.parent = null;
6 this.mfrom = 0;
7 Clazz.instantialize (this, arguments);
8 }, com.stevesoft.pat, "Pattern");
9 Clazz.defineMethod (c$, "getNext", 
10 function () {
11 return this.next != null ? this.next : (this.parent == null ? null : this.parent.getNext ());
12 });
13 Clazz.defineMethod (c$, "setParent", 
14 function (p) {
15 if (this.next != null) {
16 this.next.setParent (p);
17 } else {
18 this.parent = p;
19 }}, "com.stevesoft.pat.Pattern");
20 Clazz.defineMethod (c$, "nextMatch", 
21 function (i, pt) {
22 var p = this.getNext ();
23 return p == null ? i : p.matchInternal (i, pt);
24 }, "~N,com.stevesoft.pat.Pthings");
25 Clazz.defineMethod (c$, "nextString", 
26 function () {
27 if (this.next == null) {
28 return "";
29 }return this.next.toString ();
30 });
31 c$.inString = Clazz.defineMethod (c$, "inString", 
32 function (c, s) {
33 var i;
34 for (i = 0; i < s.length; i++) {
35 if (s.charAt (i) == c) {
36 return true;
37 }}
38 return false;
39 }, "~S,~S");
40 c$.protect = Clazz.defineMethod (c$, "protect", 
41 function (s, PROTECT_THESE, esc) {
42 var i;
43 var sb =  new StringBuffer ();
44 var p = PROTECT_THESE + esc;
45 for (i = 0; i < s.length; i++) {
46 var c = s.charAt (i);
47 if (com.stevesoft.pat.Pattern.inString (c, p)) {
48 sb.append (esc);
49 }sb.append (c);
50 }
51 return sb.toString ();
52 }, "~S,~S,~S");
53 Clazz.defineMethod (c$, "match", 
54 function (s, pt) {
55 return this.matchAt (s, 0, pt);
56 }, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Pthings");
57 Clazz.defineMethod (c$, "matchAt", 
58 function (s, i, pt) {
59 pt.src = s;
60 var r = this.matchInternal (i, pt);
61 if (r < 0) {
62 return -1;
63 }this.mfrom = r < i ? r + 1 : i;
64 return r < i ? i - r - 1 : r - i;
65 }, "com.stevesoft.pat.StringLike,~N,com.stevesoft.pat.Pthings");
66 Clazz.defineMethod (c$, "Masked", 
67 function (i, pt) {
68 return pt.cbits == null ? false : pt.cbits.get (i);
69 }, "~N,com.stevesoft.pat.Pthings");
70 Clazz.defineMethod (c$, "add", 
71 function (p) {
72 if (this.next == null) {
73 if (p == null) {
74 return this;
75 }this.next = p;
76 p.parent = this.parent;
77 this.parent = null;
78 } else {
79 this.next.add (p);
80 }return this;
81 }, "com.stevesoft.pat.Pattern");
82 Clazz.defineMethod (c$, "minChars", 
83 function () {
84 return  new com.stevesoft.pat.patInt (0);
85 });
86 Clazz.defineMethod (c$, "maxChars", 
87 function () {
88 return  new com.stevesoft.pat.patInf ();
89 });
90 Clazz.defineMethod (c$, "countMinChars", 
91 function () {
92 var p = this;
93 var sum =  new com.stevesoft.pat.patInt (0);
94 while (p != null) {
95 sum.pluseq (p.minChars ());
96 p = p.next;
97 }
98 return sum;
99 });
100 Clazz.defineMethod (c$, "countMaxChars", 
101 function () {
102 var p = this;
103 var sum =  new com.stevesoft.pat.patInt (0);
104 while (p != null) {
105 sum.pluseq (p.maxChars ());
106 p = p.next;
107 }
108 return sum;
109 });
110 Clazz.defineMethod (c$, "testMatch", 
111 function (p, pos, pt) {
112 var tab = null;
113 if (pt.marks != null) {
114 try {
115 tab =  Clazz.newIntArray (pt.marks.length, 0);
116 for (var i = 0; i < tab.length; i++) {
117 tab[i] = pt.marks[i];
118 }
119 } catch (t) {
120 }
121 }var ret = p.matchInternal (pos, pt);
122 if (ret < 0) {
123 pt.marks = tab;
124 }return ret;
125 }, "com.stevesoft.pat.Pattern,~N,com.stevesoft.pat.Pthings");
126 Clazz.defineMethod (c$, "clone1", 
127 function (h) {
128 throw  new Error (com.stevesoft.pat.MessageManager.formatMessage ("error.no_such_method_as_clone1_for",  Clazz.newArray (-1, [this.getClass ().getName ()])));
129 }, "java.util.Hashtable");
130 Clazz.defineMethod (c$, "clone", 
131 function (h) {
132 var p = h.get (this);
133 if (p != null) {
134 return p;
135 }p = this.clone1 (h);
136 if (p == null) {
137 throw  new Error (com.stevesoft.pat.MessageManager.getString ("error.null_from_clone1"));
138 }h.put (this, p);
139 h.put (p, p);
140 if (this.next != null) {
141 p.next = this.next.clone (h);
142 }if (this.parent != null) {
143 p.parent = this.parent.clone (h);
144 }return p;
145 }, "java.util.Hashtable");
146 Clazz.overrideMethod (c$, "equals", 
147 function (o) {
148 return o === this;
149 }, "~O");
150 Clazz.defineStatics (c$,
151 "ESC", '\\',
152 "PROTECT_THESE", "[]{}(),$,-\"^.");
153 });