1 Clazz.declarePackage ("JU");
\r
2 Clazz.load (["java.io.FilterInputStream"], "JU.InflaterInputStream", ["java.io.EOFException", "$.IOException", "java.lang.IllegalArgumentException", "$.IndexOutOfBoundsException", "$.NullPointerException"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.inflater = null;
\r
9 this.close_in = true;
\r
10 this.myinflater = false;
\r
13 Clazz.instantialize (this, arguments);
\r
14 }, JU, "InflaterInputStream", java.io.FilterInputStream);
\r
15 Clazz.prepareFields (c$, function () {
\r
16 this.byte1 = Clazz.newByteArray (1, 0);
\r
17 this.b = Clazz.newByteArray (512, 0);
\r
19 Clazz.makeConstructor (c$,
\r
20 function ($in, inflater, size, close_in) {
\r
21 Clazz.superConstructor (this, JU.InflaterInputStream, [$in]);
\r
22 this.inflater = inflater;
\r
23 this.buf = Clazz.newByteArray (size, 0);
\r
24 this.close_in = close_in;
\r
25 }, "java.io.InputStream,JU.Inflater,~N,~B");
\r
26 Clazz.overrideMethod (c$, "readByteAsInt",
\r
29 throw new java.io.IOException ("Stream closed");
\r
30 }return this.read (this.byte1, 0, 1) == -1 ? -1 : this.byte1[0] & 0xff;
\r
32 Clazz.overrideMethod (c$, "read",
\r
33 function (b, off, len) {
\r
34 return this.readInf (b, off, len);
\r
36 Clazz.defineMethod (c$, "readInf",
\r
37 function (b, off, len) {
\r
39 throw new java.io.IOException ("Stream closed");
\r
41 throw new NullPointerException ();
\r
42 } else if (off < 0 || len < 0 || len > b.length - off) {
\r
43 throw new IndexOutOfBoundsException ();
\r
44 } else if (len == 0) {
\r
46 } else if (this.eof) {
\r
49 this.inflater.setOutput (b, off, len);
\r
51 if (this.inflater.avail_in == 0) this.fill ();
\r
52 var err = this.inflater.inflate (0);
\r
53 n += this.inflater.next_out_index - off;
\r
54 off = this.inflater.next_out_index;
\r
57 throw new java.io.IOException (this.inflater.msg);
\r
61 if (err == 2) return -1;
\r
65 if (this.inflater.avail_out == 0) break;
\r
69 Clazz.overrideMethod (c$, "available",
\r
72 throw new java.io.IOException ("Stream closed");
\r
73 }return (this.eof ? 0 : 1);
\r
75 Clazz.overrideMethod (c$, "skip",
\r
78 throw new IllegalArgumentException ("negative skip length");
\r
80 throw new java.io.IOException ("Stream closed");
\r
81 }var max = Math.min (n, 2147483647);
\r
83 while (total < max) {
\r
84 var len = max - total;
\r
85 if (len > this.b.length) {
\r
86 len = this.b.length;
\r
87 }len = this.read (this.b, 0, len);
\r
95 Clazz.overrideMethod (c$, "close",
\r
98 if (this.myinflater) this.inflater.end ();
\r
99 if (this.close_in) this.$in.close ();
\r
100 this.closed = true;
\r
102 Clazz.defineMethod (c$, "fill",
\r
105 throw new java.io.IOException ("Stream closed");
\r
106 }this.len = this.$in.read (this.buf, 0, this.buf.length);
\r
107 if (this.len == -1) {
\r
108 if (this.inflater.istate.wrap == 0 && !this.inflater.finished ()) {
\r
111 } else if (this.inflater.istate.was != -1) {
\r
112 throw new java.io.IOException ("footer is not found");
\r
114 throw new java.io.EOFException ("Unexpected end of ZLIB input stream");
\r
115 }}this.inflater.setInput (this.buf, 0, this.len, true);
\r
117 Clazz.overrideMethod (c$, "markSupported",
\r
121 Clazz.overrideMethod (c$, "mark",
\r
122 function (readlimit) {
\r
124 Clazz.overrideMethod (c$, "reset",
\r
126 throw new java.io.IOException ("mark/reset not supported");
\r
128 Clazz.defineMethod (c$, "getTotalIn",
\r
130 return this.inflater.getTotalIn ();
\r
132 Clazz.defineMethod (c$, "getTotalOut",
\r
134 return this.inflater.getTotalOut ();
\r
136 Clazz.defineMethod (c$, "getAvailIn",
\r
138 if (this.inflater.avail_in <= 0) return null;
\r
139 var tmp = Clazz.newByteArray (this.inflater.avail_in, 0);
\r
140 System.arraycopy (this.inflater.next_in, this.inflater.next_in_index, tmp, 0, this.inflater.avail_in);
\r
143 Clazz.defineMethod (c$, "readHeader",
\r
145 var empty = "".getBytes ();
\r
146 this.inflater.setInput (empty, 0, 0, false);
\r
147 this.inflater.setOutput (empty, 0, 0);
\r
148 var err = this.inflater.inflate (0);
\r
149 if (!this.inflater.istate.inParsingHeader ()) {
\r
151 }var b1 = Clazz.newByteArray (1, 0);
\r
153 var i = this.$in.read (b1, 0, 1);
\r
154 if (i <= 0) throw new java.io.IOException ("no input");
\r
155 this.inflater.setInput (b1, 0, b1.length, false);
\r
156 err = this.inflater.inflate (0);
\r
157 if (err != 0) throw new java.io.IOException (this.inflater.msg);
\r
158 } while (this.inflater.istate.inParsingHeader ());
\r
160 Clazz.defineMethod (c$, "getInflater",
\r
162 return this.inflater;
\r
164 Clazz.defineStatics (c$,
\r
165 "DEFAULT_BUFSIZE", 512);
\r