1 Clazz.declarePackage ("com.stevesoft.pat");
\r
2 Clazz.load (["com.stevesoft.pat.ReplaceRule", "$.Replacer"], ["com.stevesoft.pat.Transformer", "$.TransRepRule"], ["com.stevesoft.pat.MessageManager", "$.Regex", "$.TransPat", "com.stevesoft.pat.wrap.StringWrap", "java.lang.ArrayIndexOutOfBoundsException", "$.NullPointerException"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
5 Clazz.instantialize (this, arguments);
\r
6 }, com.stevesoft.pat, "TransRepRule", com.stevesoft.pat.ReplaceRule);
\r
7 Clazz.makeConstructor (c$,
\r
9 Clazz.superConstructor (this, com.stevesoft.pat.TransRepRule, []);
\r
11 }, "com.stevesoft.pat.Transformer");
\r
12 Clazz.overrideMethod (c$, "toString1",
\r
16 Clazz.overrideMethod (c$, "clone1",
\r
18 return new com.stevesoft.pat.TransRepRule (this.t);
\r
20 Clazz.overrideMethod (c$, "apply",
\r
22 this.next = this.t.tp.ra[this.t.tp.pn].getReplaceRule ();
\r
23 }, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes");
\r
24 c$ = Clazz.decorateAsClass (function () {
\r
27 this.auto_optimize = false;
\r
29 Clazz.instantialize (this, arguments);
\r
30 }, com.stevesoft.pat, "Transformer");
\r
31 Clazz.prepareFields (c$, function () {
\r
32 this.repr = new com.stevesoft.pat.Replacer ();
\r
34 Clazz.defineMethod (c$, "getReplacer",
\r
36 return this.rp.getReplacer ();
\r
38 Clazz.makeConstructor (c$,
\r
40 this.rp = new com.stevesoft.pat.Regex (null, "");
\r
41 this.auto_optimize = auto;
\r
42 this.tp = new com.stevesoft.pat.TransPat ();
\r
43 this.rp.setReplaceRule ( new com.stevesoft.pat.TransRepRule (this));
\r
44 this.rp.thePattern = this.tp;
\r
46 Clazz.defineMethod (c$, "add",
\r
48 if (this.auto_optimize) {
\r
50 }this.tp.ra[this.tp.ra_len++] = r;
\r
51 if (this.tp.ra.length == this.tp.ra_len) {
\r
52 var ra2 = new Array (this.tp.ra_len + 10);
\r
53 for (var i = 0; i < this.tp.ra_len; i++) {
\r
54 ra2[i] = this.tp.ra[i];
\r
57 }this.rp.numSubs_ = r.numSubs_ > this.rp.numSubs_ ? r.numSubs_ : this.rp.numSubs_;
\r
58 }, "com.stevesoft.pat.Regex");
\r
59 Clazz.defineMethod (c$, "patterns",
\r
61 return this.tp.ra_len;
\r
63 Clazz.defineMethod (c$, "getRegexAt",
\r
65 if (i >= this.tp.ra_len) {
\r
66 throw new ArrayIndexOutOfBoundsException ("i=" + i + ">=" + this.patterns ());
\r
68 throw new ArrayIndexOutOfBoundsException ("i=" + i + "< 0");
\r
69 }return this.tp.ra[i];
\r
71 Clazz.defineMethod (c$, "setRegexAt",
\r
73 if (i >= this.tp.ra_len) {
\r
74 throw new ArrayIndexOutOfBoundsException ("i=" + i + ">=" + this.patterns ());
\r
76 throw new ArrayIndexOutOfBoundsException ("i=" + i + "< 0");
\r
77 }this.tp.ra[i] = rx;
\r
78 }, "com.stevesoft.pat.Regex,~N");
\r
79 Clazz.defineMethod (c$, "add",
\r
81 var r = com.stevesoft.pat.Regex.perlCode (rs);
\r
83 throw new NullPointerException (com.stevesoft.pat.MessageManager.formatMessage ("exception.bad_pattern_to_regex_perl_code", Clazz.newArray (-1, [rs])));
\r
86 Clazz.defineMethod (c$, "add",
\r
88 for (var i = 0; i < array.length; i++) {
\r
89 this.add (array[i]);
\r
92 Clazz.defineMethod (c$, "replaceAll",
\r
94 return this.dorep (s, 0, s.length);
\r
96 Clazz.defineMethod (c$, "replaceAll",
\r
98 return this.dorep (s, 0, s.length ());
\r
99 }, "com.stevesoft.pat.StringLike");
\r
100 Clazz.defineMethod (c$, "replaceAllFrom",
\r
101 function (s, start) {
\r
102 return this.dorep (s, start, s.length);
\r
104 Clazz.defineMethod (c$, "replaceAllRegion",
\r
105 function (s, start, end) {
\r
106 return this.dorep (s, start, end);
\r
108 Clazz.defineMethod (c$, "dorep",
\r
109 function (s, start, end) {
\r
110 var tfmd = this.repr.replaceAllRegion (s, this.rp, start, end);
\r
111 this.tp.lastMatchedTo = this.repr.$lastMatchedTo;
\r
113 }, "com.stevesoft.pat.StringLike,~N,~N");
\r
114 Clazz.defineMethod (c$, "dorep",
\r
115 function (s, start, end) {
\r
116 return this.dorep ( new com.stevesoft.pat.wrap.StringWrap (s), start, end).toString ();
\r
118 Clazz.defineMethod (c$, "replaceFirst",
\r
120 return this.dorep (s, 0, s.length);
\r
122 Clazz.defineMethod (c$, "replaceFirstFrom",
\r
123 function (s, start) {
\r
124 return this.dorep (s, start, s.length);
\r
126 Clazz.defineMethod (c$, "replaceFirstRegion",
\r
127 function (s, start, end) {
\r
128 return this.dorep (s, start, end);
\r