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