1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (["java.io.Reader", "com.stevesoft.pat.PartialBuffer", "$.RBuffer", "java.lang.StringBuffer"], "com.stevesoft.pat.RegexReader", ["com.stevesoft.pat.StringBufferLike", "com.stevesoft.pat.wrap.StringBufferWrap"], function () {
3 c$ = Clazz.decorateAsClass (function () {
6 this.moreToRead = true;
12 Clazz.instantialize (this, arguments);
13 }, com.stevesoft.pat, "RegexReader", java.io.Reader);
14 Clazz.prepareFields (c$, function () {
15 this.rb = new com.stevesoft.pat.RBuffer ( new StringBuffer ());
16 this.wrap = new com.stevesoft.pat.PartialBuffer (this.rb.sb);
18 Clazz.makeConstructor (c$,
20 Clazz.superConstructor (this, com.stevesoft.pat.RegexReader, []);
22 this.rp = rex.getReplacer ();
23 }, "com.stevesoft.pat.Regex,java.io.Reader");
24 Clazz.makeConstructor (c$,
26 Clazz.superConstructor (this, com.stevesoft.pat.RegexReader, []);
28 this.rp = tex.getReplacer ();
29 }, "com.stevesoft.pat.Transformer,java.io.Reader");
30 Clazz.defineMethod (c$, "reset",
33 this.rb = new com.stevesoft.pat.RBuffer ( new StringBuffer ());
34 this.wrap = new com.stevesoft.pat.PartialBuffer (this.rb.sb);
35 this.moreToRead = true;
37 Clazz.defineMethod (c$, "readData",
41 while ((c = this.r.read ()) != -1) {
42 this.rb.sb.append (String.fromCharCode (c));
43 if (n++ > this.nmax) {
46 if (c == -1 && n == 0) {
47 this.moreToRead = false;
48 this.wrap.allowOverRun = false;
50 Clazz.defineMethod (c$, "getMoreData",
52 while (this.rb.pos >= this.rb.epos) {
53 this.wrap.overRun = false;
54 if (this.rb.next != null) {
55 this.rb = this.rb.next;
56 } else if (this.rb.done) {
58 } else if (this.rb.epos >= this.rb.sb.length () && this.rb.epos > this.nmax) {
61 this.rb.sb.setLength (1);
63 } else if (this.rb.epos >= this.rb.sb.length () && this.moreToRead) {
65 } else if (this.rp.getRegex ().matchAt (this.wrap, this.rb.epos)) {
66 if (this.wrap.overRun) {
69 var sbw = new com.stevesoft.pat.wrap.StringBufferWrap ();
70 var sbl = new com.stevesoft.pat.StringBufferLike (sbw);
71 var rex = this.rp.getRegex ();
72 var npos = rex.matchedTo ();
73 this.rp.setBuffer (sbl);
74 this.rp.setSource (this.wrap);
75 this.rp.setPos (npos);
76 this.rp.apply (rex, rex.getReplaceRule ());
77 var opos = this.rb.epos;
78 var rb2 = new com.stevesoft.pat.RBuffer (sbw.unwrap ());
79 rb2.epos = rb2.sb.length ();
80 var rb3 = new com.stevesoft.pat.RBuffer (this.rb.sb);
85 if (rb3.epos > rb3.sb.length ()) {
86 if (this.rb.pos >= this.rb.epos) {
87 this.rb = this.rb.next;
88 }rb3.pos = rb3.epos = 0;
92 rb3.pos = rb3.epos = npos;
94 if (this.wrap.overRun) {
96 } else if (this.rb.epos < this.rb.sb.length ()) {
102 Clazz.defineMethod (c$, "read",
104 if (this.rb.pos >= this.rb.epos) {
106 if (this.rb.pos >= this.rb.epos) {
108 }}return this.rb.sb.charAt (this.rb.pos++);
110 Clazz.defineMethod (c$, "read",
111 function (buf, off, len) {
114 for (var i = off; i < end; i++) {
120 }buf[i] = String.fromCharCode (c);
124 Clazz.defineMethod (c$, "close",
128 Clazz.overrideMethod (c$, "markSupported",
132 Clazz.defineMethod (c$, "getBufferSize",
136 Clazz.defineMethod (c$, "setBufferSize",
140 Clazz.defineMethod (c$, "getMaxLines",
142 return this.max_lines;
144 Clazz.defineMethod (c$, "setMaxLines",
148 Clazz.defineMethod (c$, "getEOLchar",
152 Clazz.defineMethod (c$, "setEOLchar",
156 Clazz.overrideMethod (c$, "skip",
159 while (n < d && this.read () != -1) {