Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / swingjs / j2s / JU / InflaterInputStream.js
index 5cf6a8a..9af5e95 100644 (file)
-Clazz.declarePackage ("JU");\r
-Clazz.load (["java.io.FilterInputStream"], "JU.InflaterInputStream", ["java.io.EOFException", "$.IOException", "java.lang.IllegalArgumentException", "$.IndexOutOfBoundsException", "$.NullPointerException"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.inflater = null;\r
-this.buf = null;\r
-this.len = 0;\r
-this.closed = false;\r
-this.eof = false;\r
-this.close_in = true;\r
-this.myinflater = false;\r
-this.byte1 = null;\r
-this.b = null;\r
-Clazz.instantialize (this, arguments);\r
-}, JU, "InflaterInputStream", java.io.FilterInputStream);\r
-Clazz.prepareFields (c$, function () {\r
-this.byte1 =  Clazz.newByteArray (1, 0);\r
-this.b =  Clazz.newByteArray (512, 0);\r
-});\r
-Clazz.makeConstructor (c$, \r
-function ($in, inflater, size, close_in) {\r
-Clazz.superConstructor (this, JU.InflaterInputStream, [$in]);\r
-this.inflater = inflater;\r
-this.buf =  Clazz.newByteArray (size, 0);\r
-this.close_in = close_in;\r
-}, "java.io.InputStream,JU.Inflater,~N,~B");\r
-Clazz.overrideMethod (c$, "readByteAsInt", \r
-function () {\r
-if (this.closed) {\r
-throw  new java.io.IOException ("Stream closed");\r
-}return this.read (this.byte1, 0, 1) == -1 ? -1 : this.byte1[0] & 0xff;\r
-});\r
-Clazz.overrideMethod (c$, "read", \r
-function (b, off, len) {\r
-return this.readInf (b, off, len);\r
-}, "~A,~N,~N");\r
-Clazz.defineMethod (c$, "readInf", \r
-function (b, off, len) {\r
-if (this.closed) {\r
-throw  new java.io.IOException ("Stream closed");\r
-}if (b == null) {\r
-throw  new NullPointerException ();\r
-} else if (off < 0 || len < 0 || len > b.length - off) {\r
-throw  new IndexOutOfBoundsException ();\r
-} else if (len == 0) {\r
-return 0;\r
-} else if (this.eof) {\r
-return -1;\r
-}var n = 0;\r
-this.inflater.setOutput (b, off, len);\r
-while (!this.eof) {\r
-if (this.inflater.avail_in == 0) this.fill ();\r
-var err = this.inflater.inflate (0);\r
-n += this.inflater.next_out_index - off;\r
-off = this.inflater.next_out_index;\r
-switch (err) {\r
-case -3:\r
-throw  new java.io.IOException (this.inflater.msg);\r
-case 1:\r
-case 2:\r
-this.eof = true;\r
-if (err == 2) return -1;\r
-break;\r
-default:\r
-}\r
-if (this.inflater.avail_out == 0) break;\r
-}\r
-return n;\r
-}, "~A,~N,~N");\r
-Clazz.overrideMethod (c$, "available", \r
-function () {\r
-if (this.closed) {\r
-throw  new java.io.IOException ("Stream closed");\r
-}return (this.eof ? 0 : 1);\r
-});\r
-Clazz.overrideMethod (c$, "skip", \r
-function (n) {\r
-if (n < 0) {\r
-throw  new IllegalArgumentException ("negative skip length");\r
-}if (this.closed) {\r
-throw  new java.io.IOException ("Stream closed");\r
-}var max = Math.min (n, 2147483647);\r
-var total = 0;\r
-while (total < max) {\r
-var len = max - total;\r
-if (len > this.b.length) {\r
-len = this.b.length;\r
-}len = this.read (this.b, 0, len);\r
-if (len == -1) {\r
-this.eof = true;\r
-break;\r
-}total += len;\r
-}\r
-return total;\r
-}, "~N");\r
-Clazz.overrideMethod (c$, "close", \r
-function () {\r
-if (!this.closed) {\r
-if (this.myinflater) this.inflater.end ();\r
-if (this.close_in) this.$in.close ();\r
-this.closed = true;\r
-}});\r
-Clazz.defineMethod (c$, "fill", \r
-function () {\r
-if (this.closed) {\r
-throw  new java.io.IOException ("Stream closed");\r
-}this.len = this.$in.read (this.buf, 0, this.buf.length);\r
-if (this.len == -1) {\r
-if (this.inflater.istate.wrap == 0 && !this.inflater.finished ()) {\r
-this.buf[0] = 0;\r
-this.len = 1;\r
-} else if (this.inflater.istate.was != -1) {\r
-throw  new java.io.IOException ("footer is not found");\r
-} else {\r
-throw  new java.io.EOFException ("Unexpected end of ZLIB input stream");\r
-}}this.inflater.setInput (this.buf, 0, this.len, true);\r
-});\r
-Clazz.overrideMethod (c$, "markSupported", \r
-function () {\r
-return false;\r
-});\r
-Clazz.overrideMethod (c$, "mark", \r
-function (readlimit) {\r
-}, "~N");\r
-Clazz.overrideMethod (c$, "reset", \r
-function () {\r
-throw  new java.io.IOException ("mark/reset not supported");\r
-});\r
-Clazz.defineMethod (c$, "getTotalIn", \r
-function () {\r
-return this.inflater.getTotalIn ();\r
-});\r
-Clazz.defineMethod (c$, "getTotalOut", \r
-function () {\r
-return this.inflater.getTotalOut ();\r
-});\r
-Clazz.defineMethod (c$, "getAvailIn", \r
-function () {\r
-if (this.inflater.avail_in <= 0) return null;\r
-var tmp =  Clazz.newByteArray (this.inflater.avail_in, 0);\r
-System.arraycopy (this.inflater.next_in, this.inflater.next_in_index, tmp, 0, this.inflater.avail_in);\r
-return tmp;\r
-});\r
-Clazz.defineMethod (c$, "readHeader", \r
-function () {\r
-var empty = "".getBytes ();\r
-this.inflater.setInput (empty, 0, 0, false);\r
-this.inflater.setOutput (empty, 0, 0);\r
-var err = this.inflater.inflate (0);\r
-if (!this.inflater.istate.inParsingHeader ()) {\r
-return;\r
-}var b1 =  Clazz.newByteArray (1, 0);\r
-do {\r
-var i = this.$in.read (b1, 0, 1);\r
-if (i <= 0) throw  new java.io.IOException ("no input");\r
-this.inflater.setInput (b1, 0, b1.length, false);\r
-err = this.inflater.inflate (0);\r
-if (err != 0) throw  new java.io.IOException (this.inflater.msg);\r
-} while (this.inflater.istate.inParsingHeader ());\r
-});\r
-Clazz.defineMethod (c$, "getInflater", \r
-function () {\r
-return this.inflater;\r
-});\r
-Clazz.defineStatics (c$,\r
-"DEFAULT_BUFSIZE", 512);\r
-});\r
+Clazz.declarePackage ("JU");
+Clazz.load (["java.io.FilterInputStream"], "JU.InflaterInputStream", ["java.io.EOFException", "$.IOException", "java.lang.IllegalArgumentException", "$.IndexOutOfBoundsException", "$.NullPointerException"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.inflater = null;
+this.buf = null;
+this.len = 0;
+this.closed = false;
+this.eof = false;
+this.close_in = true;
+this.myinflater = false;
+this.byte1 = null;
+this.b = null;
+Clazz.instantialize (this, arguments);
+}, JU, "InflaterInputStream", java.io.FilterInputStream);
+Clazz.prepareFields (c$, function () {
+this.byte1 =  Clazz.newByteArray (1, 0);
+this.b =  Clazz.newByteArray (512, 0);
+});
+Clazz.makeConstructor (c$, 
+function ($in, inflater, size, close_in) {
+Clazz.superConstructor (this, JU.InflaterInputStream, [$in]);
+this.inflater = inflater;
+this.buf =  Clazz.newByteArray (size, 0);
+this.close_in = close_in;
+}, "java.io.InputStream,JU.Inflater,~N,~B");
+Clazz.overrideMethod (c$, "readByteAsInt", 
+function () {
+if (this.closed) {
+throw  new java.io.IOException ("Stream closed");
+}return this.read (this.byte1, 0, 1) == -1 ? -1 : this.byte1[0] & 0xff;
+});
+Clazz.overrideMethod (c$, "read", 
+function (b, off, len) {
+return this.readInf (b, off, len);
+}, "~A,~N,~N");
+Clazz.defineMethod (c$, "readInf", 
+function (b, off, len) {
+if (this.closed) {
+throw  new java.io.IOException ("Stream closed");
+}if (b == null) {
+throw  new NullPointerException ();
+} else if (off < 0 || len < 0 || len > b.length - off) {
+throw  new IndexOutOfBoundsException ();
+} else if (len == 0) {
+return 0;
+} else if (this.eof) {
+return -1;
+}var n = 0;
+this.inflater.setOutput (b, off, len);
+while (!this.eof) {
+if (this.inflater.avail_in == 0) this.fill ();
+var err = this.inflater.inflate (0);
+n += this.inflater.next_out_index - off;
+off = this.inflater.next_out_index;
+switch (err) {
+case -3:
+throw  new java.io.IOException (this.inflater.msg);
+case 1:
+case 2:
+this.eof = true;
+if (err == 2) return -1;
+break;
+default:
+}
+if (this.inflater.avail_out == 0) break;
+}
+return n;
+}, "~A,~N,~N");
+Clazz.overrideMethod (c$, "available", 
+function () {
+if (this.closed) {
+throw  new java.io.IOException ("Stream closed");
+}return (this.eof ? 0 : 1);
+});
+Clazz.overrideMethod (c$, "skip", 
+function (n) {
+if (n < 0) {
+throw  new IllegalArgumentException ("negative skip length");
+}if (this.closed) {
+throw  new java.io.IOException ("Stream closed");
+}var max = Math.min (n, 2147483647);
+var total = 0;
+while (total < max) {
+var len = max - total;
+if (len > this.b.length) {
+len = this.b.length;
+}len = this.read (this.b, 0, len);
+if (len == -1) {
+this.eof = true;
+break;
+}total += len;
+}
+return total;
+}, "~N");
+Clazz.overrideMethod (c$, "close", 
+function () {
+if (!this.closed) {
+if (this.myinflater) this.inflater.end ();
+if (this.close_in) this.$in.close ();
+this.closed = true;
+}});
+Clazz.defineMethod (c$, "fill", 
+function () {
+if (this.closed) {
+throw  new java.io.IOException ("Stream closed");
+}this.len = this.$in.read (this.buf, 0, this.buf.length);
+if (this.len == -1) {
+if (this.inflater.istate.wrap == 0 && !this.inflater.finished ()) {
+this.buf[0] = 0;
+this.len = 1;
+} else if (this.inflater.istate.was != -1) {
+throw  new java.io.IOException ("footer is not found");
+} else {
+throw  new java.io.EOFException ("Unexpected end of ZLIB input stream");
+}}this.inflater.setInput (this.buf, 0, this.len, true);
+});
+Clazz.overrideMethod (c$, "markSupported", 
+function () {
+return false;
+});
+Clazz.overrideMethod (c$, "mark", 
+function (readlimit) {
+}, "~N");
+Clazz.overrideMethod (c$, "reset", 
+function () {
+throw  new java.io.IOException ("mark/reset not supported");
+});
+Clazz.defineMethod (c$, "getTotalIn", 
+function () {
+return this.inflater.getTotalIn ();
+});
+Clazz.defineMethod (c$, "getTotalOut", 
+function () {
+return this.inflater.getTotalOut ();
+});
+Clazz.defineMethod (c$, "getAvailIn", 
+function () {
+if (this.inflater.avail_in <= 0) return null;
+var tmp =  Clazz.newByteArray (this.inflater.avail_in, 0);
+System.arraycopy (this.inflater.next_in, this.inflater.next_in_index, tmp, 0, this.inflater.avail_in);
+return tmp;
+});
+Clazz.defineMethod (c$, "readHeader", 
+function () {
+var empty = "".getBytes ();
+this.inflater.setInput (empty, 0, 0, false);
+this.inflater.setOutput (empty, 0, 0);
+var err = this.inflater.inflate (0);
+if (!this.inflater.istate.inParsingHeader ()) {
+return;
+}var b1 =  Clazz.newByteArray (1, 0);
+do {
+var i = this.$in.read (b1, 0, 1);
+if (i <= 0) throw  new java.io.IOException ("no input");
+this.inflater.setInput (b1, 0, b1.length, false);
+err = this.inflater.inflate (0);
+if (err != 0) throw  new java.io.IOException (this.inflater.msg);
+} while (this.inflater.istate.inParsingHeader ());
+});
+Clazz.defineMethod (c$, "getInflater", 
+function () {
+return this.inflater;
+});
+Clazz.defineStatics (c$,
+"DEFAULT_BUFSIZE", 512);
+});