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