X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjavajs%2Futil%2FBinaryDocument.js;h=a0edf334fb5486a4ada54c045bc517b36b858857;hp=420db0bb83ab2f7e97f16fba92f237e4f35e28d1;hb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/javajs/util/BinaryDocument.js b/bin/javajs/util/BinaryDocument.js index 420db0b..a0edf33 100644 --- a/bin/javajs/util/BinaryDocument.js +++ b/bin/javajs/util/BinaryDocument.js @@ -1,218 +1,218 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.GenericBinaryDocument", "javajs.util.BC"], "javajs.util.BinaryDocument", ["java.io.DataInputStream", "java.lang.Double"], function () { -c$ = Clazz.decorateAsClass (function () { -this.stream = null; -this.isRandom = false; -this.isBigEndian = true; -this.jzt = null; -this.t8 = null; -this.nBytes = 0; -this.out = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "BinaryDocument", javajs.util.BC, javajs.api.GenericBinaryDocument); -Clazz.prepareFields (c$, function () { -this.t8 = Clazz.newByteArray (8, 0); -}); -Clazz.overrideMethod (c$, "close", -function () { -if (this.stream != null) try { -this.stream.close (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -if (this.out != null) this.out.closeChannel (); -}); -Clazz.overrideMethod (c$, "setStream", -function (jzt, bis, isBigEndian) { -if (jzt != null) this.jzt = jzt; -if (bis != null) this.stream = new java.io.DataInputStream (bis); -this.isBigEndian = isBigEndian; -}, "javajs.api.GenericZipTools,java.io.BufferedInputStream,~B"); -Clazz.overrideMethod (c$, "setStreamData", -function (stream, isBigEndian) { -if (stream != null) this.stream = stream; -this.isBigEndian = isBigEndian; -}, "java.io.DataInputStream,~B"); -Clazz.defineMethod (c$, "setRandom", -function (TF) { -this.isRandom = TF; -}, "~B"); -Clazz.overrideMethod (c$, "readByte", -function () { -this.nBytes++; -return this.ioReadByte (); -}); -Clazz.defineMethod (c$, "ioReadByte", -($fz = function () { -var b = this.stream.readByte (); -if (this.out != null) this.out.writeByteAsInt (b); -return b; -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "readByteArray", -function (b, off, len) { -var n = this.ioRead (b, off, len); -this.nBytes += n; -return n; -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "ioRead", -($fz = function (b, off, len) { -var m = 0; -while (len > 0) { -var n = this.stream.read (b, off, len); -m += n; -if (n > 0 && this.out != null) this.writeBytes (b, off, n); -if (n >= len) break; -off += n; -len -= n; -} -return m; -}, $fz.isPrivate = true, $fz), "~A,~N,~N"); -Clazz.defineMethod (c$, "writeBytes", -function (b, off, n) { -this.out.write (b, off, n); -}, "~A,~N,~N"); -Clazz.overrideMethod (c$, "readString", -function (nChar) { -var temp = Clazz.newByteArray (nChar, 0); -var n = this.readByteArray (temp, 0, nChar); -return String.instantialize (temp, 0, n, "UTF-8"); -}, "~N"); -Clazz.overrideMethod (c$, "readShort", -function () { -this.nBytes += 2; -var n = (this.isBigEndian ? this.ioReadShort () : ((this.ioReadByte () & 0xff) | (this.ioReadByte () & 0xff) << 8)); -{ -return (n > 0x7FFF ? n - 0x10000 : n); -}}); -Clazz.defineMethod (c$, "ioReadShort", -($fz = function () { -var b = this.stream.readShort (); -if (this.out != null) this.writeShort (b); -return b; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeShort", -function (i) { -this.out.writeByteAsInt (i >> 8); -this.out.writeByteAsInt (i); -}, "~N"); -Clazz.overrideMethod (c$, "readIntLE", -function () { -this.nBytes += 4; -return this.readLEInt (); -}); -Clazz.overrideMethod (c$, "readInt", -function () { -this.nBytes += 4; -return (this.isBigEndian ? this.ioReadInt () : this.readLEInt ()); -}); -Clazz.defineMethod (c$, "ioReadInt", -($fz = function () { -var i = this.stream.readInt (); -if (this.out != null) this.writeInt (i); -return i; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeInt", -function (i) { -this.out.writeByteAsInt (i >> 24); -this.out.writeByteAsInt (i >> 16); -this.out.writeByteAsInt (i >> 8); -this.out.writeByteAsInt (i); -}, "~N"); -Clazz.overrideMethod (c$, "swapBytesI", -function (n) { -return (((n >> 24) & 0xff) | ((n >> 16) & 0xff) << 8 | ((n >> 8) & 0xff) << 16 | (n & 0xff) << 24); -}, "~N"); -Clazz.overrideMethod (c$, "swapBytesS", -function (n) { -return ((((n >> 8) & 0xff) | (n & 0xff) << 8)); -}, "~N"); -Clazz.overrideMethod (c$, "readUnsignedShort", -function () { -this.nBytes += 2; -var a = (this.ioReadByte () & 0xff); -var b = (this.ioReadByte () & 0xff); -return (this.isBigEndian ? (a << 8) + b : (b << 8) + a); -}); -Clazz.overrideMethod (c$, "readLong", -function () { -this.nBytes += 8; -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)); -}); -Clazz.defineMethod (c$, "ioReadLong", -($fz = function () { -var b = this.stream.readLong (); -if (this.out != null) this.writeLong (b); -return b; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeLong", -function (b) { -this.writeInt (((b >> 32) & 0xFFFFFFFF)); -this.writeInt ((b & 0xFFFFFFFF)); -}, "~N"); -Clazz.defineMethod (c$, "readLEInt", -($fz = function () { -this.ioRead (this.t8, 0, 4); -return javajs.util.BC.bytesToInt (this.t8, 0, false); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "readFloat", -function () { -return javajs.util.BC.intToFloat (this.readInt ()); -}); -Clazz.overrideMethod (c$, "readDouble", -function () { -{ -this.readByteArray(this.t8, 0, 8); -return this.bytesToDoubleToFloat(this.t8, 0, this.isBigEndian); -}}); -Clazz.defineMethod (c$, "ioReadDouble", -($fz = function () { -var d = this.stream.readDouble (); -if (this.out != null) this.writeLong (Double.doubleToRawLongBits (d)); -return d; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "readLELong", -($fz = function () { -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); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "seek", -function (offset) { -try { -if (offset == this.nBytes) return; -if (offset < this.nBytes) { -this.stream.reset (); -if (this.out != null && this.nBytes != 0) this.out.reset (); -this.nBytes = 0; -} else { -offset -= this.nBytes; -}if (this.out == null) { -this.stream.skipBytes (offset); -} else { -this.readByteArray ( Clazz.newByteArray (offset, 0), 0, offset); -}this.nBytes += offset; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -}, "~N"); -Clazz.overrideMethod (c$, "getPosition", -function () { -return this.nBytes; -}); -Clazz.overrideMethod (c$, "setOutputChannel", -function (out) { -this.out = out; -}, "javajs.util.OC"); -Clazz.overrideMethod (c$, "getAllDataFiles", -function (binaryFileList, firstFile) { -return null; -}, "~S,~S"); -Clazz.overrideMethod (c$, "getAllDataMapped", -function (replace, string, fileData) { -}, "~S,~S,java.util.Map"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.GenericBinaryDocument", "javajs.util.BC"], "javajs.util.BinaryDocument", ["java.io.DataInputStream", "java.lang.Double"], function () { +c$ = Clazz.decorateAsClass (function () { +this.stream = null; +this.isRandom = false; +this.isBigEndian = true; +this.jzt = null; +this.t8 = null; +this.nBytes = 0; +this.out = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "BinaryDocument", javajs.util.BC, javajs.api.GenericBinaryDocument); +Clazz.prepareFields (c$, function () { +this.t8 = Clazz.newByteArray (8, 0); +}); +Clazz.overrideMethod (c$, "close", +function () { +if (this.stream != null) try { +this.stream.close (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +if (this.out != null) this.out.closeChannel (); +}); +Clazz.overrideMethod (c$, "setStream", +function (jzt, bis, isBigEndian) { +if (jzt != null) this.jzt = jzt; +if (bis != null) this.stream = new java.io.DataInputStream (bis); +this.isBigEndian = isBigEndian; +}, "javajs.api.GenericZipTools,java.io.BufferedInputStream,~B"); +Clazz.overrideMethod (c$, "setStreamData", +function (stream, isBigEndian) { +if (stream != null) this.stream = stream; +this.isBigEndian = isBigEndian; +}, "java.io.DataInputStream,~B"); +Clazz.defineMethod (c$, "setRandom", +function (TF) { +this.isRandom = TF; +}, "~B"); +Clazz.overrideMethod (c$, "readByte", +function () { +this.nBytes++; +return this.ioReadByte (); +}); +Clazz.defineMethod (c$, "ioReadByte", +($fz = function () { +var b = this.stream.readByte (); +if (this.out != null) this.out.writeByteAsInt (b); +return b; +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "readByteArray", +function (b, off, len) { +var n = this.ioRead (b, off, len); +this.nBytes += n; +return n; +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "ioRead", +($fz = function (b, off, len) { +var m = 0; +while (len > 0) { +var n = this.stream.read (b, off, len); +m += n; +if (n > 0 && this.out != null) this.writeBytes (b, off, n); +if (n >= len) break; +off += n; +len -= n; +} +return m; +}, $fz.isPrivate = true, $fz), "~A,~N,~N"); +Clazz.defineMethod (c$, "writeBytes", +function (b, off, n) { +this.out.write (b, off, n); +}, "~A,~N,~N"); +Clazz.overrideMethod (c$, "readString", +function (nChar) { +var temp = Clazz.newByteArray (nChar, 0); +var n = this.readByteArray (temp, 0, nChar); +return String.instantialize (temp, 0, n, "UTF-8"); +}, "~N"); +Clazz.overrideMethod (c$, "readShort", +function () { +this.nBytes += 2; +var n = (this.isBigEndian ? this.ioReadShort () : ((this.ioReadByte () & 0xff) | (this.ioReadByte () & 0xff) << 8)); +{ +return (n > 0x7FFF ? n - 0x10000 : n); +}}); +Clazz.defineMethod (c$, "ioReadShort", +($fz = function () { +var b = this.stream.readShort (); +if (this.out != null) this.writeShort (b); +return b; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeShort", +function (i) { +this.out.writeByteAsInt (i >> 8); +this.out.writeByteAsInt (i); +}, "~N"); +Clazz.overrideMethod (c$, "readIntLE", +function () { +this.nBytes += 4; +return this.readLEInt (); +}); +Clazz.overrideMethod (c$, "readInt", +function () { +this.nBytes += 4; +return (this.isBigEndian ? this.ioReadInt () : this.readLEInt ()); +}); +Clazz.defineMethod (c$, "ioReadInt", +($fz = function () { +var i = this.stream.readInt (); +if (this.out != null) this.writeInt (i); +return i; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeInt", +function (i) { +this.out.writeByteAsInt (i >> 24); +this.out.writeByteAsInt (i >> 16); +this.out.writeByteAsInt (i >> 8); +this.out.writeByteAsInt (i); +}, "~N"); +Clazz.overrideMethod (c$, "swapBytesI", +function (n) { +return (((n >> 24) & 0xff) | ((n >> 16) & 0xff) << 8 | ((n >> 8) & 0xff) << 16 | (n & 0xff) << 24); +}, "~N"); +Clazz.overrideMethod (c$, "swapBytesS", +function (n) { +return ((((n >> 8) & 0xff) | (n & 0xff) << 8)); +}, "~N"); +Clazz.overrideMethod (c$, "readUnsignedShort", +function () { +this.nBytes += 2; +var a = (this.ioReadByte () & 0xff); +var b = (this.ioReadByte () & 0xff); +return (this.isBigEndian ? (a << 8) + b : (b << 8) + a); +}); +Clazz.overrideMethod (c$, "readLong", +function () { +this.nBytes += 8; +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)); +}); +Clazz.defineMethod (c$, "ioReadLong", +($fz = function () { +var b = this.stream.readLong (); +if (this.out != null) this.writeLong (b); +return b; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeLong", +function (b) { +this.writeInt (((b >> 32) & 0xFFFFFFFF)); +this.writeInt ((b & 0xFFFFFFFF)); +}, "~N"); +Clazz.defineMethod (c$, "readLEInt", +($fz = function () { +this.ioRead (this.t8, 0, 4); +return javajs.util.BC.bytesToInt (this.t8, 0, false); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "readFloat", +function () { +return javajs.util.BC.intToFloat (this.readInt ()); +}); +Clazz.overrideMethod (c$, "readDouble", +function () { +{ +this.readByteArray(this.t8, 0, 8); +return this.bytesToDoubleToFloat(this.t8, 0, this.isBigEndian); +}}); +Clazz.defineMethod (c$, "ioReadDouble", +($fz = function () { +var d = this.stream.readDouble (); +if (this.out != null) this.writeLong (Double.doubleToRawLongBits (d)); +return d; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "readLELong", +($fz = function () { +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); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "seek", +function (offset) { +try { +if (offset == this.nBytes) return; +if (offset < this.nBytes) { +this.stream.reset (); +if (this.out != null && this.nBytes != 0) this.out.reset (); +this.nBytes = 0; +} else { +offset -= this.nBytes; +}if (this.out == null) { +this.stream.skipBytes (offset); +} else { +this.readByteArray ( Clazz.newByteArray (offset, 0), 0, offset); +}this.nBytes += offset; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +}, "~N"); +Clazz.overrideMethod (c$, "getPosition", +function () { +return this.nBytes; +}); +Clazz.overrideMethod (c$, "setOutputChannel", +function (out) { +this.out = out; +}, "javajs.util.OC"); +Clazz.overrideMethod (c$, "getAllDataFiles", +function (binaryFileList, firstFile) { +return null; +}, "~S,~S"); +Clazz.overrideMethod (c$, "getAllDataMapped", +function (replace, string, fileData) { +}, "~S,~S,java.util.Map"); +});