JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / io / StringBufferInputStream.js
1 Clazz.load(["java.io.InputStream"],"java.io.StringBufferInputStream",["java.lang.ArrayIndexOutOfBoundsException","$.NullPointerException"],function(){\r
2 c$=Clazz.decorateAsClass(function(){\r
3 this.buffer=null;\r
4 this.count=0;\r
5 this.pos=0;\r
6 Clazz.instantialize(this,arguments);\r
7 },java.io,"StringBufferInputStream",java.io.InputStream);\r
8 Clazz.makeConstructor(c$,\r
9 function(str){\r
10 Clazz.superConstructor(this,java.io.StringBufferInputStream,[]);\r
11 if(str!=null){\r
12 this.buffer=str;\r
13 this.count=str.length;\r
14 }else{\r
15 throw new NullPointerException();\r
16 }},"~S");\r
17 Clazz.overrideMethod(c$,"available",\r
18 function(){\r
19 return this.count-this.pos;\r
20 });\r
21 Clazz.defineMethod(c$,"read",\r
22 function(){\r
23 return this.pos<this.count?(this.buffer.charAt(this.pos++)).charCodeAt(0)&0xFF:-1;\r
24 });\r
25 Clazz.defineMethod(c$,"read",\r
26 function(b,offset,length){\r
27 if(this.pos>=this.count){\r
28 return-1;\r
29 }if(b!=null){\r
30 if(0<=offset&&offset<=b.length&&0<=length&&length<=b.length-offset){\r
31 if(length==0){\r
32 return 0;\r
33 }var copylen=this.count-this.pos<length?this.count-this.pos:length;\r
34 for(var i=0;i<copylen;i++){\r
35 b[offset+i]=(this.buffer.charAt(this.pos+i)).charCodeAt(0);\r
36 }\r
37 this.pos+=copylen;\r
38 return copylen;\r
39 }throw new ArrayIndexOutOfBoundsException();\r
40 }throw new NullPointerException(("K0047"));\r
41 },"~A,~N,~N");\r
42 Clazz.overrideMethod(c$,"reset",\r
43 function(){\r
44 this.pos=0;\r
45 });\r
46 Clazz.overrideMethod(c$,"skip",\r
47 function(n){\r
48 if(n<=0){\r
49 return 0;\r
50 }var numskipped;\r
51 if(this.count-this.pos<n){\r
52 numskipped=this.count-this.pos;\r
53 this.pos=this.count;\r
54 }else{\r
55 numskipped=n;\r
56 this.pos+=n;\r
57 }return numskipped;\r
58 },"~N");\r
59 });\r