1 Clazz.declarePackage ("java.util.zip");
2 Clazz.load (["java.util.zip.InflaterInputStream", "$.CRC32"], "java.util.zip.GZIPInputStream", ["java.io.EOFException", "$.IOException", "java.util.zip.CheckedInputStream", "$.Inflater", "$.ZipException"], function () {
3 c$ = Clazz.decorateAsClass (function () {
8 Clazz.instantialize (this, arguments);
9 }, java.util.zip, "GZIPInputStream", java.util.zip.InflaterInputStream);
10 Clazz.prepareFields (c$, function () {
11 this.crc = new java.util.zip.CRC32 ();
12 this.tmpbuf = Clazz.newByteArray (128, 0);
14 Clazz.defineMethod (c$, "ensureOpen",
17 throw new java.io.IOException ("Stream closed");
19 Clazz.makeConstructor (c$,
20 function ($in, size) {
21 Clazz.superConstructor (this, java.util.zip.GZIPInputStream, [$in, new java.util.zip.Inflater ().init (0, true), size]);
22 this.readHeader ($in);
23 }, "java.io.InputStream,~N");
24 Clazz.overrideMethod (c$, "read",
25 function (buf, off, len) {
29 }var n = this.readInf (buf, off, len);
31 if (this.readTrailer ()) this.eos = true;
32 else return this.read (buf, off, len);
34 this.crc.update (buf, off, n);
37 Clazz.defineMethod (c$, "close",
40 Clazz.superCall (this, java.util.zip.GZIPInputStream, "close", []);
44 Clazz.defineMethod (c$, "readHeader",
46 var $in = new java.util.zip.CheckedInputStream (this_in).set (this.crc);
48 if (this.readUShort ($in) != 35615) {
49 throw new java.util.zip.ZipException ("Not in GZIP format");
50 }if (this.readUByte ($in) != 8) {
51 throw new java.util.zip.ZipException ("Unsupported compression method");
52 }var flg = this.readUByte ($in);
53 this.skipBytes ($in, 6);
56 var m = this.readUShort ($in);
57 this.skipBytes ($in, m);
59 }if ((flg & 8) == 8) {
62 } while (this.readUByte ($in) != 0);
63 }if ((flg & 16) == 16) {
66 } while (this.readUByte ($in) != 0);
67 }if ((flg & 2) == 2) {
68 var v = this.crc.getValue () & 0xffff;
69 if (this.readUShort ($in) != v) {
70 throw new java.util.zip.ZipException ("Corrupt GZIP header");
74 }, "java.io.InputStream");
75 Clazz.defineMethod (c$, "readTrailer",
79 Clazz.defineMethod (c$, "readUShort",
81 var b = this.readUByte ($in);
82 return (this.readUByte ($in) << 8) | b;
83 }, "java.io.InputStream");
84 Clazz.defineMethod (c$, "readUByte",
86 var b = $in.readByteAsInt ();
88 throw new java.io.EOFException ();
89 }if (b < -1 || b > 255) {
90 throw new java.io.IOException (this.$in.getClass ().getName () + ".read() returned value out of range -1..255: " + b);
92 }, "java.io.InputStream");
93 Clazz.defineMethod (c$, "skipBytes",
96 var len = $in.read (this.tmpbuf, 0, n < this.tmpbuf.length ? n : this.tmpbuf.length);
98 throw new java.io.EOFException ();
101 }, "java.io.InputStream,~N");
102 Clazz.defineStatics (c$,
103 "GZIP_MAGIC", 0x8b1f,