1 Clazz.declarePackage ("JU");
2 Clazz.load (null, "JU.ZStream", ["JU.Adler32"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.next_in_index = 0;
9 this.next_out_index = 0;
17 Clazz.instantialize (this, arguments);
19 Clazz.defineMethod (c$, "setAdler32",
21 this.checksum = new JU.Adler32 ();
23 Clazz.defineMethod (c$, "inflate",
25 if (this.istate == null) return -2;
26 return this.istate.inflate (f);
28 Clazz.defineMethod (c$, "deflate",
30 if (this.dstate == null) {
32 }return this.dstate.deflate (flush);
34 Clazz.defineMethod (c$, "flush_pending",
36 var len = this.dstate.pending;
37 if (len > this.avail_out) len = this.avail_out;
39 System.arraycopy (this.dstate.pending_buf, this.dstate.pending_out, this.next_out, this.next_out_index, len);
40 this.next_out_index += len;
41 this.dstate.pending_out += len;
42 this.total_out += len;
43 this.avail_out -= len;
44 this.dstate.pending -= len;
45 if (this.dstate.pending == 0) {
46 this.dstate.pending_out = 0;
48 Clazz.defineMethod (c$, "read_buf",
49 function (buf, start, size) {
50 var len = this.avail_in;
51 if (len > size) len = size;
52 if (len == 0) return 0;
54 if (this.dstate.wrap != 0) {
55 this.checksum.update (this.next_in, this.next_in_index, len);
56 }System.arraycopy (this.next_in, this.next_in_index, buf, start, len);
57 this.next_in_index += len;
61 Clazz.defineMethod (c$, "getAdler",
63 return this.checksum.getValue ();
65 Clazz.defineMethod (c$, "free",
71 Clazz.defineMethod (c$, "setOutput",
72 function (buf, off, len) {
74 this.next_out_index = off;
77 Clazz.defineMethod (c$, "setInput",
78 function (buf, off, len, append) {
79 if (len <= 0 && append && this.next_in != null) return;
80 if (this.avail_in > 0 && append) {
81 var tmp = Clazz.newByteArray (this.avail_in + len, 0);
82 System.arraycopy (this.next_in, this.next_in_index, tmp, 0, this.avail_in);
83 System.arraycopy (buf, off, tmp, this.avail_in, len);
85 this.next_in_index = 0;
89 this.next_in_index = off;
92 Clazz.defineMethod (c$, "getAvailIn",
96 Clazz.defineMethod (c$, "getTotalOut",
98 return this.total_out;
100 Clazz.defineMethod (c$, "getTotalIn",
102 return this.total_in;
104 c$.getBytes = Clazz.defineMethod (c$, "getBytes",
108 for (var i = 0; i < s.length;i++) {
109 var pt = s.charCodeAt(i);
112 } else if (pt <= 0x7FF) {
113 x.push(0xC0|((pt>>6)&0x1F));
114 x.push(0x80|(pt&0x3F));
115 } else if (pt <= 0xFFFF) {
116 x.push(0xE0|((pt>>12)&0xF));
117 x.push(0x80|((pt>>6)&0x3F));
118 x.push(0x80|(pt&0x3F));
123 return (Int32Array != Array ? new Int32Array(x) : x);
125 Clazz.defineStatics (c$,
126 "Z_STREAM_ERROR", -2);