Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / io / BufferedReader.js
index 5204b68..e70ed87 100644 (file)
-Clazz.load (["java.io.Reader"], "java.io.BufferedReader", ["java.io.IOException", "java.lang.IllegalArgumentException", "$.IndexOutOfBoundsException", "JU.SB"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.$in = null;\r
-this.cb = null;\r
-this.nChars = 0;\r
-this.nextChar = 0;\r
-this.markedChar = -1;\r
-this.readAheadLimit = 0;\r
-this.skipLF = false;\r
-this.markedSkipLF = false;\r
-Clazz.instantialize (this, arguments);\r
-}, java.io, "BufferedReader", java.io.Reader);\r
-Clazz.defineMethod (c$, "setSize", \r
- function (sz) {\r
-if (sz <= 0) throw  new IllegalArgumentException ("Buffer size <= 0");\r
-this.cb =  Clazz.newCharArray (sz, '\0');\r
-this.nextChar = this.nChars = 0;\r
-}, "~N");\r
-Clazz.makeConstructor (c$, \r
-function ($in) {\r
-Clazz.superConstructor (this, java.io.BufferedReader, [$in]);\r
-this.$in = $in;\r
-this.setSize (8192);\r
-}, "java.io.Reader");\r
-Clazz.defineMethod (c$, "ensureOpen", \r
- function () {\r
-if (this.$in == null) throw  new java.io.IOException ("Stream closed");\r
-});\r
-Clazz.defineMethod (c$, "fill", \r
- function () {\r
-var dst;\r
-if (this.markedChar <= -1) {\r
-dst = 0;\r
-} else {\r
-var delta = this.nextChar - this.markedChar;\r
-if (delta >= this.readAheadLimit) {\r
-this.markedChar = -2;\r
-this.readAheadLimit = 0;\r
-dst = 0;\r
-} else {\r
-if (this.readAheadLimit <= this.cb.length) {\r
-System.arraycopy (this.cb, this.markedChar, this.cb, 0, delta);\r
-this.markedChar = 0;\r
-dst = delta;\r
-} else {\r
-var ncb =  Clazz.newCharArray (this.readAheadLimit, '\0');\r
-System.arraycopy (this.cb, this.markedChar, ncb, 0, delta);\r
-this.cb = ncb;\r
-this.markedChar = 0;\r
-dst = delta;\r
-}this.nextChar = this.nChars = delta;\r
-}}var n;\r
-do {\r
-n = this.$in.read (this.cb, dst, this.cb.length - dst);\r
-} while (n == 0);\r
-if (n > 0) {\r
-this.nChars = dst + n;\r
-this.nextChar = dst;\r
-}});\r
-Clazz.defineMethod (c$, "read1", \r
- function (cbuf, off, len) {\r
-if (this.nextChar >= this.nChars) {\r
-if (len >= this.cb.length && this.markedChar <= -1 && !this.skipLF) {\r
-return this.$in.read (cbuf, off, len);\r
-}this.fill ();\r
-}if (this.nextChar >= this.nChars) return -1;\r
-if (this.skipLF) {\r
-this.skipLF = false;\r
-if (this.cb[this.nextChar] == '\n') {\r
-this.nextChar++;\r
-if (this.nextChar >= this.nChars) this.fill ();\r
-if (this.nextChar >= this.nChars) return -1;\r
-}}var n = Math.min (len, this.nChars - this.nextChar);\r
-System.arraycopy (this.cb, this.nextChar, cbuf, off, n);\r
-this.nextChar += n;\r
-return n;\r
-}, "~A,~N,~N");\r
-Clazz.defineMethod (c$, "read", \r
-function (cbuf, off, len) {\r
-{\r
-this.ensureOpen ();\r
-if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) {\r
-throw  new IndexOutOfBoundsException ();\r
-} else if (len == 0) {\r
-return 0;\r
-}var n = this.read1 (cbuf, off, len);\r
-if (n <= 0) return n;\r
-while ((n < len) && this.$in.ready ()) {\r
-var n1 = this.read1 (cbuf, off + n, len - n);\r
-if (n1 <= 0) break;\r
-n += n1;\r
-}\r
-return n;\r
-}}, "~A,~N,~N");\r
-Clazz.defineMethod (c$, "readLine1", \r
- function (ignoreLF) {\r
-var s = null;\r
-var startChar;\r
-{\r
-this.ensureOpen ();\r
-var omitLF = ignoreLF || this.skipLF;\r
-for (; ; ) {\r
-if (this.nextChar >= this.nChars) this.fill ();\r
-if (this.nextChar >= this.nChars) {\r
-if (s != null && s.length () > 0) return s.toString ();\r
-return null;\r
-}var eol = false;\r
-var c = String.fromCharCode (0);\r
-var i;\r
-if (omitLF && (this.cb[this.nextChar] == '\n')) this.nextChar++;\r
-this.skipLF = false;\r
-omitLF = false;\r
-charLoop : for (i = this.nextChar; i < this.nChars; i++) {\r
-c = this.cb[i];\r
-if ((c == '\n') || (c == '\r')) {\r
-eol = true;\r
-break charLoop;\r
-}}\r
-startChar = this.nextChar;\r
-this.nextChar = i;\r
-if (eol) {\r
-var str;\r
-if (s == null) {\r
-str =  String.instantialize (this.cb, startChar, i - startChar);\r
-} else {\r
-s.appendCB (this.cb, startChar, i - startChar);\r
-str = s.toString ();\r
-}this.nextChar++;\r
-if (c == '\r') {\r
-this.skipLF = true;\r
-}return str;\r
-}if (s == null) s = JU.SB.newN (80);\r
-s.appendCB (this.cb, startChar, i - startChar);\r
-}\r
-}}, "~B");\r
-Clazz.defineMethod (c$, "readLine", \r
-function () {\r
-return this.readLine1 (false);\r
-});\r
-Clazz.overrideMethod (c$, "skip", \r
-function (n) {\r
-if (n < 0) {\r
-throw  new IllegalArgumentException ("skip value is negative");\r
-}{\r
-this.ensureOpen ();\r
-var r = n;\r
-while (r > 0) {\r
-if (this.nextChar >= this.nChars) this.fill ();\r
-if (this.nextChar >= this.nChars) break;\r
-if (this.skipLF) {\r
-this.skipLF = false;\r
-if (this.cb[this.nextChar] == '\n') {\r
-this.nextChar++;\r
-}}var d = this.nChars - this.nextChar;\r
-if (r <= d) {\r
-this.nextChar += r;\r
-r = 0;\r
-break;\r
-}r -= d;\r
-this.nextChar = this.nChars;\r
-}\r
-return n - r;\r
-}}, "~N");\r
-Clazz.defineMethod (c$, "ready", \r
-function () {\r
-{\r
-this.ensureOpen ();\r
-if (this.skipLF) {\r
-if (this.nextChar >= this.nChars && this.$in.ready ()) {\r
-this.fill ();\r
-}if (this.nextChar < this.nChars) {\r
-if (this.cb[this.nextChar] == '\n') this.nextChar++;\r
-this.skipLF = false;\r
-}}return (this.nextChar < this.nChars) || this.$in.ready ();\r
-}});\r
-Clazz.overrideMethod (c$, "markSupported", \r
-function () {\r
-return true;\r
-});\r
-Clazz.overrideMethod (c$, "mark", \r
-function (readAheadLimit) {\r
-if (readAheadLimit < 0) {\r
-throw  new IllegalArgumentException ("Read-ahead limit < 0");\r
-}{\r
-this.ensureOpen ();\r
-this.readAheadLimit = readAheadLimit;\r
-this.markedChar = this.nextChar;\r
-this.markedSkipLF = this.skipLF;\r
-}}, "~N");\r
-Clazz.overrideMethod (c$, "reset", \r
-function () {\r
-{\r
-this.ensureOpen ();\r
-if (this.markedChar < 0) throw  new java.io.IOException ((this.markedChar == -2) ? "Mark invalid" : "Stream not marked");\r
-this.nextChar = this.markedChar;\r
-this.skipLF = this.markedSkipLF;\r
-}});\r
-Clazz.defineMethod (c$, "close", \r
-function () {\r
-{\r
-if (this.$in == null) return;\r
-this.$in.close ();\r
-this.$in = null;\r
-this.cb = null;\r
-}});\r
-Clazz.defineStatics (c$,\r
-"INVALIDATED", -2,\r
-"UNMARKED", -1,\r
-"DEFAULT_CHAR_BUFFER_SIZE", 8192,\r
-"DEFAULT_EXPECTED_LINE_LENGTH", 80);\r
-});\r
+Clazz.load (["java.io.Reader"], "java.io.BufferedReader", ["java.io.IOException", "java.lang.IllegalArgumentException", "$.IndexOutOfBoundsException", "JU.SB"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.$in = null;
+this.cb = null;
+this.nChars = 0;
+this.nextChar = 0;
+this.markedChar = -1;
+this.readAheadLimit = 0;
+this.skipLF = false;
+this.markedSkipLF = false;
+Clazz.instantialize (this, arguments);
+}, java.io, "BufferedReader", java.io.Reader);
+Clazz.defineMethod (c$, "setSize", 
+ function (sz) {
+if (sz <= 0) throw  new IllegalArgumentException ("Buffer size <= 0");
+this.cb =  Clazz.newCharArray (sz, '\0');
+this.nextChar = this.nChars = 0;
+}, "~N");
+Clazz.makeConstructor (c$, 
+function ($in) {
+Clazz.superConstructor (this, java.io.BufferedReader, [$in]);
+this.$in = $in;
+this.setSize (8192);
+}, "java.io.Reader");
+Clazz.defineMethod (c$, "ensureOpen", 
+ function () {
+if (this.$in == null) throw  new java.io.IOException ("Stream closed");
+});
+Clazz.defineMethod (c$, "fill", 
+ function () {
+var dst;
+if (this.markedChar <= -1) {
+dst = 0;
+} else {
+var delta = this.nextChar - this.markedChar;
+if (delta >= this.readAheadLimit) {
+this.markedChar = -2;
+this.readAheadLimit = 0;
+dst = 0;
+} else {
+if (this.readAheadLimit <= this.cb.length) {
+System.arraycopy (this.cb, this.markedChar, this.cb, 0, delta);
+this.markedChar = 0;
+dst = delta;
+} else {
+var ncb =  Clazz.newCharArray (this.readAheadLimit, '\0');
+System.arraycopy (this.cb, this.markedChar, ncb, 0, delta);
+this.cb = ncb;
+this.markedChar = 0;
+dst = delta;
+}this.nextChar = this.nChars = delta;
+}}var n;
+do {
+n = this.$in.read (this.cb, dst, this.cb.length - dst);
+} while (n == 0);
+if (n > 0) {
+this.nChars = dst + n;
+this.nextChar = dst;
+}});
+Clazz.defineMethod (c$, "read1", 
+ function (cbuf, off, len) {
+if (this.nextChar >= this.nChars) {
+if (len >= this.cb.length && this.markedChar <= -1 && !this.skipLF) {
+return this.$in.read (cbuf, off, len);
+}this.fill ();
+}if (this.nextChar >= this.nChars) return -1;
+if (this.skipLF) {
+this.skipLF = false;
+if (this.cb[this.nextChar] == '\n') {
+this.nextChar++;
+if (this.nextChar >= this.nChars) this.fill ();
+if (this.nextChar >= this.nChars) return -1;
+}}var n = Math.min (len, this.nChars - this.nextChar);
+System.arraycopy (this.cb, this.nextChar, cbuf, off, n);
+this.nextChar += n;
+return n;
+}, "~A,~N,~N");
+Clazz.defineMethod (c$, "read", 
+function (cbuf, off, len) {
+{
+this.ensureOpen ();
+if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) {
+throw  new IndexOutOfBoundsException ();
+} else if (len == 0) {
+return 0;
+}var n = this.read1 (cbuf, off, len);
+if (n <= 0) return n;
+while ((n < len) && this.$in.ready ()) {
+var n1 = this.read1 (cbuf, off + n, len - n);
+if (n1 <= 0) break;
+n += n1;
+}
+return n;
+}}, "~A,~N,~N");
+Clazz.defineMethod (c$, "readLine1", 
+ function (ignoreLF) {
+var s = null;
+var startChar;
+{
+this.ensureOpen ();
+var omitLF = ignoreLF || this.skipLF;
+for (; ; ) {
+if (this.nextChar >= this.nChars) this.fill ();
+if (this.nextChar >= this.nChars) {
+if (s != null && s.length () > 0) return s.toString ();
+return null;
+}var eol = false;
+var c = String.fromCharCode (0);
+var i;
+if (omitLF && (this.cb[this.nextChar] == '\n')) this.nextChar++;
+this.skipLF = false;
+omitLF = false;
+charLoop : for (i = this.nextChar; i < this.nChars; i++) {
+c = this.cb[i];
+if ((c == '\n') || (c == '\r')) {
+eol = true;
+break charLoop;
+}}
+startChar = this.nextChar;
+this.nextChar = i;
+if (eol) {
+var str;
+if (s == null) {
+str =  String.instantialize (this.cb, startChar, i - startChar);
+} else {
+s.appendCB (this.cb, startChar, i - startChar);
+str = s.toString ();
+}this.nextChar++;
+if (c == '\r') {
+this.skipLF = true;
+}return str;
+}if (s == null) s = JU.SB.newN (80);
+s.appendCB (this.cb, startChar, i - startChar);
+}
+}}, "~B");
+Clazz.defineMethod (c$, "readLine", 
+function () {
+return this.readLine1 (false);
+});
+Clazz.overrideMethod (c$, "skip", 
+function (n) {
+if (n < 0) {
+throw  new IllegalArgumentException ("skip value is negative");
+}{
+this.ensureOpen ();
+var r = n;
+while (r > 0) {
+if (this.nextChar >= this.nChars) this.fill ();
+if (this.nextChar >= this.nChars) break;
+if (this.skipLF) {
+this.skipLF = false;
+if (this.cb[this.nextChar] == '\n') {
+this.nextChar++;
+}}var d = this.nChars - this.nextChar;
+if (r <= d) {
+this.nextChar += r;
+r = 0;
+break;
+}r -= d;
+this.nextChar = this.nChars;
+}
+return n - r;
+}}, "~N");
+Clazz.defineMethod (c$, "ready", 
+function () {
+{
+this.ensureOpen ();
+if (this.skipLF) {
+if (this.nextChar >= this.nChars && this.$in.ready ()) {
+this.fill ();
+}if (this.nextChar < this.nChars) {
+if (this.cb[this.nextChar] == '\n') this.nextChar++;
+this.skipLF = false;
+}}return (this.nextChar < this.nChars) || this.$in.ready ();
+}});
+Clazz.overrideMethod (c$, "markSupported", 
+function () {
+return true;
+});
+Clazz.overrideMethod (c$, "mark", 
+function (readAheadLimit) {
+if (readAheadLimit < 0) {
+throw  new IllegalArgumentException ("Read-ahead limit < 0");
+}{
+this.ensureOpen ();
+this.readAheadLimit = readAheadLimit;
+this.markedChar = this.nextChar;
+this.markedSkipLF = this.skipLF;
+}}, "~N");
+Clazz.overrideMethod (c$, "reset", 
+function () {
+{
+this.ensureOpen ();
+if (this.markedChar < 0) throw  new java.io.IOException ((this.markedChar == -2) ? "Mark invalid" : "Stream not marked");
+this.nextChar = this.markedChar;
+this.skipLF = this.markedSkipLF;
+}});
+Clazz.defineMethod (c$, "close", 
+function () {
+{
+if (this.$in == null) return;
+this.$in.close ();
+this.$in = null;
+this.cb = null;
+}});
+Clazz.defineStatics (c$,
+"INVALIDATED", -2,
+"UNMARKED", -1,
+"DEFAULT_CHAR_BUFFER_SIZE", 8192,
+"DEFAULT_EXPECTED_LINE_LENGTH", 80);
+});