/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* An abstract class implementing the <code>ImageOutputStream</code> interface.
* This class is designed to reduce the number of methods that must
* be implemented by subclasses.
*
*/
public abstract class ImageOutputStreamImpl
extends ImageInputStreamImpl
implements ImageOutputStream {
/**
* Constructs an <code>ImageOutputStreamImpl</code>.
*/
public ImageOutputStreamImpl() {
}
}
}
write(v);
}
} else {
}
}
writeShort(v);
}
} else {
}
}
} else {
}
// REMIND: Once 6277756 is fixed, we should do a bulk write of all 8
// bytes here as we do in writeShort() and writeInt() for even better
// performance. For now, two bulk writes of 4 bytes each is still
// faster than 8 individual write() calls (see 6347575 for details).
}
}
}
for (int i = 0 ; i < len ; i++) {
}
}
byte[] b = new byte[len*2];
int boff = 0;
for (int i = 0; i < len ; i++) {
int v = s.charAt(i);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 0);
}
} else {
for (int i = 0; i < len ; i++) {
int v = s.charAt(i);
b[boff++] = (byte)(v >>> 0);
b[boff++] = (byte)(v >>> 8);
}
}
}
int utflen = 0;
int c, boff = 0;
for (int i = 0; i < strlen; i++) {
c = charr[i];
if ((c >= 0x0001) && (c <= 0x007F)) {
utflen++;
} else if (c > 0x07FF) {
utflen += 3;
} else {
utflen += 2;
}
}
if (utflen > 65535) {
throw new UTFDataFormatException("utflen > 65536!");
}
byte[] b = new byte[utflen+2];
for (int i = 0; i < strlen; i++) {
c = charr[i];
if ((c >= 0x0001) && (c <= 0x007F)) {
b[boff++] = (byte) c;
} else if (c > 0x07FF) {
} else {
}
}
}
// Fix 4430357 - if off + len < 0, overflow occurred
throw new IndexOutOfBoundsException
("off < 0 || len < 0 || off + len > s.length!");
}
byte[] b = new byte[len*2];
int boff = 0;
for (int i = 0; i < len; i++) {
short v = s[off + i];
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 0);
}
} else {
for (int i = 0; i < len; i++) {
short v = s[off + i];
b[boff++] = (byte)(v >>> 0);
b[boff++] = (byte)(v >>> 8);
}
}
}
// Fix 4430357 - if off + len < 0, overflow occurred
throw new IndexOutOfBoundsException
("off < 0 || len < 0 || off + len > c.length!");
}
byte[] b = new byte[len*2];
int boff = 0;
for (int i = 0; i < len; i++) {
char v = c[off + i];
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 0);
}
} else {
for (int i = 0; i < len; i++) {
char v = c[off + i];
b[boff++] = (byte)(v >>> 0);
b[boff++] = (byte)(v >>> 8);
}
}
}
// Fix 4430357 - if off + len < 0, overflow occurred
throw new IndexOutOfBoundsException
("off < 0 || len < 0 || off + len > i.length!");
}
byte[] b = new byte[len*4];
int boff = 0;
for (int j = 0; j < len; j++) {
int v = i[off + j];
b[boff++] = (byte)(v >>> 24);
b[boff++] = (byte)(v >>> 16);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 0);
}
} else {
for (int j = 0; j < len; j++) {
int v = i[off + j];
b[boff++] = (byte)(v >>> 0);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 16);
b[boff++] = (byte)(v >>> 24);
}
}
}
// Fix 4430357 - if off + len < 0, overflow occurred
throw new IndexOutOfBoundsException
("off < 0 || len < 0 || off + len > l.length!");
}
byte[] b = new byte[len*8];
int boff = 0;
for (int i = 0; i < len; i++) {
long v = l[off + i];
b[boff++] = (byte)(v >>> 56);
b[boff++] = (byte)(v >>> 48);
b[boff++] = (byte)(v >>> 40);
b[boff++] = (byte)(v >>> 32);
b[boff++] = (byte)(v >>> 24);
b[boff++] = (byte)(v >>> 16);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 0);
}
} else {
for (int i = 0; i < len; i++) {
long v = l[off + i];
b[boff++] = (byte)(v >>> 0);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 16);
b[boff++] = (byte)(v >>> 24);
b[boff++] = (byte)(v >>> 32);
b[boff++] = (byte)(v >>> 40);
b[boff++] = (byte)(v >>> 48);
b[boff++] = (byte)(v >>> 56);
}
}
}
// Fix 4430357 - if off + len < 0, overflow occurred
throw new IndexOutOfBoundsException
("off < 0 || len < 0 || off + len > f.length!");
}
byte[] b = new byte[len*4];
int boff = 0;
for (int i = 0; i < len; i++) {
b[boff++] = (byte)(v >>> 24);
b[boff++] = (byte)(v >>> 16);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 0);
}
} else {
for (int i = 0; i < len; i++) {
b[boff++] = (byte)(v >>> 0);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 16);
b[boff++] = (byte)(v >>> 24);
}
}
}
// Fix 4430357 - if off + len < 0, overflow occurred
throw new IndexOutOfBoundsException
("off < 0 || len < 0 || off + len > d.length!");
}
byte[] b = new byte[len*8];
int boff = 0;
for (int i = 0; i < len; i++) {
b[boff++] = (byte)(v >>> 56);
b[boff++] = (byte)(v >>> 48);
b[boff++] = (byte)(v >>> 40);
b[boff++] = (byte)(v >>> 32);
b[boff++] = (byte)(v >>> 24);
b[boff++] = (byte)(v >>> 16);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 0);
}
} else {
for (int i = 0; i < len; i++) {
b[boff++] = (byte)(v >>> 0);
b[boff++] = (byte)(v >>> 8);
b[boff++] = (byte)(v >>> 16);
b[boff++] = (byte)(v >>> 24);
b[boff++] = (byte)(v >>> 32);
b[boff++] = (byte)(v >>> 40);
b[boff++] = (byte)(v >>> 48);
b[boff++] = (byte)(v >>> 56);
}
}
}
}
checkClosed();
throw new IllegalArgumentException("Bad value for numBits!");
}
if (numBits == 0) {
return;
}
// Prologue: deal with pre-existing bits
// Bug 4499158, 4507868 - if we're at the beginning of the stream
// and the bit offset is 0, there can't be any pre-existing bits
int partialByte = read();
if (partialByte != -1) {
} else {
partialByte = 0;
}
// Notch out the partial byte and drop in the new bits
} else {
// Fill out the partial byte and reduce numBits
// Note that bitOffset is already 0, so there is no risk
// of this advancing to the next byte
}
}
// Now write any whole bytes
if (numBits > 7) {
? bits & 0xFF
}
}
// Epilogue: write out remaining partial byte, if any
// Note that we may be at EOF, in which case we pad with 0,
// or not, in which case we must preserve the existing bits
if (numBits != 0) {
// If we are not at the end of the file, read the current byte
// If we are at the end of the file, initialize our byte to 0.
int partialByte = 0;
partialByte = read();
if (partialByte != -1) {
}
// Fix 4494976: writeBit(int) does not pad the remainder
// of the current byte with 0s
else { // EOF
partialByte = 0;
}
// bitOffset is always already 0 when we get here.
}
}
/**
* If the bit offset is non-zero, forces the remaining bits
* in the current byte to 0 and advances the stream position
* by one. This method should be called by subclasses at the
* beginning of the <code>write(int)</code> and
* <code>write(byte[], int, int)</code> methods.
*
* @exception IOException if an I/O error occurs.
*/
checkClosed();
if (bitOffset != 0) {
if (partialByte < 0) {
// Fix 4465683: When bitOffset is set
// to something non-zero beyond EOF,
// we should set that whole byte to
// zero and write it to stream.
partialByte = 0;
bitOffset = 0;
}
else {
}
}
}
}