JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / javajs / util / LimitedLineReader.js
1 Clazz.declarePackage ("javajs.util");
2 c$ = Clazz.decorateAsClass (function () {
3 this.buf = null;
4 this.cchBuf = 0;
5 this.ichCurrent = 0;
6 Clazz.instantialize (this, arguments);
7 }, javajs.util, "LimitedLineReader");
8 Clazz.makeConstructor (c$, 
9 function (bufferedReader, readLimit) {
10 bufferedReader.mark (readLimit + 1);
11 this.buf =  Clazz.newCharArray (readLimit, '\0');
12 this.cchBuf = Math.max (bufferedReader.read (this.buf, 0, readLimit), 0);
13 this.ichCurrent = 0;
14 bufferedReader.reset ();
15 }, "java.io.BufferedReader,~N");
16 Clazz.defineMethod (c$, "getHeader", 
17 function (n) {
18 return (n == 0 ?  String.instantialize (this.buf) :  String.instantialize (this.buf, 0, Math.min (this.cchBuf, n)));
19 }, "~N");
20 Clazz.defineMethod (c$, "readLineWithNewline", 
21 function () {
22 while (this.ichCurrent < this.cchBuf) {
23 var ichBeginningOfLine = this.ichCurrent;
24 var ch = String.fromCharCode (0);
25 while (this.ichCurrent < this.cchBuf && (ch = this.buf[this.ichCurrent++]) != '\r' && ch != '\n') {
26 }
27 if (ch == '\r' && this.ichCurrent < this.cchBuf && this.buf[this.ichCurrent] == '\n') ++this.ichCurrent;
28 var cchLine = this.ichCurrent - ichBeginningOfLine;
29 if (this.buf[ichBeginningOfLine] == '#') continue;
30 return  String.instantialize (this.buf, ichBeginningOfLine, cchLine);
31 }
32 return "";
33 });