Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / com / stevesoft / pat / Bracket.js
1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (["com.stevesoft.pat.Or"], "com.stevesoft.pat.Bracket", ["com.stevesoft.pat.patInt", "java.util.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.neg = false;
5 Clazz.instantialize (this, arguments);
6 }, com.stevesoft.pat, "Bracket", com.stevesoft.pat.Or);
7 Clazz.makeConstructor (c$, 
8 function (n) {
9 Clazz.superConstructor (this, com.stevesoft.pat.Bracket, []);
10 this.neg = n;
11 }, "~B");
12 Clazz.overrideMethod (c$, "leftForm", 
13 function () {
14 if (this.neg) {
15 return "[^";
16 } else {
17 return "[";
18 }});
19 Clazz.overrideMethod (c$, "rightForm", 
20 function () {
21 return "]";
22 });
23 Clazz.overrideMethod (c$, "sepForm", 
24 function () {
25 return "";
26 });
27 Clazz.defineMethod (c$, "matchInternal", 
28 function (pos, pt) {
29 if (pos >= pt.src.length ()) {
30 return -1;
31 }var r = Clazz.superCall (this, com.stevesoft.pat.Bracket, "matchInternal", [pos, pt]);
32 if ((this.neg && r < 0) || (!this.neg && r >= 0)) {
33 return this.nextMatch (pos + 1, pt);
34 }return -1;
35 }, "~N,com.stevesoft.pat.Pthings");
36 Clazz.overrideMethod (c$, "minChars", 
37 function () {
38 return  new com.stevesoft.pat.patInt (1);
39 });
40 Clazz.overrideMethod (c$, "maxChars", 
41 function () {
42 return  new com.stevesoft.pat.patInt (1);
43 });
44 Clazz.overrideMethod (c$, "addOr", 
45 function (p) {
46 this.pv = null;
47 this.v.addElement (p);
48 p.setParent (null);
49 return this;
50 }, "com.stevesoft.pat.Pattern");
51 Clazz.overrideMethod (c$, "clone1", 
52 function (h) {
53 var b =  new com.stevesoft.pat.Bracket (this.neg);
54 b.v =  new java.util.Vector ();
55 for (var i = 0; i < this.v.size (); i++) {
56 b.v.addElement ((this.v.elementAt (i)).clone1 (h));
57 }
58 return b;
59 }, "java.util.Hashtable");
60 });