1 Clazz.load (["java.io.FilterInputStream"], "java.io.BufferedInputStream", ["java.io.IOException", "java.lang.IndexOutOfBoundsException"], function () {
\r
2 c$ = Clazz.decorateAsClass (function () {
\r
8 Clazz.instantialize (this, arguments);
\r
9 }, java.io, "BufferedInputStream", java.io.FilterInputStream);
\r
10 Clazz.defineMethod (c$, "getInIfOpen",
\r
12 var input = this.$in;
\r
13 if (input == null) throw new java.io.IOException ("Stream closed");
\r
16 Clazz.defineMethod (c$, "getBufIfOpen",
\r
18 var buffer = this.buf;
\r
19 if (buffer == null) throw new java.io.IOException ("Stream closed");
\r
22 Clazz.overrideMethod (c$, "resetStream",
\r
25 Clazz.makeConstructor (c$,
\r
27 Clazz.superConstructor (this, java.io.BufferedInputStream, [$in]);
\r
28 this.buf = Clazz.newByteArray (8192, 0);
\r
29 }, "java.io.InputStream");
\r
30 Clazz.defineMethod (c$, "fill",
\r
32 var buffer = this.getBufIfOpen ();
\r
33 if (this.markpos < 0) this.pos = 0;
\r
34 else if (this.pos >= buffer.length) if (this.markpos > 0) {
\r
35 var sz = this.pos - this.markpos;
\r
36 System.arraycopy (buffer, this.markpos, buffer, 0, sz);
\r
39 } else if (buffer.length >= this.marklimit) {
\r
43 var nsz = this.pos * 2;
\r
44 if (nsz > this.marklimit) nsz = this.marklimit;
\r
45 var nbuf = Clazz.newByteArray (nsz, 0);
\r
46 System.arraycopy (buffer, 0, nbuf, 0, this.pos);
\r
47 buffer = this.buf = nbuf;
\r
48 }this.count = this.pos;
\r
49 var n = this.getInIfOpen ().read (buffer, this.pos, buffer.length - this.pos);
\r
50 if (n > 0) this.count = n + this.pos;
\r
52 Clazz.overrideMethod (c$, "readByteAsInt",
\r
54 if (this.pos >= this.count) {
\r
56 if (this.pos >= this.count) return -1;
\r
57 }return this.getBufIfOpen ()[this.pos++] & 0xff;
\r
59 Clazz.defineMethod (c$, "read1",
\r
60 function (b, off, len) {
\r
61 var avail = this.count - this.pos;
\r
63 if (len >= this.getBufIfOpen ().length && this.markpos < 0) {
\r
64 return this.getInIfOpen ().read (b, off, len);
\r
66 avail = this.count - this.pos;
\r
67 if (avail <= 0) return -1;
\r
68 }var cnt = (avail < len) ? avail : len;
\r
69 System.arraycopy (this.getBufIfOpen (), this.pos, b, off, cnt);
\r
73 Clazz.overrideMethod (c$, "read",
\r
74 function (b, off, len) {
\r
75 if (arguments.length == 1) {
\r
79 this.getBufIfOpen ();
\r
80 if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
\r
81 throw new IndexOutOfBoundsException ();
\r
82 } else if (len == 0) {
\r
86 var nread = this.read1 (b, off + n, len - n);
\r
87 if (nread <= 0) return (n == 0) ? nread : n;
\r
89 if (n >= len) return n;
\r
90 var input = this.$in;
\r
91 if (input != null && input.available () <= 0) return n;
\r
94 Clazz.overrideMethod (c$, "skip",
\r
96 this.getBufIfOpen ();
\r
99 }var avail = this.count - this.pos;
\r
101 if (this.markpos < 0) return this.getInIfOpen ().skip (n);
\r
103 avail = this.count - this.pos;
\r
104 if (avail <= 0) return 0;
\r
105 }var skipped = (avail < n) ? avail : n;
\r
106 this.pos += skipped;
\r
109 Clazz.overrideMethod (c$, "available",
\r
111 var n = this.count - this.pos;
\r
112 var avail = this.getInIfOpen ().available ();
\r
113 return n > (2147483647 - avail) ? 2147483647 : n + avail;
\r
115 Clazz.overrideMethod (c$, "mark",
\r
116 function (readlimit) {
\r
117 this.marklimit = readlimit;
\r
118 this.markpos = this.pos;
\r
120 Clazz.overrideMethod (c$, "reset",
\r
122 this.getBufIfOpen ();
\r
123 if (this.markpos < 0) throw new java.io.IOException ("Resetting to invalid mark");
\r
124 this.pos = this.markpos;
\r
126 Clazz.overrideMethod (c$, "markSupported",
\r
130 Clazz.overrideMethod (c$, "close",
\r
132 var input = this.$in;
\r
134 if (input != null) input.close ();
\r
137 Clazz.defineStatics (c$,
\r
138 "DEFAULT_BUFFER_SIZE", 8192);
\r