Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / io / StringBufferInputStream.js
1 Clazz.load(["java.io.InputStream"],"java.io.StringBufferInputStream",["java.lang.ArrayIndexOutOfBoundsException","$.NullPointerException"],function(){
2 c$=Clazz.decorateAsClass(function(){
3 this.buffer=null;
4 this.count=0;
5 this.pos=0;
6 Clazz.instantialize(this,arguments);
7 },java.io,"StringBufferInputStream",java.io.InputStream);
8 Clazz.makeConstructor(c$,
9 function(str){
10 Clazz.superConstructor(this,java.io.StringBufferInputStream,[]);
11 if(str!=null){
12 this.buffer=str;
13 this.count=str.length;
14 }else{
15 throw new NullPointerException();
16 }},"~S");
17 Clazz.overrideMethod(c$,"available",
18 function(){
19 return this.count-this.pos;
20 });
21 Clazz.defineMethod(c$,"read",
22 function(){
23 return this.pos<this.count?(this.buffer.charAt(this.pos++)).charCodeAt(0)&0xFF:-1;
24 });
25 Clazz.defineMethod(c$,"read",
26 function(b,offset,length){
27 if(this.pos>=this.count){
28 return-1;
29 }if(b!=null){
30 if(0<=offset&&offset<=b.length&&0<=length&&length<=b.length-offset){
31 if(length==0){
32 return 0;
33 }var copylen=this.count-this.pos<length?this.count-this.pos:length;
34 for(var i=0;i<copylen;i++){
35 b[offset+i]=(this.buffer.charAt(this.pos+i)).charCodeAt(0);
36 }
37 this.pos+=copylen;
38 return copylen;
39 }throw new ArrayIndexOutOfBoundsException();
40 }throw new NullPointerException(("K0047"));
41 },"~A,~N,~N");
42 Clazz.overrideMethod(c$,"reset",
43 function(){
44 this.pos=0;
45 });
46 Clazz.overrideMethod(c$,"skip",
47 function(n){
48 if(n<=0){
49 return 0;
50 }var numskipped;
51 if(this.count-this.pos<n){
52 numskipped=this.count-this.pos;
53 this.pos=this.count;
54 }else{
55 numskipped=n;
56 this.pos+=n;
57 }return numskipped;
58 },"~N");
59 });