JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / io / CharArrayReader.js
1 Clazz.load(["java.io.Reader"],"java.io.CharArrayReader",["java.io.IOException","java.lang.ArrayIndexOutOfBoundsException","$.IllegalArgumentException"],function(){\r
2 c$=Clazz.decorateAsClass(function(){\r
3 this.buf=null;\r
4 this.pos=0;\r
5 this.markedPos=-1;\r
6 this.count=0;\r
7 Clazz.instantialize(this,arguments);\r
8 },java.io,"CharArrayReader",java.io.Reader);\r
9 Clazz.makeConstructor(c$,\r
10 function(buf){\r
11 Clazz.superConstructor(this,java.io.CharArrayReader,[buf]);\r
12 this.buf=buf;\r
13 this.count=buf.length;\r
14 },"~A");\r
15 Clazz.makeConstructor(c$,\r
16 function(buf,offset,length){\r
17 Clazz.superConstructor(this,java.io.CharArrayReader,[buf]);\r
18 if(0<=offset&&offset<=buf.length&&length>=0){\r
19 this.buf=buf;\r
20 this.pos=offset;\r
21 this.count=this.pos+length<buf.length?length:buf.length;\r
22 }else{\r
23 throw new IllegalArgumentException();\r
24 }},"~A,~N,~N");\r
25 Clazz.overrideMethod(c$,"close",\r
26 function(){\r
27 {\r
28 if(this.isOpen()){\r
29 this.buf=null;\r
30 }}});\r
31 Clazz.defineMethod(c$,"isOpen",\r
32 ($fz=function(){\r
33 return this.buf!=null;\r
34 },$fz.isPrivate=true,$fz));\r
35 Clazz.overrideMethod(c$,"mark",\r
36 function(readLimit){\r
37 {\r
38 if(this.isOpen()){\r
39 this.markedPos=this.pos;\r
40 }else{\r
41 throw new java.io.IOException(("K0060"));\r
42 }}},"~N");\r
43 Clazz.overrideMethod(c$,"markSupported",\r
44 function(){\r
45 return true;\r
46 });\r
47 Clazz.defineMethod(c$,"read",\r
48 function(){\r
49 {\r
50 if(this.isOpen()){\r
51 if(this.pos!=this.count){\r
52 return this.buf[this.pos++];\r
53 }return-1;\r
54 }throw new java.io.IOException(("K0060"));\r
55 }});\r
56 Clazz.defineMethod(c$,"read",\r
57 function(buffer,offset,len){\r
58 if(0<=offset&&offset<=buffer.length&&0<=len&&len<=buffer.length-offset){\r
59 {\r
60 if(this.isOpen()){\r
61 if(this.pos<this.count){\r
62 var bytesRead=this.pos+len>this.count?this.count-this.pos:len;\r
63 System.arraycopy(this.buf,this.pos,buffer,offset,bytesRead);\r
64 this.pos+=bytesRead;\r
65 return bytesRead;\r
66 }return-1;\r
67 }throw new java.io.IOException(("K0060"));\r
68 }}throw new ArrayIndexOutOfBoundsException();\r
69 },"~A,~N,~N");\r
70 Clazz.overrideMethod(c$,"ready",\r
71 function(){\r
72 {\r
73 if(this.isOpen()){\r
74 return this.pos!=this.count;\r
75 }throw new java.io.IOException(("K0060"));\r
76 }});\r
77 Clazz.overrideMethod(c$,"reset",\r
78 function(){\r
79 {\r
80 if(this.isOpen()){\r
81 this.pos=this.markedPos!=-1?this.markedPos:0;\r
82 }else{\r
83 throw new java.io.IOException(("K0060"));\r
84 }}});\r
85 Clazz.overrideMethod(c$,"skip",\r
86 function(n){\r
87 {\r
88 if(this.isOpen()){\r
89 if(n<=0){\r
90 return 0;\r
91 }var skipped=0;\r
92 if(n<this.count-this.pos){\r
93 this.pos=this.pos+n;\r
94 skipped=n;\r
95 }else{\r
96 skipped=this.count-this.pos;\r
97 this.pos=this.count;\r
98 }return skipped;\r
99 }throw new java.io.IOException(("K0060"));\r
100 }},"~N");\r
101 });\r