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