Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / JU / GZIPHeader.js
1 Clazz.declarePackage ("JU");
2 Clazz.load (null, "JU.GZIPHeader", ["JU.ZStream", "java.lang.IllegalArgumentException", "$.InternalError"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.text = false;
5 this.fhcrc = false;
6 this.time = 0;
7 this.xflags = 0;
8 this.os = 255;
9 this.extra = null;
10 this.name = null;
11 this.comment = null;
12 this.hcrc = 0;
13 this.crc = 0;
14 this.done = false;
15 this.mtime = 0;
16 Clazz.instantialize (this, arguments);
17 }, JU, "GZIPHeader", null, Cloneable);
18 Clazz.defineMethod (c$, "setModifiedTime", 
19 function (mtime) {
20 this.mtime = mtime;
21 }, "~N");
22 Clazz.defineMethod (c$, "getModifiedTime", 
23 function () {
24 return this.mtime;
25 });
26 Clazz.defineMethod (c$, "setOS", 
27 function (os) {
28 if ((0 <= os && os <= 13) || os == 255) this.os = os;
29  else throw  new IllegalArgumentException ("os: " + os);
30 }, "~N");
31 Clazz.defineMethod (c$, "getOS", 
32 function () {
33 return this.os;
34 });
35 Clazz.defineMethod (c$, "setName", 
36 function (name) {
37 this.name = JU.ZStream.getBytes (name);
38 }, "~S");
39 Clazz.defineMethod (c$, "getName", 
40 function () {
41 if (this.name == null) return "";
42 try {
43 return  String.instantialize (this.name, "ISO-8859-1");
44 } catch (e) {
45 if (Clazz.exceptionOf (e, java.io.UnsupportedEncodingException)) {
46 throw  new InternalError (e.toString ());
47 } else {
48 throw e;
49 }
50 }
51 });
52 Clazz.defineMethod (c$, "setComment", 
53 function (comment) {
54 this.comment = JU.ZStream.getBytes (comment);
55 }, "~S");
56 Clazz.defineMethod (c$, "getComment", 
57 function () {
58 if (this.comment == null) return "";
59 try {
60 return  String.instantialize (this.comment, "ISO-8859-1");
61 } catch (e) {
62 if (Clazz.exceptionOf (e, java.io.UnsupportedEncodingException)) {
63 throw  new InternalError (e.toString ());
64 } else {
65 throw e;
66 }
67 }
68 });
69 Clazz.defineMethod (c$, "setCRC", 
70 function (crc) {
71 this.crc = crc;
72 }, "~N");
73 Clazz.defineMethod (c$, "getCRC", 
74 function () {
75 return this.crc;
76 });
77 Clazz.defineMethod (c$, "put", 
78 function (d) {
79 var flag = 0;
80 if (this.text) {
81 flag |= 1;
82 }if (this.fhcrc) {
83 flag |= 2;
84 }if (this.extra != null) {
85 flag |= 4;
86 }if (this.name != null) {
87 flag |= 8;
88 }if (this.comment != null) {
89 flag |= 16;
90 }var xfl = 0;
91 if (d.level == 1) {
92 xfl |= 4;
93 } else if (d.level == 9) {
94 xfl |= 2;
95 }d.put_short (0x8b1f);
96 d.put_byteB (8);
97 d.put_byteB (flag);
98 d.put_byteB (this.mtime);
99 d.put_byteB ((this.mtime >> 8));
100 d.put_byteB ((this.mtime >> 16));
101 d.put_byteB ((this.mtime >> 24));
102 d.put_byteB (xfl);
103 d.put_byteB (this.os);
104 if (this.extra != null) {
105 d.put_byteB (this.extra.length);
106 d.put_byteB ((this.extra.length >> 8));
107 d.put_byte (this.extra, 0, this.extra.length);
108 }if (this.name != null) {
109 d.put_byte (this.name, 0, this.name.length);
110 d.put_byteB (0);
111 }if (this.comment != null) {
112 d.put_byte (this.comment, 0, this.comment.length);
113 d.put_byteB (0);
114 }}, "JU.Deflate");
115 Clazz.defineMethod (c$, "clone", 
116 function () {
117 var gheader = Clazz.superCall (this, JU.GZIPHeader, "clone", []);
118 var tmp;
119 if (gheader.extra != null) {
120 tmp =  Clazz.newByteArray (gheader.extra.length, 0);
121 System.arraycopy (gheader.extra, 0, tmp, 0, tmp.length);
122 gheader.extra = tmp;
123 }if (gheader.name != null) {
124 tmp =  Clazz.newByteArray (gheader.name.length, 0);
125 System.arraycopy (gheader.name, 0, tmp, 0, tmp.length);
126 gheader.name = tmp;
127 }if (gheader.comment != null) {
128 tmp =  Clazz.newByteArray (gheader.comment.length, 0);
129 System.arraycopy (gheader.comment, 0, tmp, 0, tmp.length);
130 gheader.comment = tmp;
131 }return gheader;
132 });
133 Clazz.defineStatics (c$,
134 "OS_MSDOS", 0x00,
135 "OS_AMIGA", 0x01,
136 "OS_VMS", 0x02,
137 "OS_UNIX", 0x03,
138 "OS_ATARI", 0x05,
139 "OS_OS2", 0x06,
140 "OS_MACOS", 0x07,
141 "OS_TOPS20", 0x0a,
142 "OS_WIN32", 0x0b,
143 "OS_VMCMS", 0x04,
144 "OS_ZSYSTEM", 0x08,
145 "OS_CPM", 0x09,
146 "OS_QDOS", 0x0c,
147 "OS_RISCOS", 0x0d,
148 "OS_UNKNOWN", 0xff);
149 });