Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / io / BufferedInputStream.js
index be66e70..26b104e 100644 (file)
-Clazz.load (["java.io.FilterInputStream"], "java.io.BufferedInputStream", ["java.io.IOException", "java.lang.IndexOutOfBoundsException"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.buf = null;\r
-this.count = 0;\r
-this.pos = 0;\r
-this.markpos = -1;\r
-this.marklimit = 0;\r
-Clazz.instantialize (this, arguments);\r
-}, java.io, "BufferedInputStream", java.io.FilterInputStream);\r
-Clazz.defineMethod (c$, "getInIfOpen", \r
- function () {\r
-var input = this.$in;\r
-if (input == null) throw  new java.io.IOException ("Stream closed");\r
-return input;\r
-});\r
-Clazz.defineMethod (c$, "getBufIfOpen", \r
- function () {\r
-var buffer = this.buf;\r
-if (buffer == null) throw  new java.io.IOException ("Stream closed");\r
-return buffer;\r
-});\r
-Clazz.overrideMethod (c$, "resetStream", \r
-function () {\r
-});\r
-Clazz.makeConstructor (c$, \r
-function ($in) {\r
-Clazz.superConstructor (this, java.io.BufferedInputStream, [$in]);\r
-this.buf =  Clazz.newByteArray (8192, 0);\r
-}, "java.io.InputStream");\r
-Clazz.defineMethod (c$, "fill", \r
- function () {\r
-var buffer = this.getBufIfOpen ();\r
-if (this.markpos < 0) this.pos = 0;\r
- else if (this.pos >= buffer.length) if (this.markpos > 0) {\r
-var sz = this.pos - this.markpos;\r
-System.arraycopy (buffer, this.markpos, buffer, 0, sz);\r
-this.pos = sz;\r
-this.markpos = 0;\r
-} else if (buffer.length >= this.marklimit) {\r
-this.markpos = -1;\r
-this.pos = 0;\r
-} else {\r
-var nsz = this.pos * 2;\r
-if (nsz > this.marklimit) nsz = this.marklimit;\r
-var nbuf =  Clazz.newByteArray (nsz, 0);\r
-System.arraycopy (buffer, 0, nbuf, 0, this.pos);\r
-buffer = this.buf = nbuf;\r
-}this.count = this.pos;\r
-var n = this.getInIfOpen ().read (buffer, this.pos, buffer.length - this.pos);\r
-if (n > 0) this.count = n + this.pos;\r
-});\r
-Clazz.overrideMethod (c$, "readByteAsInt", \r
-function () {\r
-if (this.pos >= this.count) {\r
-this.fill ();\r
-if (this.pos >= this.count) return -1;\r
-}return this.getBufIfOpen ()[this.pos++] & 0xff;\r
-});\r
-Clazz.defineMethod (c$, "read1", \r
- function (b, off, len) {\r
-var avail = this.count - this.pos;\r
-if (avail <= 0) {\r
-if (len >= this.getBufIfOpen ().length && this.markpos < 0) {\r
-return this.getInIfOpen ().read (b, off, len);\r
-}this.fill ();\r
-avail = this.count - this.pos;\r
-if (avail <= 0) return -1;\r
-}var cnt = (avail < len) ? avail : len;\r
-System.arraycopy (this.getBufIfOpen (), this.pos, b, off, cnt);\r
-this.pos += cnt;\r
-return cnt;\r
-}, "~A,~N,~N");\r
-Clazz.overrideMethod (c$, "read", \r
-function (b, off, len) {\r
-if (arguments.length == 1) {\r
-  off = 0;\r
-  len  = b.length;\r
-}\r
-this.getBufIfOpen ();\r
-if ((off | len | (off + len) | (b.length - (off + len))) < 0) {\r
-throw  new IndexOutOfBoundsException ();\r
-} else if (len == 0) {\r
-return 0;\r
-}var n = 0;\r
-for (; ; ) {\r
-var nread = this.read1 (b, off + n, len - n);\r
-if (nread <= 0) return (n == 0) ? nread : n;\r
-n += nread;\r
-if (n >= len) return n;\r
-var input = this.$in;\r
-if (input != null && input.available () <= 0) return n;\r
-}\r
-}, "~A,~N,~N");\r
-Clazz.overrideMethod (c$, "skip", \r
-function (n) {\r
-this.getBufIfOpen ();\r
-if (n <= 0) {\r
-return 0;\r
-}var avail = this.count - this.pos;\r
-if (avail <= 0) {\r
-if (this.markpos < 0) return this.getInIfOpen ().skip (n);\r
-this.fill ();\r
-avail = this.count - this.pos;\r
-if (avail <= 0) return 0;\r
-}var skipped = (avail < n) ? avail : n;\r
-this.pos += skipped;\r
-return skipped;\r
-}, "~N");\r
-Clazz.overrideMethod (c$, "available", \r
-function () {\r
-var n = this.count - this.pos;\r
-var avail = this.getInIfOpen ().available ();\r
-return n > (2147483647 - avail) ? 2147483647 : n + avail;\r
-});\r
-Clazz.overrideMethod (c$, "mark", \r
-function (readlimit) {\r
-this.marklimit = readlimit;\r
-this.markpos = this.pos;\r
-}, "~N");\r
-Clazz.overrideMethod (c$, "reset", \r
-function () {\r
-this.getBufIfOpen ();\r
-if (this.markpos < 0) throw  new java.io.IOException ("Resetting to invalid mark");\r
-this.pos = this.markpos;\r
-});\r
-Clazz.overrideMethod (c$, "markSupported", \r
-function () {\r
-return true;\r
-});\r
-Clazz.overrideMethod (c$, "close", \r
-function () {\r
-var input = this.$in;\r
-this.$in = null;\r
-if (input != null) input.close ();\r
-return;\r
-});\r
-Clazz.defineStatics (c$,\r
-"DEFAULT_BUFFER_SIZE", 8192);\r
-});\r
+Clazz.load (["java.io.FilterInputStream"], "java.io.BufferedInputStream", ["java.io.IOException", "java.lang.IndexOutOfBoundsException"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.buf = null;
+this.count = 0;
+this.pos = 0;
+this.markpos = -1;
+this.marklimit = 0;
+Clazz.instantialize (this, arguments);
+}, java.io, "BufferedInputStream", java.io.FilterInputStream);
+Clazz.defineMethod (c$, "getInIfOpen", 
+ function () {
+var input = this.$in;
+if (input == null) throw  new java.io.IOException ("Stream closed");
+return input;
+});
+Clazz.defineMethod (c$, "getBufIfOpen", 
+ function () {
+var buffer = this.buf;
+if (buffer == null) throw  new java.io.IOException ("Stream closed");
+return buffer;
+});
+Clazz.overrideMethod (c$, "resetStream", 
+function () {
+});
+Clazz.makeConstructor (c$, 
+function ($in) {
+Clazz.superConstructor (this, java.io.BufferedInputStream, [$in]);
+this.buf =  Clazz.newByteArray (8192, 0);
+}, "java.io.InputStream");
+Clazz.defineMethod (c$, "fill", 
+ function () {
+var buffer = this.getBufIfOpen ();
+if (this.markpos < 0) this.pos = 0;
+ else if (this.pos >= buffer.length) if (this.markpos > 0) {
+var sz = this.pos - this.markpos;
+System.arraycopy (buffer, this.markpos, buffer, 0, sz);
+this.pos = sz;
+this.markpos = 0;
+} else if (buffer.length >= this.marklimit) {
+this.markpos = -1;
+this.pos = 0;
+} else {
+var nsz = this.pos * 2;
+if (nsz > this.marklimit) nsz = this.marklimit;
+var nbuf =  Clazz.newByteArray (nsz, 0);
+System.arraycopy (buffer, 0, nbuf, 0, this.pos);
+buffer = this.buf = nbuf;
+}this.count = this.pos;
+var n = this.getInIfOpen ().read (buffer, this.pos, buffer.length - this.pos);
+if (n > 0) this.count = n + this.pos;
+});
+Clazz.overrideMethod (c$, "readByteAsInt", 
+function () {
+if (this.pos >= this.count) {
+this.fill ();
+if (this.pos >= this.count) return -1;
+}return this.getBufIfOpen ()[this.pos++] & 0xff;
+});
+Clazz.defineMethod (c$, "read1", 
+ function (b, off, len) {
+var avail = this.count - this.pos;
+if (avail <= 0) {
+if (len >= this.getBufIfOpen ().length && this.markpos < 0) {
+return this.getInIfOpen ().read (b, off, len);
+}this.fill ();
+avail = this.count - this.pos;
+if (avail <= 0) return -1;
+}var cnt = (avail < len) ? avail : len;
+System.arraycopy (this.getBufIfOpen (), this.pos, b, off, cnt);
+this.pos += cnt;
+return cnt;
+}, "~A,~N,~N");
+Clazz.overrideMethod (c$, "read", 
+function (b, off, len) {
+if (arguments.length == 1) {
+  off = 0;
+  len  = b.length;
+}
+this.getBufIfOpen ();
+if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
+throw  new IndexOutOfBoundsException ();
+} else if (len == 0) {
+return 0;
+}var n = 0;
+for (; ; ) {
+var nread = this.read1 (b, off + n, len - n);
+if (nread <= 0) return (n == 0) ? nread : n;
+n += nread;
+if (n >= len) return n;
+var input = this.$in;
+if (input != null && input.available () <= 0) return n;
+}
+}, "~A,~N,~N");
+Clazz.overrideMethod (c$, "skip", 
+function (n) {
+this.getBufIfOpen ();
+if (n <= 0) {
+return 0;
+}var avail = this.count - this.pos;
+if (avail <= 0) {
+if (this.markpos < 0) return this.getInIfOpen ().skip (n);
+this.fill ();
+avail = this.count - this.pos;
+if (avail <= 0) return 0;
+}var skipped = (avail < n) ? avail : n;
+this.pos += skipped;
+return skipped;
+}, "~N");
+Clazz.overrideMethod (c$, "available", 
+function () {
+var n = this.count - this.pos;
+var avail = this.getInIfOpen ().available ();
+return n > (2147483647 - avail) ? 2147483647 : n + avail;
+});
+Clazz.overrideMethod (c$, "mark", 
+function (readlimit) {
+this.marklimit = readlimit;
+this.markpos = this.pos;
+}, "~N");
+Clazz.overrideMethod (c$, "reset", 
+function () {
+this.getBufIfOpen ();
+if (this.markpos < 0) throw  new java.io.IOException ("Resetting to invalid mark");
+this.pos = this.markpos;
+});
+Clazz.overrideMethod (c$, "markSupported", 
+function () {
+return true;
+});
+Clazz.overrideMethod (c$, "close", 
+function () {
+var input = this.$in;
+this.$in = null;
+if (input != null) input.close ();
+return;
+});
+Clazz.defineStatics (c$,
+"DEFAULT_BUFFER_SIZE", 8192);
+});