File size: 6,694 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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | Clazz.load (["java.io.DataInput", "$.FilterInputStream"], "java.io.DataInputStream", ["java.io.EOFException", "$.PushbackInputStream", "$.UTFDataFormatException", "java.lang.Double", "$.Float", "$.IndexOutOfBoundsException"], function () {
c$ = Clazz.decorateAsClass (function () {
this.bytearr = null;
this.chararr = null;
this.readBuffer = null;
this.lineBuffer = null;
Clazz.instantialize (this, arguments);
}, java.io, "DataInputStream", java.io.FilterInputStream, java.io.DataInput);
Clazz.prepareFields (c$, function () {
this.bytearr = Clazz.newByteArray (80, 0);
this.chararr = Clazz.newCharArray (80, '\0');
this.readBuffer = Clazz.newByteArray (8, 0);
});
Clazz.defineMethod (c$, "read",
function (b, off, len) {
return this.$in.read (b, off, len);
}, "~A,~N,~N");
Clazz.defineMethod (c$, "readFully",
function (b, off, len) {
if (len < 0) throw new IndexOutOfBoundsException ();
var n = 0;
while (n < len) {
var count = this.$in.read (b, off + n, len - n);
if (count < 0) throw new java.io.EOFException ();
n += count;
}
}, "~A,~N,~N");
Clazz.overrideMethod (c$, "skipBytes",
function (n) {
var total = 0;
var cur = 0;
while ((total < n) && ((cur = this.$in.skip (n - total)) > 0)) {
total += cur;
}
return total;
}, "~N");
Clazz.overrideMethod (c$, "readBoolean",
function () {
var ch = this.$in.readByteAsInt ();
if (ch < 0) throw new java.io.EOFException ();
return (ch != 0);
});
Clazz.overrideMethod (c$, "readByte",
function () {
var ch = this.$in.readByteAsInt ();
if (ch < 0) throw new java.io.EOFException ();
return (ch);
});
Clazz.overrideMethod (c$, "readUnsignedByte",
function () {
var ch = this.$in.readByteAsInt ();
if (ch < 0) throw new java.io.EOFException ();
return ch;
});
Clazz.overrideMethod (c$, "readShort",
function () {
var ch1 = this.$in.readByteAsInt ();
var ch2 = this.$in.readByteAsInt ();
if ((ch1 | ch2) < 0) throw new java.io.EOFException ();
var n = ((ch1 << 8) + (ch2 << 0));
{
return (n > 0x7FFF ? n - 0x10000 : n);
}});
Clazz.defineMethod (c$, "readUnsignedShort",
function () {
var ch1 = this.$in.readByteAsInt ();
var ch2 = this.$in.readByteAsInt ();
if ((ch1 | ch2) < 0) throw new java.io.EOFException ();
return (ch1 << 8) + (ch2 << 0);
});
Clazz.overrideMethod (c$, "readChar",
function () {
var ch1 = this.$in.readByteAsInt ();
var ch2 = this.$in.readByteAsInt ();
if ((ch1 | ch2) < 0) throw new java.io.EOFException ();
return String.fromCharCode ((ch1 << 8) + (ch2 << 0));
});
Clazz.overrideMethod (c$, "readInt",
function () {
var ch1 = this.$in.readByteAsInt ();
var ch2 = this.$in.readByteAsInt ();
var ch3 = this.$in.readByteAsInt ();
var ch4 = this.$in.readByteAsInt ();
if ((ch1 | ch2 | ch3 | ch4) < 0) throw new java.io.EOFException ();
var n = ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
{
return (n > 0x7FFFFFFF ? n - 0x100000000 : n);
}});
Clazz.overrideMethod (c$, "readLong",
function () {
this.readFully (this.readBuffer, 0, 8);
return ((this.readBuffer[0] << 56) + ((this.readBuffer[1] & 255) << 48) + ((this.readBuffer[2] & 255) << 40) + ((this.readBuffer[3] & 255) << 32) + ((this.readBuffer[4] & 255) << 24) + ((this.readBuffer[5] & 255) << 16) + ((this.readBuffer[6] & 255) << 8) + ((this.readBuffer[7] & 255) << 0));
});
Clazz.overrideMethod (c$, "readFloat",
function () {
return Float.intBitsToFloat (this.readInt ());
});
Clazz.overrideMethod (c$, "readDouble",
function () {
return Double.longBitsToDouble (this.readLong ());
});
Clazz.overrideMethod (c$, "readLine",
function () {
var buf = this.lineBuffer;
if (buf == null) {
buf = this.lineBuffer = Clazz.newCharArray (128, '\0');
}var room = buf.length;
var offset = 0;
var c;
loop : while (true) {
switch (c = this.$in.readByteAsInt ()) {
case -1:
case '\n':
break loop;
case '\r':
var c2 = this.$in.readByteAsInt ();
if ((c2 != 10) && (c2 != -1)) {
if (!(Clazz.instanceOf (this.$in, java.io.PushbackInputStream))) {
this.$in = new java.io.PushbackInputStream (this.$in, 1);
}(this.$in).unreadByte (c2);
}break loop;
default:
if (--room < 0) {
buf = Clazz.newCharArray (offset + 128, '\0');
room = buf.length - offset - 1;
System.arraycopy (this.lineBuffer, 0, buf, 0, offset);
this.lineBuffer = buf;
}buf[offset++] = String.fromCharCode (c);
break;
}
}
if ((c == -1) && (offset == 0)) {
return null;
}return String.copyValueOf (buf, 0, offset);
});
Clazz.overrideMethod (c$, "readUTF",
function () {
return java.io.DataInputStream.readUTFBytes (this, -1);
});
c$.readUTFBytes = Clazz.defineMethod (c$, "readUTFBytes",
function ($in, utflen) {
var isByteArray = (utflen >= 0);
if (!isByteArray) utflen = $in.readUnsignedShort ();
var bytearr = null;
var chararr = null;
if (Clazz.instanceOf ($in, java.io.DataInputStream)) {
var dis = $in;
if (dis.bytearr.length < utflen) {
dis.bytearr = Clazz.newByteArray (isByteArray ? utflen : utflen * 2, 0);
dis.chararr = Clazz.newCharArray (dis.bytearr.length, '\0');
}chararr = dis.chararr;
bytearr = dis.bytearr;
} else {
bytearr = Clazz.newByteArray (utflen, 0);
chararr = Clazz.newCharArray (utflen, '\0');
}var c;
var char2;
var char3;
var count = 0;
var chararr_count = 0;
$in.readFully (bytearr, 0, utflen);
while (count < utflen) {
c = bytearr[count] & 0xff;
if (c > 127) break;
count++;
chararr[chararr_count++] = String.fromCharCode (c);
}
while (count < utflen) {
c = bytearr[count] & 0xff;
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
count++;
chararr[chararr_count++] = String.fromCharCode (c);
break;
case 12:
case 13:
count += 2;
if (count > utflen) throw new java.io.UTFDataFormatException ("malformed input: partial character at end");
char2 = bytearr[count - 1];
if ((char2 & 0xC0) != 0x80) throw new java.io.UTFDataFormatException ("malformed input around byte " + count);
chararr[chararr_count++] = String.fromCharCode (((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
count += 3;
if (count > utflen) throw new java.io.UTFDataFormatException ("malformed input: partial character at end");
char2 = bytearr[count - 2];
char3 = bytearr[count - 1];
if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) throw new java.io.UTFDataFormatException ("malformed input around byte " + (count - 1));
chararr[chararr_count++] = String.fromCharCode (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
break;
default:
throw new java.io.UTFDataFormatException ("malformed input around byte " + count);
}
}
return String.instantialize (chararr, 0, chararr_count);
}, "java.io.DataInput,~N");
});
|