1 Clazz.load (["java.io.DataInput", "$.FilterInputStream"], "java.io.DataInputStream", ["java.io.EOFException", "$.PushbackInputStream", "$.UTFDataFormatException", "java.lang.Double", "$.Float", "$.IndexOutOfBoundsException"], function () {
2 c$ = Clazz.decorateAsClass (function () {
5 this.readBuffer = null;
6 this.lineBuffer = null;
7 Clazz.instantialize (this, arguments);
8 }, java.io, "DataInputStream", java.io.FilterInputStream, java.io.DataInput);
9 Clazz.prepareFields (c$, function () {
10 this.bytearr = Clazz.newByteArray (80, 0);
11 this.chararr = Clazz.newCharArray (80, '\0');
12 this.readBuffer = Clazz.newByteArray (8, 0);
14 Clazz.overrideMethod (c$, "read",
15 function (b, off, len) {
16 if (arguments.length == 1) { off = 0; len = b.length; }
17 return this.$in.read (b, off, len);
19 Clazz.defineMethod (c$, "readFully",
20 function (b, off, len) {
21 if (len < 0) throw new IndexOutOfBoundsException ();
24 var count = this.$in.read (b, off + n, len - n);
25 if (count < 0) throw new java.io.EOFException ();
29 Clazz.overrideMethod (c$, "skipBytes",
33 while ((total < n) && ((cur = this.$in.skip (n - total)) > 0)) {
38 Clazz.overrideMethod (c$, "readBoolean",
40 var ch = this.$in.readByteAsInt ();
41 if (ch < 0) throw new java.io.EOFException ();
44 Clazz.overrideMethod (c$, "readByte",
46 var ch = this.$in.readByteAsInt ();
47 if (ch < 0) throw new java.io.EOFException ();
50 Clazz.overrideMethod (c$, "readUnsignedByte",
52 var ch = this.$in.readByteAsInt ();
53 if (ch < 0) throw new java.io.EOFException ();
56 Clazz.overrideMethod (c$, "readShort",
58 var ch1 = this.$in.readByteAsInt ();
59 var ch2 = this.$in.readByteAsInt ();
60 if ((ch1 | ch2) < 0) throw new java.io.EOFException ();
61 var n = ((ch1 << 8) + (ch2 << 0));
63 return (n > 0x7FFF ? n - 0x10000 : n);
65 Clazz.defineMethod (c$, "readUnsignedShort",
67 var ch1 = this.$in.readByteAsInt ();
68 var ch2 = this.$in.readByteAsInt ();
69 if ((ch1 | ch2) < 0) throw new java.io.EOFException ();
70 return (ch1 << 8) + (ch2 << 0);
72 Clazz.overrideMethod (c$, "readChar",
74 var ch1 = this.$in.readByteAsInt ();
75 var ch2 = this.$in.readByteAsInt ();
76 if ((ch1 | ch2) < 0) throw new java.io.EOFException ();
77 return String.fromCharCode ((ch1 << 8) + (ch2 << 0));
79 Clazz.overrideMethod (c$, "readInt",
81 var ch1 = this.$in.readByteAsInt ();
82 var ch2 = this.$in.readByteAsInt ();
83 var ch3 = this.$in.readByteAsInt ();
84 var ch4 = this.$in.readByteAsInt ();
85 if ((ch1 | ch2 | ch3 | ch4) < 0) throw new java.io.EOFException ();
86 var n = ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
88 return (n > 0x7FFFFFFF ? n - 0x100000000 : n);
90 Clazz.overrideMethod (c$, "readLong",
92 this.readFully (this.readBuffer, 0, 8);
93 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));
95 Clazz.overrideMethod (c$, "readFloat",
97 return Float.intBitsToFloat (this.readInt ());
99 Clazz.overrideMethod (c$, "readDouble",
101 return Double.longBitsToDouble (this.readLong ());
103 Clazz.overrideMethod (c$, "readLine",
105 var buf = this.lineBuffer;
107 buf = this.lineBuffer = Clazz.newCharArray (128, '\0');
108 }var room = buf.length;
111 loop : while (true) {
112 switch (c = this.$in.readByteAsInt ()) {
117 var c2 = this.$in.readByteAsInt ();
118 if ((c2 != 10) && (c2 != -1)) {
119 if (!(Clazz.instanceOf (this.$in, java.io.PushbackInputStream))) {
120 this.$in = new java.io.PushbackInputStream (this.$in, 1);
121 }(this.$in).unreadByte (c2);
125 buf = Clazz.newCharArray (offset + 128, '\0');
126 room = buf.length - offset - 1;
127 System.arraycopy (this.lineBuffer, 0, buf, 0, offset);
128 this.lineBuffer = buf;
129 }buf[offset++] = String.fromCharCode (c);
133 if ((c == -1) && (offset == 0)) {
135 }return String.copyValueOf (buf, 0, offset);
137 Clazz.overrideMethod (c$, "readUTF",
139 return java.io.DataInputStream.readUTFBytes (this, -1);
141 c$.readUTFBytes = Clazz.defineMethod (c$, "readUTFBytes",
142 function ($in, utflen) {
143 var isByteArray = (utflen >= 0);
144 if (!isByteArray) utflen = $in.readUnsignedShort ();
147 if (Clazz.instanceOf ($in, java.io.DataInputStream)) {
149 if (dis.bytearr.length < utflen) {
150 dis.bytearr = Clazz.newByteArray (isByteArray ? utflen : utflen * 2, 0);
151 dis.chararr = Clazz.newCharArray (dis.bytearr.length, '\0');
152 }chararr = dis.chararr;
153 bytearr = dis.bytearr;
155 bytearr = Clazz.newByteArray (utflen, 0);
156 chararr = Clazz.newCharArray (utflen, '\0');
161 var chararr_count = 0;
162 $in.readFully (bytearr, 0, utflen);
163 while (count < utflen) {
164 c = bytearr[count] & 0xff;
167 chararr[chararr_count++] = String.fromCharCode (c);
169 while (count < utflen) {
170 c = bytearr[count] & 0xff;
181 chararr[chararr_count++] = String.fromCharCode (c);
186 if (count > utflen) throw new java.io.UTFDataFormatException ("malformed input: partial character at end");
187 char2 = bytearr[count - 1];
188 if ((char2 & 0xC0) != 0x80) throw new java.io.UTFDataFormatException ("malformed input around byte " + count);
189 chararr[chararr_count++] = String.fromCharCode (((c & 0x1F) << 6) | (char2 & 0x3F));
193 if (count > utflen) throw new java.io.UTFDataFormatException ("malformed input: partial character at end");
194 char2 = bytearr[count - 2];
195 char3 = bytearr[count - 1];
196 if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) throw new java.io.UTFDataFormatException ("malformed input around byte " + (count - 1));
197 chararr[chararr_count++] = String.fromCharCode (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
200 throw new java.io.UTFDataFormatException ("malformed input around byte " + count);
203 return String.instantialize (chararr, 0, chararr_count);
204 }, "java.io.DataInput,~N");