JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / io / StringWriter.js
1 Clazz.load(["java.io.Writer"],"java.io.StringWriter",["java.lang.IllegalArgumentException","$.IndexOutOfBoundsException","$.StringBuffer"],function(){\r
2 c$=Clazz.decorateAsClass(function(){\r
3 this.buf=null;\r
4 Clazz.instantialize(this,arguments);\r
5 },java.io,"StringWriter",java.io.Writer);\r
6 Clazz.makeConstructor(c$,\r
7 function(){\r
8 Clazz.superConstructor(this,java.io.StringWriter);\r
9 this.buf=new StringBuffer(16);\r
10 this.lock=this.buf;\r
11 });\r
12 Clazz.makeConstructor(c$,\r
13 function(initialSize){\r
14 Clazz.superConstructor(this,java.io.StringWriter,[]);\r
15 if(initialSize>=0){\r
16 this.buf=new StringBuffer(initialSize);\r
17 this.lock=this.buf;\r
18 }else{\r
19 throw new IllegalArgumentException();\r
20 }},"~N");\r
21 Clazz.overrideMethod(c$,"close",\r
22 function(){\r
23 });\r
24 Clazz.overrideMethod(c$,"flush",\r
25 function(){\r
26 });\r
27 Clazz.defineMethod(c$,"getBuffer",\r
28 function(){\r
29 {\r
30 return this.buf;\r
31 }});\r
32 Clazz.overrideMethod(c$,"toString",\r
33 function(){\r
34 {\r
35 return this.buf.toString();\r
36 }});\r
37 Clazz.defineMethod(c$,"write",\r
38 function(cbuf,offset,count){\r
39 if(0<=offset&&offset<=cbuf.length&&0<=count&&count<=cbuf.length-offset){\r
40 {\r
41 this.buf.append(cbuf,offset,count);\r
42 }}else{\r
43 throw new IndexOutOfBoundsException();\r
44 }},"~A,~N,~N");\r
45 Clazz.defineMethod(c$,"write",\r
46 function(oneChar){\r
47 {\r
48 this.buf.append(String.fromCharCode(oneChar));\r
49 }},"~N");\r
50 Clazz.defineMethod(c$,"write",\r
51 function(str){\r
52 {\r
53 this.buf.append(str);\r
54 }},"~S");\r
55 Clazz.defineMethod(c$,"write",\r
56 function(str,offset,count){\r
57 var sub=str.substring(offset,offset+count);\r
58 {\r
59 this.buf.append(sub);\r
60 }},"~S,~N,~N");\r
61 Clazz.defineMethod(c$,"append",\r
62 function(c){\r
63 this.write(c.charCodeAt(0));\r
64 return this;\r
65 },"~N");\r
66 Clazz.defineMethod(c$,"append",\r
67 function(csq){\r
68 if(null==csq){\r
69 this.append("null",0,"null".length);\r
70 }else{\r
71 this.append(csq,0,csq.length());\r
72 }return this;\r
73 },"CharSequence");\r
74 Clazz.defineMethod(c$,"append",\r
75 function(csq,start,end){\r
76 if(null==csq){\r
77 csq="null";\r
78 }var output=csq.subSequence(start,end).toString();\r
79 this.write(output,0,output.length);\r
80 return this;\r
81 },"CharSequence,~N,~N");\r
82 });\r