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