Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / JU / DataReader.js
1 Clazz.declarePackage ("JU");
2 Clazz.load (["java.io.BufferedReader"], "JU.DataReader", ["java.io.StringReader"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.ptMark = 0;
5 Clazz.instantialize (this, arguments);
6 }, JU, "DataReader", java.io.BufferedReader);
7 Clazz.makeConstructor (c$, 
8 function () {
9 Clazz.superConstructor (this, JU.DataReader, [ new java.io.StringReader ("")]);
10 });
11 Clazz.defineMethod (c$, "getBufferedReader", 
12 function () {
13 return this;
14 });
15 Clazz.defineMethod (c$, "readBuf", 
16 function (buf, off, len) {
17 var nRead = 0;
18 var line = this.readLine ();
19 if (line == null) return 0;
20 var linept = 0;
21 var linelen = line.length;
22 for (var i = off; i < len && linelen >= 0; i++) {
23 if (linept >= linelen) {
24 linept = 0;
25 buf[i] = '\n';
26 line = this.readLine ();
27 linelen = (line == null ? -1 : line.length);
28 } else {
29 buf[i] = line.charAt (linept++);
30 }nRead++;
31 }
32 return nRead;
33 }, "~A,~N,~N");
34 });