File size: 1,772 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 | Clazz.load (["java.io.InputStream"], "java.io.ByteArrayInputStream", ["java.lang.IndexOutOfBoundsException", "$.NullPointerException"], function () {
c$ = Clazz.decorateAsClass (function () {
this.buf = null;
this.pos = 0;
this.$mark = 0;
this.count = 0;
Clazz.instantialize (this, arguments);
}, java.io, "ByteArrayInputStream", java.io.InputStream);
Clazz.makeConstructor (c$,
function (buf) {
Clazz.superConstructor (this, java.io.ByteArrayInputStream, []);
this.buf = buf;
this.pos = 0;
this.count = buf.length;
}, "~A");
Clazz.overrideMethod (c$, "readByteAsInt",
function () {
return (this.pos < this.count) ? (this.buf[this.pos++] & 0xff) : -1;
});
Clazz.defineMethod (c$, "read",
function (b, off, len) {
if (b == null) {
throw new NullPointerException ();
} else if (off < 0 || len < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException ();
}if (this.pos >= this.count) {
return -1;
}var avail = this.count - this.pos;
if (len > avail) {
len = avail;
}if (len <= 0) {
return 0;
}System.arraycopy (this.buf, this.pos, b, off, len);
this.pos += len;
return len;
}, "~A,~N,~N");
Clazz.overrideMethod (c$, "skip",
function (n) {
var k = this.count - this.pos;
if (n < k) {
k = n < 0 ? 0 : n;
}this.pos += k;
return k;
}, "~N");
Clazz.overrideMethod (c$, "available",
function () {
return this.count - this.pos;
});
Clazz.overrideMethod (c$, "markSupported",
function () {
return true;
});
Clazz.overrideMethod (c$, "mark",
function (readAheadLimit) {
this.$mark = this.pos;
}, "~N");
Clazz.overrideMethod (c$, "resetStream",
function () {
});
Clazz.overrideMethod (c$, "reset",
function () {
this.pos = this.$mark;
});
Clazz.overrideMethod (c$, "close",
function () {
});
});
|