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