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