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