1 Clazz.declarePackage ("JU");
2 Clazz.load (["java.io.FilterOutputStream"], "JU.DeflaterOutputStream", ["java.io.IOException", "java.lang.IndexOutOfBoundsException"], function () {
3 c$ = Clazz.decorateAsClass (function () {
7 this.syncFlush = false;
9 this.mydeflater = false;
10 this.close_out = true;
11 Clazz.instantialize (this, arguments);
12 }, JU, "DeflaterOutputStream", java.io.FilterOutputStream);
13 Clazz.prepareFields (c$, function () {
14 this.buf1 = Clazz.newByteArray (1, 0);
16 Clazz.defineMethod (c$, "jzSetDOS",
17 function (out, deflater, size, close_out) {
19 if (size == 0) size = 512;
20 this.deflater = deflater;
21 this.buffer = Clazz.newByteArray (size, 0);
22 this.close_out = close_out;
23 }, "java.io.OutputStream,JU.Deflater,~N,~B");
24 Clazz.overrideMethod (c$, "writeByteAsInt",
26 this.buf1[0] = (b & 0xff);
27 this.write (this.buf1, 0, 1);
29 Clazz.defineMethod (c$, "write",
30 function (b, off, len) {
31 if (this.deflater.finished ()) throw new java.io.IOException ("finished");
32 if ( new Boolean ( new Boolean (off < 0 | len < 0).valueOf () | off + len > b.length).valueOf ()) throw new IndexOutOfBoundsException ();
34 var flush = this.syncFlush ? 2 : 0;
35 this.deflater.setInput (b, off, len, true);
36 while (this.deflater.avail_in > 0) {
37 var err = this.deflate (flush);
41 Clazz.defineMethod (c$, "finish",
43 while (!this.deflater.finished ()) {
47 Clazz.overrideMethod (c$, "close",
51 if (this.mydeflater) {
53 }if (this.close_out) this.out.close ();
56 Clazz.defineMethod (c$, "deflate",
58 this.deflater.setOutput (this.buffer, 0, this.buffer.length);
59 var err = this.deflater.deflate (flush);
65 if (this.deflater.avail_in <= 0 && flush != 4) {
68 throw new java.io.IOException ("failed to deflate");
70 var len = this.deflater.next_out_index;
72 this.out.write (this.buffer, 0, len);
75 Clazz.overrideMethod (c$, "flush",
77 if (this.syncFlush && !this.deflater.finished ()) {
79 var err = this.deflate (2);
80 if (this.deflater.next_out_index < this.buffer.length) break;
85 Clazz.defineMethod (c$, "getTotalIn",
87 return this.deflater.getTotalIn ();
89 Clazz.defineMethod (c$, "getTotalOut",
91 return this.deflater.getTotalOut ();
93 Clazz.defineMethod (c$, "setSyncFlush",
94 function (syncFlush) {
95 this.syncFlush = syncFlush;
97 Clazz.defineMethod (c$, "getSyncFlush",
99 return this.syncFlush;
101 Clazz.defineMethod (c$, "getDeflater",
103 return this.deflater;
105 Clazz.defineStatics (c$,
106 "DEFAULT_BUFSIZE", 512);