JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / io / CharArrayWriter.js
1 Clazz.load(["java.io.Writer"],"java.io.CharArrayWriter",["java.lang.IllegalArgumentException","$.IndexOutOfBoundsException","$.NullPointerException","$.StringIndexOutOfBoundsException"],function(){\r
2 c$=Clazz.decorateAsClass(function(){\r
3 this.buf=null;\r
4 this.count=0;\r
5 Clazz.instantialize(this,arguments);\r
6 },java.io,"CharArrayWriter",java.io.Writer);\r
7 Clazz.makeConstructor(c$,\r
8 function(){\r
9 Clazz.superConstructor(this,java.io.CharArrayWriter);\r
10 this.buf=Clazz.newArray(32,'\0');\r
11 this.lock=this.buf;\r
12 });\r
13 Clazz.makeConstructor(c$,\r
14 function(initialSize){\r
15 Clazz.superConstructor(this,java.io.CharArrayWriter);\r
16 if(initialSize>=0){\r
17 this.buf=Clazz.newArray(initialSize,'\0');\r
18 this.lock=this.buf;\r
19 }else{\r
20 throw new IllegalArgumentException(("K005e"));\r
21 }},"~N");\r
22 Clazz.overrideMethod(c$,"close",\r
23 function(){\r
24 });\r
25 Clazz.defineMethod(c$,"expand",\r
26 ($fz=function(i){\r
27 if(this.count+i<=this.buf.length){\r
28 return;\r
29 }var newbuf=Clazz.newArray(this.buf.length+(2*i),'\0');\r
30 System.arraycopy(this.buf,0,newbuf,0,this.count);\r
31 this.buf=newbuf;\r
32 },$fz.isPrivate=true,$fz),"~N");\r
33 Clazz.overrideMethod(c$,"flush",\r
34 function(){\r
35 });\r
36 Clazz.defineMethod(c$,"reset",\r
37 function(){\r
38 {\r
39 this.count=0;\r
40 }});\r
41 Clazz.defineMethod(c$,"size",\r
42 function(){\r
43 {\r
44 return this.count;\r
45 }});\r
46 Clazz.defineMethod(c$,"toCharArray",\r
47 function(){\r
48 {\r
49 var result=Clazz.newArray(this.count,'\0');\r
50 System.arraycopy(this.buf,0,result,0,this.count);\r
51 return result;\r
52 }});\r
53 Clazz.overrideMethod(c$,"toString",\r
54 function(){\r
55 {\r
56 return String.instantialize(this.buf,0,this.count);\r
57 }});\r
58 Clazz.defineMethod(c$,"write",\r
59 function(c,offset,len){\r
60 if(0<=offset&&offset<=c.length&&0<=len&&len<=c.length-offset){\r
61 {\r
62 this.expand(len);\r
63 System.arraycopy(c,offset,this.buf,this.count,len);\r
64 this.count+=len;\r
65 }}else{\r
66 throw new IndexOutOfBoundsException();\r
67 }},"~A,~N,~N");\r
68 Clazz.defineMethod(c$,"write",\r
69 function(oneChar){\r
70 {\r
71 this.expand(1);\r
72 this.buf[this.count++]=String.fromCharCode(oneChar);\r
73 }},"~N");\r
74 Clazz.defineMethod(c$,"write",\r
75 function(str,offset,len){\r
76 if(str==null){\r
77 throw new NullPointerException(("K0047"));\r
78 }if(0<=offset&&offset<=str.length&&0<=len&&len<=str.length-offset){\r
79 {\r
80 this.expand(len);\r
81 str.getChars(offset,offset+len,this.buf,this.count);\r
82 this.count+=len;\r
83 }}else{\r
84 throw new StringIndexOutOfBoundsException();\r
85 }},"~S,~N,~N");\r
86 Clazz.defineMethod(c$,"writeTo",\r
87 function(out){\r
88 {\r
89 out.write(this.buf,0,this.count);\r
90 }},"java.io.Writer");\r
91 Clazz.defineMethod(c$,"append",\r
92 function(c){\r
93 this.write(c.charCodeAt(0));\r
94 return this;\r
95 },"~N");\r
96 Clazz.defineMethod(c$,"append",\r
97 function(csq){\r
98 if(null==csq){\r
99 this.append("null",0,"null".length);\r
100 }else{\r
101 this.append(csq,0,csq.length());\r
102 }return this;\r
103 },"CharSequence");\r
104 Clazz.defineMethod(c$,"append",\r
105 function(csq,start,end){\r
106 if(null==csq){\r
107 csq="null";\r
108 }var output=csq.subSequence(start,end).toString();\r
109 this.write(output,0,output.length);\r
110 return this;\r
111 },"CharSequence,~N,~N");\r
112 });\r