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