Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / JU / Deflater.js
1 Clazz.declarePackage ("JU");
2 Clazz.load (["JU.ZStream"], "JU.Deflater", ["JU.Deflate"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.$finished = false;
5 Clazz.instantialize (this, arguments);
6 }, JU, "Deflater", JU.ZStream);
7 Clazz.defineMethod (c$, "init", 
8 function (level, bits, nowrap) {
9 if (bits == 0) bits = 15;
10 this.$finished = false;
11 this.setAdler32 ();
12 this.dstate =  new JU.Deflate (this);
13 this.dstate.deflateInit2 (level, nowrap ? -bits : bits);
14 return this;
15 }, "~N,~N,~B");
16 Clazz.overrideMethod (c$, "deflate", 
17 function (flush) {
18 if (this.dstate == null) {
19 return -2;
20 }var ret = this.dstate.deflate (flush);
21 if (ret == 1) this.$finished = true;
22 return ret;
23 }, "~N");
24 Clazz.overrideMethod (c$, "end", 
25 function () {
26 this.$finished = true;
27 if (this.dstate == null) return -2;
28 var ret = this.dstate.deflateEnd ();
29 this.dstate = null;
30 this.free ();
31 return ret;
32 });
33 Clazz.defineMethod (c$, "params", 
34 function (level, strategy) {
35 if (this.dstate == null) return -2;
36 return this.dstate.deflateParams (level, strategy);
37 }, "~N,~N");
38 Clazz.defineMethod (c$, "setDictionary", 
39 function (dictionary, dictLength) {
40 if (this.dstate == null) return -2;
41 return this.dstate.deflateSetDictionary (dictionary, dictLength);
42 }, "~A,~N");
43 Clazz.overrideMethod (c$, "finished", 
44 function () {
45 return this.$finished;
46 });
47 Clazz.defineMethod (c$, "finish", 
48 function () {
49 });
50 Clazz.defineMethod (c$, "getBytesRead", 
51 function () {
52 return this.dstate.getBytesRead ();
53 });
54 Clazz.defineMethod (c$, "getBytesWritten", 
55 function () {
56 return this.dstate.getBytesWritten ();
57 });
58 Clazz.defineStatics (c$,
59 "MAX_WBITS", 15,
60 "Z_STREAM_END", 1,
61 "$Z_STREAM_ERROR", -2);
62 });