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