JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / com / stevesoft / pat / RegRes.js
1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (null, "com.stevesoft.pat.RegRes", ["java.lang.StringBuffer"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.marks = null;
5 this.didMatch_ = false;
6 this.src = null;
7 this.charsMatched_ = 0;
8 this.matchFrom_ = 0;
9 this.numSubs_ = 0;
10 Clazz.instantialize (this, arguments);
11 }, com.stevesoft.pat, "RegRes");
12 Clazz.defineMethod (c$, "getString", 
13 function () {
14 return this.src.toString ();
15 });
16 Clazz.defineMethod (c$, "getStringLike", 
17 function () {
18 return this.src;
19 });
20 Clazz.overrideMethod (c$, "toString", 
21 function () {
22 var sb =  new StringBuffer ();
23 sb.append ("match=" + this.matchedFrom () + ":" + this.charsMatched ());
24 if (!this.didMatch ()) {
25 return sb.toString ();
26 }for (var i = 0; i < this.numSubs (); i++) {
27 var n = i + 1;
28 sb.append (" sub(" + n + ")=" + this.matchedFromI (n) + ":" + this.charsMatchedI (n));
29 }
30 return sb.toString ();
31 });
32 Clazz.defineMethod (c$, "copyOutOf", 
33 function (r) {
34 if (r.marks == null) {
35 this.marks = null;
36 } else {
37 try {
38 this.marks =  Clazz.newIntArray (r.marks.length, 0);
39 for (var i = 0; i < this.marks.length; i++) {
40 this.marks[i] = r.marks[i];
41 }
42 } catch (t) {
43 }
44 }this.didMatch_ = r.didMatch_;
45 this.src = r.src;
46 this.charsMatched_ = r.charsMatched_;
47 this.matchFrom_ = r.matchFrom_;
48 this.numSubs_ = r.numSubs_;
49 }, "com.stevesoft.pat.RegRes");
50 Clazz.defineMethod (c$, "equals", 
51 function (r) {
52 if (this.charsMatched_ != r.charsMatched_ || this.matchFrom_ != r.matchFrom_ || this.didMatch_ != r.didMatch_ || this.numSubs_ != r.numSubs_ || !this.src.unwrap ().equals (r.src.unwrap ())) {
53 return false;
54 }if (this.marks == null && r.marks != null) {
55 return false;
56 }if (this.marks != null && r.marks == null) {
57 return false;
58 }for (var i = 1; i <= this.numSubs_; i++) {
59 if (this.matchedFromI (i) != r.matchedFromI (i)) {
60 return false;
61 } else if (this.charsMatchedI (i) != r.charsMatchedI (i)) {
62 return false;
63 }}
64 return true;
65 }, "com.stevesoft.pat.RegRes");
66 Clazz.defineMethod (c$, "stringMatched", 
67 function () {
68 var mf = this.matchedFrom ();
69 var cm = this.charsMatched ();
70 return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf, mf + cm);
71 });
72 Clazz.defineMethod (c$, "matchedFromI", 
73 function (i) {
74 if (this.marks == null || i > this.numSubs_) {
75 return -1;
76 }return this.marks[i];
77 }, "~N");
78 Clazz.defineMethod (c$, "charsMatchedI", 
79 function (i) {
80 if (this.marks == null || i > this.numSubs_ || !this.didMatch_) {
81 return -1;
82 }var mf = this.matchedFromI (i);
83 return mf < 0 ? -1 : this.marks[i + this.numSubs_] - this.matchedFromI (i);
84 }, "~N");
85 Clazz.defineMethod (c$, "matchedToI", 
86 function (i) {
87 if (this.marks == null || i > this.numSubs_ || !this.didMatch_) {
88 return -1;
89 }return this.marks[i + this.numSubs_];
90 }, "~N");
91 Clazz.defineMethod (c$, "stringMatchedI", 
92 function (i) {
93 var mf = this.matchedFromI (i);
94 var cm = this.charsMatchedI (i);
95 return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf, mf + cm);
96 }, "~N");
97 Clazz.defineMethod (c$, "left", 
98 function () {
99 var mf = this.matchedFrom ();
100 return !this.didMatch_ || (mf < 0) ? null : this.src.substring (0, mf);
101 });
102 Clazz.defineMethod (c$, "leftI", 
103 function (i) {
104 var mf = this.matchedFromI (i);
105 return !this.didMatch_ || (mf < 0) ? null : this.src.substring (0, mf);
106 }, "~N");
107 Clazz.defineMethod (c$, "right", 
108 function () {
109 var mf = this.matchedFrom ();
110 var cm = this.charsMatched ();
111 return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf + cm, this.src.length ());
112 });
113 Clazz.defineMethod (c$, "rightI", 
114 function (i) {
115 var mf = this.matchedFromI (i);
116 var cm = this.charsMatchedI (i);
117 return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf + cm, this.src.length ());
118 }, "~N");
119 Clazz.defineMethod (c$, "matchedFrom", 
120 function () {
121 return !this.didMatch_ ? -1 : this.matchFrom_;
122 });
123 Clazz.defineMethod (c$, "charsMatched", 
124 function () {
125 return !this.didMatch_ || this.matchFrom_ < 0 ? -1 : this.charsMatched_;
126 });
127 Clazz.defineMethod (c$, "matchedTo", 
128 function () {
129 return !this.didMatch_ ? -1 : this.matchFrom_ + this.charsMatched_;
130 });
131 Clazz.defineMethod (c$, "numSubs", 
132 function () {
133 return this.numSubs_;
134 });
135 Clazz.defineMethod (c$, "didMatch", 
136 function () {
137 return this.didMatch_;
138 });
139 Clazz.defineMethod (c$, "matchFrom", 
140 function () {
141 return this.matchedFrom ();
142 });
143 Clazz.defineMethod (c$, "substring", 
144 function () {
145 return this.stringMatched ();
146 });
147 Clazz.defineMethod (c$, "matchFromI", 
148 function (i) {
149 return this.matchedFromI (i);
150 }, "~N");
151 Clazz.defineMethod (c$, "substringI", 
152 function (i) {
153 return this.stringMatchedI (i);
154 }, "~N");
155 });