1 Clazz.load (["java.io.Reader"], "java.io.InputStreamReader", ["java.lang.NullPointerException"], function () {
\r
2 c$ = Clazz.decorateAsClass (function () {
\r
5 this.charsetName = null;
\r
9 Clazz.instantialize (this, arguments);
\r
10 }, java.io, "InputStreamReader", java.io.Reader);
\r
11 Clazz.makeConstructor (c$,
\r
13 //just sets lock Clazz.superConstructor (this, java.io.InputStreamReader, [$in]);
\r
15 var charsetName = (arguments.length > 1 ? arguments[1] : "UTF-8");
\r
17 this.charsetName = charsetName;
\r
18 if (!(this.isUTF8 = "UTF-8".equals (charsetName)) && !"ISO-8859-1".equals (charsetName)) throw new NullPointerException ("charsetName");
\r
19 }, "java.io.InputStream");
\r
20 Clazz.defineMethod (c$, "getEncoding",
\r
22 return this.charsetName;
\r
24 Clazz.overrideMethod (c$, "read",
\r
25 function (cbuf, offset, length) {
\r
26 if (this.bytearr == null || this.bytearr.length < length) this.bytearr = Clazz.newByteArray (length, 0);
\r
31 var charCount = offset;
\r
32 var byteLen = this.$in.read (this.bytearr, this.pos, length - this.pos);
\r
33 var nAvail = this.$in.available ();
\r
34 if (byteLen < 0) return -1;
\r
36 while (byteCount < nMax) {
\r
37 c = this.bytearr[byteCount] & 0xff;
\r
38 if (this.isUTF8) switch (c >> 4) {
\r
41 if (byteCount + 1 >= byteLen) {
\r
45 }} else if (((char2 = this.bytearr[byteCount + 1]) & 0xC0) == 0x80) {
\r
46 cbuf[charCount++] = String.fromCharCode (((c & 0x1F) << 6) | (char2 & 0x3F));
\r
49 }this.isUTF8 = false;
\r
52 if (byteCount + 2 >= byteLen) {
\r
56 }} else if (((char2 = this.bytearr[byteCount + 1]) & 0xC0) == 0x80 && ((char3 = this.bytearr[byteCount + 2]) & 0xC0) == 0x80) {
\r
57 cbuf[charCount++] = String.fromCharCode (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | (char3 & 0x3F));
\r
60 }this.isUTF8 = false;
\r
64 cbuf[charCount++] = String.fromCharCode (c);
\r
66 this.pos = byteLen - byteCount;
\r
67 for (var i = 0; i < this.pos; i++) {
\r
68 this.bytearr[i] = this.bytearr[byteCount++];
\r
70 return charCount - offset;
\r
72 Clazz.overrideMethod (c$, "ready",
\r
76 Clazz.overrideMethod (c$, "close",
\r
79 this.isOpen = false;
\r