75e79dae86159a69c91e0bf7d61d173b0f27da75
[jalviewjs.git] / site / swingjs / j2s / java / util / zip / CheckedInputStream.js
1 Clazz.declarePackage ("java.util.zip");
2 Clazz.load (["java.io.FilterInputStream"], "java.util.zip.CheckedInputStream", null, function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.cksum = null;
5 Clazz.instantialize (this, arguments);
6 }, java.util.zip, "CheckedInputStream", java.io.FilterInputStream);
7 Clazz.defineMethod (c$, "set", 
8 function (cksum) {
9 this.$in = this.$in;
10 this.cksum = cksum;
11 return this;
12 }, "JU.Checksum");
13 Clazz.overrideMethod (c$, "readByteAsInt", 
14 function () {
15 var b = this.$in.readByteAsInt ();
16 if (b != -1) {
17 this.cksum.updateByteAsInt (b);
18 }return b;
19 });
20 Clazz.overrideMethod (c$, "read", 
21 function (buf, off, len) {
22 len = this.$in.read (buf, off, len);
23 if (len != -1) {
24 this.cksum.update (buf, off, len);
25 }return len;
26 }, "~A,~N,~N");
27 Clazz.overrideMethod (c$, "skip", 
28 function (n) {
29 var buf =  Clazz.newByteArray (512, 0);
30 var total = 0;
31 while (total < n) {
32 var len = n - total;
33 len = this.read (buf, 0, len < buf.length ? len : buf.length);
34 if (len == -1) {
35 return total;
36 }total += len;
37 }
38 return total;
39 }, "~N");
40 Clazz.defineMethod (c$, "getChecksum", 
41 function () {
42 return this.cksum;
43 });
44 });