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