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