1 Clazz.declarePackage ("javajs.util");
\r
2 Clazz.load (["javajs.api.GenericBinaryDocument", "javajs.util.BC"], "javajs.util.BinaryDocument", ["java.io.DataInputStream", "java.lang.Double"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
5 this.isRandom = false;
\r
6 this.isBigEndian = true;
\r
11 Clazz.instantialize (this, arguments);
\r
12 }, javajs.util, "BinaryDocument", javajs.util.BC, javajs.api.GenericBinaryDocument);
\r
13 Clazz.prepareFields (c$, function () {
\r
14 this.t8 = Clazz.newByteArray (8, 0);
\r
16 Clazz.overrideMethod (c$, "close",
\r
18 if (this.stream != null) try {
\r
19 this.stream.close ();
\r
21 if (Clazz.exceptionOf (e, Exception)) {
\r
26 if (this.out != null) this.out.closeChannel ();
\r
28 Clazz.overrideMethod (c$, "setStream",
\r
29 function (jzt, bis, isBigEndian) {
\r
30 if (jzt != null) this.jzt = jzt;
\r
31 if (bis != null) this.stream = new java.io.DataInputStream (bis);
\r
32 this.isBigEndian = isBigEndian;
\r
33 }, "javajs.api.GenericZipTools,java.io.BufferedInputStream,~B");
\r
34 Clazz.overrideMethod (c$, "setStreamData",
\r
35 function (stream, isBigEndian) {
\r
36 if (stream != null) this.stream = stream;
\r
37 this.isBigEndian = isBigEndian;
\r
38 }, "java.io.DataInputStream,~B");
\r
39 Clazz.defineMethod (c$, "setRandom",
\r
43 Clazz.overrideMethod (c$, "readByte",
\r
46 return this.ioReadByte ();
\r
48 Clazz.defineMethod (c$, "ioReadByte",
\r
49 ($fz = function () {
\r
50 var b = this.stream.readByte ();
\r
51 if (this.out != null) this.out.writeByteAsInt (b);
\r
53 }, $fz.isPrivate = true, $fz));
\r
54 Clazz.overrideMethod (c$, "readByteArray",
\r
55 function (b, off, len) {
\r
56 var n = this.ioRead (b, off, len);
\r
60 Clazz.defineMethod (c$, "ioRead",
\r
61 ($fz = function (b, off, len) {
\r
64 var n = this.stream.read (b, off, len);
\r
66 if (n > 0 && this.out != null) this.writeBytes (b, off, n);
\r
67 if (n >= len) break;
\r
72 }, $fz.isPrivate = true, $fz), "~A,~N,~N");
\r
73 Clazz.defineMethod (c$, "writeBytes",
\r
74 function (b, off, n) {
\r
75 this.out.write (b, off, n);
\r
77 Clazz.overrideMethod (c$, "readString",
\r
79 var temp = Clazz.newByteArray (nChar, 0);
\r
80 var n = this.readByteArray (temp, 0, nChar);
\r
81 return String.instantialize (temp, 0, n, "UTF-8");
\r
83 Clazz.overrideMethod (c$, "readShort",
\r
86 var n = (this.isBigEndian ? this.ioReadShort () : ((this.ioReadByte () & 0xff) | (this.ioReadByte () & 0xff) << 8));
\r
88 return (n > 0x7FFF ? n - 0x10000 : n);
\r
90 Clazz.defineMethod (c$, "ioReadShort",
\r
91 ($fz = function () {
\r
92 var b = this.stream.readShort ();
\r
93 if (this.out != null) this.writeShort (b);
\r
95 }, $fz.isPrivate = true, $fz));
\r
96 Clazz.defineMethod (c$, "writeShort",
\r
98 this.out.writeByteAsInt (i >> 8);
\r
99 this.out.writeByteAsInt (i);
\r
101 Clazz.overrideMethod (c$, "readIntLE",
\r
104 return this.readLEInt ();
\r
106 Clazz.overrideMethod (c$, "readInt",
\r
109 return (this.isBigEndian ? this.ioReadInt () : this.readLEInt ());
\r
111 Clazz.defineMethod (c$, "ioReadInt",
\r
112 ($fz = function () {
\r
113 var i = this.stream.readInt ();
\r
114 if (this.out != null) this.writeInt (i);
\r
116 }, $fz.isPrivate = true, $fz));
\r
117 Clazz.defineMethod (c$, "writeInt",
\r
119 this.out.writeByteAsInt (i >> 24);
\r
120 this.out.writeByteAsInt (i >> 16);
\r
121 this.out.writeByteAsInt (i >> 8);
\r
122 this.out.writeByteAsInt (i);
\r
124 Clazz.overrideMethod (c$, "swapBytesI",
\r
126 return (((n >> 24) & 0xff) | ((n >> 16) & 0xff) << 8 | ((n >> 8) & 0xff) << 16 | (n & 0xff) << 24);
\r
128 Clazz.overrideMethod (c$, "swapBytesS",
\r
130 return ((((n >> 8) & 0xff) | (n & 0xff) << 8));
\r
132 Clazz.overrideMethod (c$, "readUnsignedShort",
\r
135 var a = (this.ioReadByte () & 0xff);
\r
136 var b = (this.ioReadByte () & 0xff);
\r
137 return (this.isBigEndian ? (a << 8) + b : (b << 8) + a);
\r
139 Clazz.overrideMethod (c$, "readLong",
\r
142 return (this.isBigEndian ? this.ioReadLong () : (((this.ioReadByte ()) & 0xff) | ((this.ioReadByte ()) & 0xff) << 8 | ((this.ioReadByte ()) & 0xff) << 16 | ((this.ioReadByte ()) & 0xff) << 24 | ((this.ioReadByte ()) & 0xff) << 32 | ((this.ioReadByte ()) & 0xff) << 40 | ((this.ioReadByte ()) & 0xff) << 48 | ((this.ioReadByte ()) & 0xff) << 54));
\r
144 Clazz.defineMethod (c$, "ioReadLong",
\r
145 ($fz = function () {
\r
146 var b = this.stream.readLong ();
\r
147 if (this.out != null) this.writeLong (b);
\r
149 }, $fz.isPrivate = true, $fz));
\r
150 Clazz.defineMethod (c$, "writeLong",
\r
152 this.writeInt (((b >> 32) & 0xFFFFFFFF));
\r
153 this.writeInt ((b & 0xFFFFFFFF));
\r
155 Clazz.defineMethod (c$, "readLEInt",
\r
156 ($fz = function () {
\r
157 this.ioRead (this.t8, 0, 4);
\r
158 return javajs.util.BC.bytesToInt (this.t8, 0, false);
\r
159 }, $fz.isPrivate = true, $fz));
\r
160 Clazz.overrideMethod (c$, "readFloat",
\r
162 return javajs.util.BC.intToFloat (this.readInt ());
\r
164 Clazz.overrideMethod (c$, "readDouble",
\r
167 this.readByteArray(this.t8, 0, 8);
\r
168 return this.bytesToDoubleToFloat(this.t8, 0, this.isBigEndian);
\r
170 Clazz.defineMethod (c$, "ioReadDouble",
\r
171 ($fz = function () {
\r
172 var d = this.stream.readDouble ();
\r
173 if (this.out != null) this.writeLong (Double.doubleToRawLongBits (d));
\r
175 }, $fz.isPrivate = true, $fz));
\r
176 Clazz.defineMethod (c$, "readLELong",
\r
177 ($fz = function () {
\r
178 return (((this.ioReadByte ()) & 0xff) | ((this.ioReadByte ()) & 0xff) << 8 | ((this.ioReadByte ()) & 0xff) << 16 | ((this.ioReadByte ()) & 0xff) << 24 | ((this.ioReadByte ()) & 0xff) << 32 | ((this.ioReadByte ()) & 0xff) << 40 | ((this.ioReadByte ()) & 0xff) << 48 | ((this.ioReadByte ()) & 0xff) << 56);
\r
179 }, $fz.isPrivate = true, $fz));
\r
180 Clazz.overrideMethod (c$, "seek",
\r
181 function (offset) {
\r
183 if (offset == this.nBytes) return;
\r
184 if (offset < this.nBytes) {
\r
185 this.stream.reset ();
\r
186 if (this.out != null && this.nBytes != 0) this.out.reset ();
\r
189 offset -= this.nBytes;
\r
190 }if (this.out == null) {
\r
191 this.stream.skipBytes (offset);
\r
193 this.readByteArray ( Clazz.newByteArray (offset, 0), 0, offset);
\r
194 }this.nBytes += offset;
\r
196 if (Clazz.exceptionOf (e, Exception)) {
\r
197 System.out.println (e.toString ());
\r
203 Clazz.overrideMethod (c$, "getPosition",
\r
205 return this.nBytes;
\r
207 Clazz.overrideMethod (c$, "setOutputChannel",
\r
210 }, "javajs.util.OC");
\r
211 Clazz.overrideMethod (c$, "getAllDataFiles",
\r
212 function (binaryFileList, firstFile) {
\r
215 Clazz.overrideMethod (c$, "getAllDataMapped",
\r
216 function (replace, string, fileData) {
\r
217 }, "~S,~S,java.util.Map");
\r