JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / com / stevesoft / pat / Or.js
1 Clazz.declarePackage ("com.stevesoft.pat");\r
2 Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Or", ["com.stevesoft.pat.patInt", "java.lang.StringBuffer", "java.util.Vector"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.v = null;\r
5 this.pv = null;\r
6 Clazz.instantialize (this, arguments);\r
7 }, com.stevesoft.pat, "Or", com.stevesoft.pat.Pattern);\r
8 Clazz.makeConstructor (c$, \r
9 function () {\r
10 Clazz.superConstructor (this, com.stevesoft.pat.Or, []);\r
11 this.v =  new java.util.Vector ();\r
12 });\r
13 Clazz.defineMethod (c$, "leftForm", \r
14 function () {\r
15 return "(?:";\r
16 });\r
17 Clazz.defineMethod (c$, "rightForm", \r
18 function () {\r
19 return ")";\r
20 });\r
21 Clazz.defineMethod (c$, "sepForm", \r
22 function () {\r
23 return "|";\r
24 });\r
25 Clazz.defineMethod (c$, "addOr", \r
26 function (p) {\r
27 this.pv = null;\r
28 this.v.addElement (p);\r
29 p.setParent (this);\r
30 return this;\r
31 }, "com.stevesoft.pat.Pattern");\r
32 Clazz.defineMethod (c$, "toString", \r
33 function () {\r
34 var i;\r
35 var sb =  new StringBuffer ();\r
36 sb.append (this.leftForm ());\r
37 if (this.v.size () > 0) {\r
38 sb.append ((this.v.elementAt (0)).toString ());\r
39 }for (i = 1; i < this.v.size (); i++) {\r
40 sb.append (this.sepForm ());\r
41 sb.append ((this.v.elementAt (i)).toString ());\r
42 }\r
43 sb.append (this.rightForm ());\r
44 sb.append (this.nextString ());\r
45 return sb.toString ();\r
46 });\r
47 Clazz.defineMethod (c$, "matchInternal", \r
48 function (pos, pt) {\r
49 if (this.pv == null) {\r
50 this.pv =  new Array (this.v.size ());\r
51 this.v.copyInto (this.pv);\r
52 }for (var i = 0; i < this.v.size (); i++) {\r
53 var p = this.pv[i];\r
54 var r = p.matchInternal (pos, pt);\r
55 if (r >= 0) {\r
56 return r;\r
57 }}\r
58 return -1;\r
59 }, "~N,com.stevesoft.pat.Pthings");\r
60 Clazz.overrideMethod (c$, "minChars", \r
61 function () {\r
62 if (this.v.size () == 0) {\r
63 return  new com.stevesoft.pat.patInt (0);\r
64 }var m = (this.v.elementAt (0)).countMinChars ();\r
65 for (var i = 1; i < this.v.size (); i++) {\r
66 var p = this.v.elementAt (i);\r
67 m.mineq (p.countMinChars ());\r
68 }\r
69 return m;\r
70 });\r
71 Clazz.overrideMethod (c$, "maxChars", \r
72 function () {\r
73 if (this.v.size () == 0) {\r
74 return  new com.stevesoft.pat.patInt (0);\r
75 }var m = (this.v.elementAt (0)).countMaxChars ();\r
76 for (var i = 1; i < this.v.size (); i++) {\r
77 var p = this.v.elementAt (i);\r
78 m.maxeq (p.countMaxChars ());\r
79 }\r
80 return m;\r
81 });\r
82 Clazz.overrideMethod (c$, "clone1", \r
83 function (h) {\r
84 var o =  new com.stevesoft.pat.Or ();\r
85 h.put (this, o);\r
86 h.put (o, o);\r
87 for (var i = 0; i < this.v.size (); i++) {\r
88 o.v.addElement ((this.v.elementAt (i)).clone (h));\r
89 }\r
90 return o;\r
91 }, "java.util.Hashtable");\r
92 });\r