JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / util / zip / ZipEntry.js
1 Clazz.declarePackage ("java.util.zip");\r
2 Clazz.load (["java.util.zip.ZipConstants"], "java.util.zip.ZipEntry", ["java.lang.IllegalArgumentException", "$.InternalError", "$.NullPointerException", "java.util.Date"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.offset = 0;\r
5 this.name = null;\r
6 this.time = -1;\r
7 this.crc = -1;\r
8 this.size = -1;\r
9 this.csize = -1;\r
10 this.method = -1;\r
11 this.flag = 0;\r
12 this.extra = null;\r
13 this.comment = null;\r
14 Clazz.instantialize (this, arguments);\r
15 }, java.util.zip, "ZipEntry", null, [java.util.zip.ZipConstants, Cloneable]);\r
16 Clazz.makeConstructor (c$, \r
17 function (name) {\r
18 if (name == null) {\r
19 throw  new NullPointerException ();\r
20 }if (name.length > 0xFFFF) {\r
21 throw  new IllegalArgumentException ("entry name too long");\r
22 }this.name = name;\r
23 }, "~S");\r
24 Clazz.defineMethod (c$, "getName", \r
25 function () {\r
26 return this.name;\r
27 });\r
28 Clazz.defineMethod (c$, "setTime", \r
29 function (time) {\r
30 this.time = java.util.zip.ZipEntry.javaToDosTime (time);\r
31 }, "~N");\r
32 Clazz.defineMethod (c$, "getTime", \r
33 function () {\r
34 return this.time != -1 ? java.util.zip.ZipEntry.dosToJavaTime (this.time) : -1;\r
35 });\r
36 Clazz.defineMethod (c$, "setSize", \r
37 function (size) {\r
38 if (size < 0) {\r
39 throw  new IllegalArgumentException ("invalid entry size");\r
40 }this.size = size;\r
41 }, "~N");\r
42 Clazz.defineMethod (c$, "getSize", \r
43 function () {\r
44 return this.size;\r
45 });\r
46 Clazz.defineMethod (c$, "getCompressedSize", \r
47 function () {\r
48 return this.csize;\r
49 });\r
50 Clazz.defineMethod (c$, "setCompressedSize", \r
51 function (csize) {\r
52 this.csize = csize;\r
53 }, "~N");\r
54 Clazz.defineMethod (c$, "setCrc", \r
55 function (crc) {\r
56 if (crc < 0 || crc > 0xFFFFFFFF) {\r
57 throw  new IllegalArgumentException ("invalid entry crc-32");\r
58 }this.crc = crc;\r
59 }, "~N");\r
60 Clazz.defineMethod (c$, "getCrc", \r
61 function () {\r
62 return this.crc;\r
63 });\r
64 Clazz.defineMethod (c$, "setMethod", \r
65 function (method) {\r
66 if (method != 0 && method != 8) {\r
67 throw  new IllegalArgumentException ("invalid compression method");\r
68 }this.method = method;\r
69 }, "~N");\r
70 Clazz.defineMethod (c$, "getMethod", \r
71 function () {\r
72 return this.method;\r
73 });\r
74 Clazz.defineMethod (c$, "setExtra", \r
75 function (extra) {\r
76 if (extra != null && extra.length > 0xFFFF) {\r
77 throw  new IllegalArgumentException ("invalid extra field length");\r
78 }this.extra = extra;\r
79 }, "~A");\r
80 Clazz.defineMethod (c$, "getExtra", \r
81 function () {\r
82 return this.extra;\r
83 });\r
84 Clazz.defineMethod (c$, "setComment", \r
85 function (comment) {\r
86 this.comment = comment;\r
87 }, "~S");\r
88 Clazz.defineMethod (c$, "getComment", \r
89 function () {\r
90 return this.comment;\r
91 });\r
92 Clazz.defineMethod (c$, "isDirectory", \r
93 function () {\r
94 return this.name.endsWith ("/");\r
95 });\r
96 Clazz.overrideMethod (c$, "toString", \r
97 function () {\r
98 return this.getName ();\r
99 });\r
100 c$.dosToJavaTime = Clazz.defineMethod (c$, "dosToJavaTime", \r
101  function (dtime) {\r
102 var d =  new java.util.Date ((((dtime >> 25) & 0x7f) + 80), (((dtime >> 21) & 0x0f) - 1), ((dtime >> 16) & 0x1f), ((dtime >> 11) & 0x1f), ((dtime >> 5) & 0x3f), ((dtime << 1) & 0x3e));\r
103 return d.getTime ();\r
104 }, "~N");\r
105 c$.javaToDosTime = Clazz.defineMethod (c$, "javaToDosTime", \r
106  function (time) {\r
107 var d =  new java.util.Date (time);\r
108 var year = d.getYear () + 1900;\r
109 if (year < 1980) {\r
110 return 2162688;\r
111 }return (year - 1980) << 25 | (d.getMonth () + 1) << 21 | d.getDate () << 16 | d.getHours () << 11 | d.getMinutes () << 5 | d.getSeconds () >> 1;\r
112 }, "~N");\r
113 Clazz.overrideMethod (c$, "hashCode", \r
114 function () {\r
115 return this.name.hashCode ();\r
116 });\r
117 Clazz.defineMethod (c$, "clone", \r
118 function () {\r
119 try {\r
120 var e = Clazz.superCall (this, java.util.zip.ZipEntry, "clone", []);\r
121 if (this.extra != null) {\r
122 e.extra =  Clazz.newByteArray (this.extra.length, 0);\r
123 System.arraycopy (this.extra, 0, e.extra, 0, this.extra.length);\r
124 }return e;\r
125 } catch (e) {\r
126 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {\r
127 throw  new InternalError ();\r
128 } else {\r
129 throw e;\r
130 }\r
131 }\r
132 });\r
133 Clazz.defineStatics (c$,\r
134 "STORED", 0,\r
135 "DEFLATED", 8);\r
136 });\r