1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (null, "com.stevesoft.pat.RegRes", ["java.lang.StringBuffer"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.didMatch_ = false;
7 this.charsMatched_ = 0;
10 Clazz.instantialize (this, arguments);
11 }, com.stevesoft.pat, "RegRes");
12 Clazz.defineMethod (c$, "getString",
14 return this.src.toString ();
16 Clazz.defineMethod (c$, "getStringLike",
20 Clazz.overrideMethod (c$, "toString",
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++) {
28 sb.append (" sub(" + n + ")=" + this.matchedFromI (n) + ":" + this.charsMatchedI (n));
30 return sb.toString ();
32 Clazz.defineMethod (c$, "copyOutOf",
34 if (r.marks == null) {
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];
44 }this.didMatch_ = r.didMatch_;
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",
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 ())) {
54 }if (this.marks == null && r.marks != null) {
56 }if (this.marks != null && r.marks == null) {
58 }for (var i = 1; i <= this.numSubs_; i++) {
59 if (this.matchedFromI (i) != r.matchedFromI (i)) {
61 } else if (this.charsMatchedI (i) != r.charsMatchedI (i)) {
65 }, "com.stevesoft.pat.RegRes");
66 Clazz.defineMethod (c$, "stringMatched",
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);
72 Clazz.defineMethod (c$, "matchedFromI",
74 if (this.marks == null || i > this.numSubs_) {
76 }return this.marks[i];
78 Clazz.defineMethod (c$, "charsMatchedI",
80 if (this.marks == null || i > this.numSubs_ || !this.didMatch_) {
82 }var mf = this.matchedFromI (i);
83 return mf < 0 ? -1 : this.marks[i + this.numSubs_] - this.matchedFromI (i);
85 Clazz.defineMethod (c$, "matchedToI",
87 if (this.marks == null || i > this.numSubs_ || !this.didMatch_) {
89 }return this.marks[i + this.numSubs_];
91 Clazz.defineMethod (c$, "stringMatchedI",
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);
97 Clazz.defineMethod (c$, "left",
99 var mf = this.matchedFrom ();
100 return !this.didMatch_ || (mf < 0) ? null : this.src.substring (0, mf);
102 Clazz.defineMethod (c$, "leftI",
104 var mf = this.matchedFromI (i);
105 return !this.didMatch_ || (mf < 0) ? null : this.src.substring (0, mf);
107 Clazz.defineMethod (c$, "right",
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 ());
113 Clazz.defineMethod (c$, "rightI",
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 ());
119 Clazz.defineMethod (c$, "matchedFrom",
121 return !this.didMatch_ ? -1 : this.matchFrom_;
123 Clazz.defineMethod (c$, "charsMatched",
125 return !this.didMatch_ || this.matchFrom_ < 0 ? -1 : this.charsMatched_;
127 Clazz.defineMethod (c$, "matchedTo",
129 return !this.didMatch_ ? -1 : this.matchFrom_ + this.charsMatched_;
131 Clazz.defineMethod (c$, "numSubs",
133 return this.numSubs_;
135 Clazz.defineMethod (c$, "didMatch",
137 return this.didMatch_;
139 Clazz.defineMethod (c$, "matchFrom",
141 return this.matchedFrom ();
143 Clazz.defineMethod (c$, "substring",
145 return this.stringMatched ();
147 Clazz.defineMethod (c$, "matchFromI",
149 return this.matchedFromI (i);
151 Clazz.defineMethod (c$, "substringI",
153 return this.stringMatchedI (i);