1 Clazz.load (["java.io.Reader"], "java.io.BufferedReader", ["java.io.IOException", "java.lang.IllegalArgumentException", "$.IndexOutOfBoundsException", "JU.SB"], function () {
\r
2 c$ = Clazz.decorateAsClass (function () {
\r
7 this.markedChar = -1;
\r
8 this.readAheadLimit = 0;
\r
10 this.markedSkipLF = false;
\r
11 Clazz.instantialize (this, arguments);
\r
12 }, java.io, "BufferedReader", java.io.Reader);
\r
13 Clazz.defineMethod (c$, "setSize",
\r
15 if (sz <= 0) throw new IllegalArgumentException ("Buffer size <= 0");
\r
16 this.cb = Clazz.newCharArray (sz, '\0');
\r
17 this.nextChar = this.nChars = 0;
\r
19 Clazz.makeConstructor (c$,
\r
21 Clazz.superConstructor (this, java.io.BufferedReader, [$in]);
\r
23 this.setSize (8192);
\r
24 }, "java.io.Reader");
\r
25 Clazz.defineMethod (c$, "ensureOpen",
\r
27 if (this.$in == null) throw new java.io.IOException ("Stream closed");
\r
29 Clazz.defineMethod (c$, "fill",
\r
32 if (this.markedChar <= -1) {
\r
35 var delta = this.nextChar - this.markedChar;
\r
36 if (delta >= this.readAheadLimit) {
\r
37 this.markedChar = -2;
\r
38 this.readAheadLimit = 0;
\r
41 if (this.readAheadLimit <= this.cb.length) {
\r
42 System.arraycopy (this.cb, this.markedChar, this.cb, 0, delta);
\r
43 this.markedChar = 0;
\r
46 var ncb = Clazz.newCharArray (this.readAheadLimit, '\0');
\r
47 System.arraycopy (this.cb, this.markedChar, ncb, 0, delta);
\r
49 this.markedChar = 0;
\r
51 }this.nextChar = this.nChars = delta;
\r
54 n = this.$in.read (this.cb, dst, this.cb.length - dst);
\r
57 this.nChars = dst + n;
\r
58 this.nextChar = dst;
\r
60 Clazz.defineMethod (c$, "read1",
\r
61 function (cbuf, off, len) {
\r
62 if (this.nextChar >= this.nChars) {
\r
63 if (len >= this.cb.length && this.markedChar <= -1 && !this.skipLF) {
\r
64 return this.$in.read (cbuf, off, len);
\r
66 }if (this.nextChar >= this.nChars) return -1;
\r
68 this.skipLF = false;
\r
69 if (this.cb[this.nextChar] == '\n') {
\r
71 if (this.nextChar >= this.nChars) this.fill ();
\r
72 if (this.nextChar >= this.nChars) return -1;
\r
73 }}var n = Math.min (len, this.nChars - this.nextChar);
\r
74 System.arraycopy (this.cb, this.nextChar, cbuf, off, n);
\r
78 Clazz.defineMethod (c$, "read",
\r
79 function (cbuf, off, len) {
\r
82 if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) {
\r
83 throw new IndexOutOfBoundsException ();
\r
84 } else if (len == 0) {
\r
86 }var n = this.read1 (cbuf, off, len);
\r
87 if (n <= 0) return n;
\r
88 while ((n < len) && this.$in.ready ()) {
\r
89 var n1 = this.read1 (cbuf, off + n, len - n);
\r
95 Clazz.defineMethod (c$, "readLine1",
\r
96 function (ignoreLF) {
\r
100 this.ensureOpen ();
\r
101 var omitLF = ignoreLF || this.skipLF;
\r
103 if (this.nextChar >= this.nChars) this.fill ();
\r
104 if (this.nextChar >= this.nChars) {
\r
105 if (s != null && s.length () > 0) return s.toString ();
\r
108 var c = String.fromCharCode (0);
\r
110 if (omitLF && (this.cb[this.nextChar] == '\n')) this.nextChar++;
\r
111 this.skipLF = false;
\r
113 charLoop : for (i = this.nextChar; i < this.nChars; i++) {
\r
115 if ((c == '\n') || (c == '\r')) {
\r
119 startChar = this.nextChar;
\r
124 str = String.instantialize (this.cb, startChar, i - startChar);
\r
126 s.appendCB (this.cb, startChar, i - startChar);
\r
127 str = s.toString ();
\r
130 this.skipLF = true;
\r
132 }if (s == null) s = JU.SB.newN (80);
\r
133 s.appendCB (this.cb, startChar, i - startChar);
\r
136 Clazz.defineMethod (c$, "readLine",
\r
138 return this.readLine1 (false);
\r
140 Clazz.overrideMethod (c$, "skip",
\r
143 throw new IllegalArgumentException ("skip value is negative");
\r
145 this.ensureOpen ();
\r
148 if (this.nextChar >= this.nChars) this.fill ();
\r
149 if (this.nextChar >= this.nChars) break;
\r
151 this.skipLF = false;
\r
152 if (this.cb[this.nextChar] == '\n') {
\r
154 }}var d = this.nChars - this.nextChar;
\r
156 this.nextChar += r;
\r
160 this.nextChar = this.nChars;
\r
164 Clazz.defineMethod (c$, "ready",
\r
167 this.ensureOpen ();
\r
169 if (this.nextChar >= this.nChars && this.$in.ready ()) {
\r
171 }if (this.nextChar < this.nChars) {
\r
172 if (this.cb[this.nextChar] == '\n') this.nextChar++;
\r
173 this.skipLF = false;
\r
174 }}return (this.nextChar < this.nChars) || this.$in.ready ();
\r
176 Clazz.overrideMethod (c$, "markSupported",
\r
180 Clazz.overrideMethod (c$, "mark",
\r
181 function (readAheadLimit) {
\r
182 if (readAheadLimit < 0) {
\r
183 throw new IllegalArgumentException ("Read-ahead limit < 0");
\r
185 this.ensureOpen ();
\r
186 this.readAheadLimit = readAheadLimit;
\r
187 this.markedChar = this.nextChar;
\r
188 this.markedSkipLF = this.skipLF;
\r
190 Clazz.overrideMethod (c$, "reset",
\r
193 this.ensureOpen ();
\r
194 if (this.markedChar < 0) throw new java.io.IOException ((this.markedChar == -2) ? "Mark invalid" : "Stream not marked");
\r
195 this.nextChar = this.markedChar;
\r
196 this.skipLF = this.markedSkipLF;
\r
198 Clazz.defineMethod (c$, "close",
\r
201 if (this.$in == null) return;
\r
206 Clazz.defineStatics (c$,
\r
209 "DEFAULT_CHAR_BUFFER_SIZE", 8192,
\r
210 "DEFAULT_EXPECTED_LINE_LENGTH", 80);
\r