1 Clazz.load (["java.io.OutputStream"], "java.io.ByteArrayOutputStream", ["java.lang.IllegalArgumentException", "$.IndexOutOfBoundsException", "$.OutOfMemoryError"], function () {
\r
2 c$ = Clazz.decorateAsClass (function () {
\r
5 Clazz.instantialize (this, arguments);
\r
6 }, java.io, "ByteArrayOutputStream", java.io.OutputStream);
\r
7 Clazz.makeConstructor (c$,
\r
11 Clazz.makeConstructor (c$,
\r
13 Clazz.superConstructor (this, java.io.ByteArrayOutputStream, []);
\r
15 throw new IllegalArgumentException ("Negative initial size: " + size);
\r
16 }this.buf = Clazz.newByteArray (size, 0);
\r
18 Clazz.defineMethod (c$, "ensureCapacity",
\r
19 function (minCapacity) {
\r
20 if (minCapacity - this.buf.length > 0) this.grow (minCapacity);
\r
22 Clazz.defineMethod (c$, "grow",
\r
23 function (minCapacity) {
\r
24 var oldCapacity = this.buf.length;
\r
25 var newCapacity = oldCapacity << 1;
\r
26 if (newCapacity - minCapacity < 0) newCapacity = minCapacity;
\r
27 if (newCapacity < 0) {
\r
28 if (minCapacity < 0) throw new OutOfMemoryError ();
\r
29 newCapacity = minCapacity;
\r
30 }this.buf = java.io.ByteArrayOutputStream.arrayCopyByte (this.buf, newCapacity);
\r
32 c$.arrayCopyByte = Clazz.defineMethod (c$, "arrayCopyByte",
\r
33 function (array, newLength) {
\r
34 var t = Clazz.newByteArray (newLength, 0);
\r
35 System.arraycopy (array, 0, t, 0, array.length < newLength ? array.length : newLength);
\r
38 Clazz.overrideMethod (c$, "writeByteAsInt",
\r
40 this.ensureCapacity (this.count + 1);
\r
41 this.buf[this.count] = b;
\r
44 Clazz.defineMethod (c$, "write",
\r
45 function (b, off, len) {
\r
46 if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) - b.length > 0)) {
\r
47 throw new IndexOutOfBoundsException ();
\r
48 }this.ensureCapacity (this.count + len);
\r
49 System.arraycopy (b, off, this.buf, this.count, len);
\r
52 Clazz.defineMethod (c$, "writeTo",
\r
54 out.write (this.buf, 0, this.count);
\r
55 }, "java.io.OutputStream");
\r
56 Clazz.defineMethod (c$, "reset",
\r
60 Clazz.defineMethod (c$, "toByteArray",
\r
62 return (this.count == this.buf.length ? this.buf : java.io.ByteArrayOutputStream.arrayCopyByte (this.buf, this.count));
\r
64 Clazz.defineMethod (c$, "size",
\r
68 Clazz.overrideMethod (c$, "toString",
\r
70 return String.instantialize (this.buf, 0, this.count);
\r
72 Clazz.overrideMethod (c$, "close",
\r