JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / com / stevesoft / pat / Range.js
1 Clazz.declarePackage ("com.stevesoft.pat");\r
2 Clazz.load (["com.stevesoft.pat.Pattern", "$.RegSyntax"], ["com.stevesoft.pat.BadRangeArgs", "$.Range"], ["com.stevesoft.pat.RegSyntaxError", "$.oneChar", "$.patInt"], function () {\r
3 c$ = Clazz.declareType (com.stevesoft.pat, "BadRangeArgs", com.stevesoft.pat.RegSyntax);\r
4 c$ = Clazz.decorateAsClass (function () {\r
5 this.lo = '\0';\r
6 this.hi = '\0';\r
7 this.altlo = '\0';\r
8 this.althi = '\0';\r
9 this.printBrackets = false;\r
10 Clazz.instantialize (this, arguments);\r
11 }, com.stevesoft.pat, "Range", com.stevesoft.pat.Pattern);\r
12 Clazz.overrideMethod (c$, "toString", \r
13 function () {\r
14 var s = com.stevesoft.pat.Pattern.protect ("" + this.lo, "[]{}(),$,-\"^.", '\\') + "-" + com.stevesoft.pat.Pattern.protect ("" + this.hi, "[]{}(),$,-\"^.", '\\');\r
15 if (!this.printBrackets) {\r
16 return s;\r
17 }return "[" + s + "]";\r
18 });\r
19 Clazz.makeConstructor (c$, \r
20 function (loi, hii) {\r
21 Clazz.superConstructor (this, com.stevesoft.pat.Range, []);\r
22 this.lo = loi;\r
23 this.hi = hii;\r
24 var o = null;\r
25 if (this.lo >= this.hi) {\r
26 com.stevesoft.pat.RegSyntaxError.endItAll ("Badly formed []'s : " + this.lo + " >= " + this.hi);\r
27 }o =  new com.stevesoft.pat.oneChar (this.lo);\r
28 this.altlo = o.altc;\r
29 o =  new com.stevesoft.pat.oneChar (this.hi);\r
30 this.althi = o.altc;\r
31 }, "~S,~S");\r
32 Clazz.overrideMethod (c$, "matchInternal", \r
33 function (pos, pt) {\r
34 if (pos >= pt.src.length ()) {\r
35 return -1;\r
36 }if (this.Masked (pos, pt)) {\r
37 return -1;\r
38 }var c = pt.src.charAt (pos);\r
39 if (this.lo <= c && c <= this.hi || (pt.ignoreCase && (this.altlo <= c && c <= this.althi))) {\r
40 return this.nextMatch (pos + 1, pt);\r
41 }return -1;\r
42 }, "~N,com.stevesoft.pat.Pthings");\r
43 Clazz.overrideMethod (c$, "minChars", \r
44 function () {\r
45 return  new com.stevesoft.pat.patInt (1);\r
46 });\r
47 Clazz.overrideMethod (c$, "maxChars", \r
48 function () {\r
49 return  new com.stevesoft.pat.patInt (1);\r
50 });\r
51 Clazz.overrideMethod (c$, "clone1", \r
52 function (h) {\r
53 try {\r
54 var r =  new com.stevesoft.pat.Range (this.lo, this.hi);\r
55 r.printBrackets = this.printBrackets;\r
56 return r;\r
57 } catch (rs) {\r
58 if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) {\r
59 return null;\r
60 } else {\r
61 throw rs;\r
62 }\r
63 }\r
64 }, "java.util.Hashtable");\r
65 });\r