public class XdrOutput extends Object
EXROutputStream
to write primitive
and string data.
Each instance uses a private buffer to write data into the stream. All
methods are not thread safe, and assume that the stream will remain
valid through the lifetime of a XdrOutput
instance.
Modeled after the functions in ImfXdr.h from the C++ OpenEXR library.
EXROutputStream
Constructor and Description |
---|
XdrOutput(EXROutputStream stream) |
Modifier and Type | Method and Description |
---|---|
void |
pad(int n)
Add
n padding bytes. |
long |
position()
Get the current writing position, in bytes from the beginning of the
stream.
|
XdrOutput |
position(long pos)
Set the current position.
|
void |
writeBoolean(boolean value) |
void |
writeBuffer(ByteBuffer src) |
void |
writeByte(byte b) |
void |
writeByteArray(byte[] b) |
void |
writeByteArray(byte[] b,
int off,
int len) |
void |
writeDouble(double value) |
void |
writeFloat(float value) |
void |
writeHalf(Half value) |
void |
writeInt(int value) |
void |
writeNullTerminatedUTF8(String s) |
void |
writeNullTerminatedUTF8(String s,
int maxLen) |
void |
writeShort(short value) |
void |
writeUnsignedByte(int value) |
void |
writeUnsignedInt(long value) |
void |
writeUnsignedShort(int value) |
void |
writeUTF8(String s) |
void |
writeUTF8(String s,
int maxLen) |
public XdrOutput(EXROutputStream stream)
public long position() throws EXRIOException
write()
will write the first byte in
the stream, position()
returns 0.
This implementation simply relies on
EXROutputStream.position()
.
EXRIOException
- if an I/O error occurs.public XdrOutput position(long pos) throws EXRIOException
position(i)
,
position()
returns i.
This implementation simply relies on
EXROutputStream.position(long)
.
pos
- the new writing position.XdrOutput
instanceEXRIOException
public void writeBoolean(boolean value) throws EXRIOException
EXRIOException
public void writeByte(byte b) throws EXRIOException
EXRIOException
public void writeUnsignedByte(int value) throws EXRIOException
EXRIOException
public void writeShort(short value) throws EXRIOException
EXRIOException
public void writeUnsignedShort(int value) throws EXRIOException
EXRIOException
public void writeInt(int value) throws EXRIOException
EXRIOException
public void writeUnsignedInt(long value) throws EXRIOException
EXRIOException
public void writeFloat(float value) throws EXRIOException
EXRIOException
public void writeDouble(double value) throws EXRIOException
EXRIOException
public void writeHalf(Half value) throws EXRIOException
EXRIOException
public void writeNullTerminatedUTF8(String s) throws EXRIOException
EXRIOException
public void writeNullTerminatedUTF8(String s, int maxLen) throws EXRIOException
EXRIOException
public void writeUTF8(String s) throws EXRIOException
EXRIOException
public void writeUTF8(String s, int maxLen) throws EXRIOException
EXRIOException
public void pad(int n) throws EXRIOException
n
padding bytes. The added bytes are set to zero.
If n
is less than one the function returns immediately.n
- number of padding bytes to add.EXRIOException
public void writeByteArray(byte[] b) throws EXRIOException
EXRIOException
public void writeByteArray(byte[] b, int off, int len) throws EXRIOException
b
- off
- len
- EXRIOException
IllegalArgumentException
- if b
is null.IndexOutOfBoundsException
- if off
is negative,
len
is negative, or len
is greater than
b.length - off
public void writeBuffer(ByteBuffer src) throws EXRIOException
EXRIOException