3 package com.pixelmed.codec.jpeg;
5 import java.io.IOException;
6 import java.io.OutputStream;
8 import java.nio.ByteOrder;
24 private static final String identString =
"@(#) $Header: /userland/cvs/codec/com/pixelmed/codec/jpeg/OutputArrayOrStream.java,v 1.5 2016/01/16 13:30:09 dclunie Exp $";
26 protected OutputStream
out = null;
27 protected ByteOrder
order = null;
52 public void setOutputStream(OutputStream out,ByteOrder order)
throws IOException {
53 if (this.out != null || this.byteValues != null || this.shortValues != null) {
54 throw new IOException(
"Destination already allocated");
66 return out == null ? null :
order;
75 public void order(ByteOrder order)
throws IOException {
77 throw new IOException(
"Cannot assign byte order if no OutputStream");
83 if (this.out != null || this.byteValues != null || this.shortValues != null) {
84 throw new IOException(
"Destination already allocated");
86 this.byteValues =
new byte[length];
91 if (this.out != null || this.byteValues != null || this.shortValues != null) {
92 throw new IOException(
"Destination already allocated");
94 this.shortValues =
new short[length];
120 else if (byteValues != null) {
121 byteValues[byteOffset++] = (byte)b;
123 else if (shortValues != null) {
124 throw new IOException(
"Cannot write byte value to short array");
127 throw new IOException(
"Byte array not allocated yet");
139 if (order == ByteOrder.LITTLE_ENDIAN) {
148 else if (shortValues != null) {
149 shortValues[shortOffset++] = (short)s;
151 else if (byteValues != null) {
152 throw new IOException(
"Cannot write short value to byte array");
155 throw new IOException(
"Short array not allocated yet");
166 public void close() throws IOException {
void order(ByteOrder order)
OutputStream getOutputStream()
void allocateByteArray(int length)
OutputArrayOrStream(byte[] byteValues)
void writeByte(int b)
Writes the specified byte to this output.
void setOutputStream(OutputStream out, ByteOrder order)
void allocateShortArray(int length)
OutputArrayOrStream(short[] shortValues)
OutputArrayOrStream(OutputStream out, ByteOrder order)
void writeShort(int s)
Writes the specified short to this output.