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