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