Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / io / SequenceInputStream.js
1 \feffClazz.load (["java.io.InputStream"], "java.io.SequenceInputStream", ["java.lang.Error", "$.IndexOutOfBoundsException", "$.NullPointerException", "java.util.Vector"], function () {
2 c$ = Clazz.decorateAsClass (function () {
3 this.e = null;
4 this.$in = null;
5 Clazz.instantialize (this, arguments);
6 }, java.io, "SequenceInputStream", java.io.InputStream);
7 Clazz.makeConstructor (c$, 
8 function (e) {
9 Clazz.superConstructor (this, java.io.SequenceInputStream, []);
10 this.e = e;
11 try {
12 this.nextStream ();
13 } catch (ex) {
14 if (Clazz.exceptionOf (ex, java.io.IOException)) {
15 throw  new Error ("panic");
16 } else {
17 throw ex;
18 }
19 }
20 }, "java.util.Enumeration");
21 Clazz.makeConstructor (c$, 
22 function (s1, s2) {
23 Clazz.superConstructor (this, java.io.SequenceInputStream, []);
24 var v =  new java.util.Vector (2);
25 v.addElement (s1);
26 v.addElement (s2);
27 this.e = v.elements ();
28 try {
29 this.nextStream ();
30 } catch (ex) {
31 if (Clazz.exceptionOf (ex, java.io.IOException)) {
32 throw  new Error ("panic");
33 } else {
34 throw ex;
35 }
36 }
37 }, "java.io.InputStream,java.io.InputStream");
38 Clazz.defineMethod (c$, "nextStream", 
39 function () {
40 if (this.$in != null) {
41 this.$in.close ();
42 }if (this.e.hasMoreElements ()) {
43 this.$in = this.e.nextElement ();
44 if (this.$in == null) throw  new NullPointerException ();
45 } else this.$in = null;
46 });
47 Clazz.defineMethod (c$, "available", 
48 function () {
49 if (this.$in == null) {
50 return 0;
51 }return this.$in.available ();
52 });
53 Clazz.defineMethod (c$, "readByteAsInt", 
54 function () {
55 if (this.$in == null) {
56 return -1;
57 }var c = this.$in.readByteAsInt ();
58 if (c == -1) {
59 this.nextStream ();
60 return this.readByteAsInt ();
61 }return c;
62 });
63 Clazz.defineMethod (c$, "read", 
64 function (b, off, len) {
65 if (this.$in == null) {
66 return -1;
67 } else if (b == null) {
68 throw  new NullPointerException ();
69 } else if (off < 0 || len < 0 || len > b.length - off) {
70 throw  new IndexOutOfBoundsException ();
71 } else if (len == 0) {
72 return 0;
73 }var n = this.$in.read (b, off, len);
74 if (n <= 0) {
75 this.nextStream ();
76 return this.read (b, off, len);
77 }return n;
78 }, "~A,~N,~N");
79 Clazz.defineMethod (c$, "close", 
80 function () {
81 do {
82 this.nextStream ();
83 } while (this.$in != null);
84 });
85 });