public abstract class XdrEncodingStream extends Object
Derived classes need to implement the xdrEncodeInt(int)
,
xdrEncodeOpaque(byte[])
and
xdrEncodeOpaque(byte[], int, int)
methods to make this complete
mess workable.
Constructor and Description |
---|
XdrEncodingStream() |
Modifier and Type | Method and Description |
---|---|
void |
beginEncoding(InetAddress receiverAddress,
int receiverPort)
Begins encoding a new XDR record.
|
void |
close()
Closes this encoding XDR stream and releases any system resources
associated with this stream.
|
void |
endEncoding()
Flushes this encoding XDR stream and forces any buffered output bytes
to be written out.
|
String |
getCharacterEncoding()
Get the character encoding for serializing strings.
|
void |
setCharacterEncoding(String characterEncoding)
Set the character encoding for serializing strings.
|
void |
xdrEncodeBoolean(boolean value)
Encodes (aka "serializes") a boolean and writes it down this XDR stream.
|
void |
xdrEncodeBooleanFixedVector(boolean[] value,
int length)
Encodes (aka "serializes") a vector of booleans and writes it down
this XDR stream.
|
void |
xdrEncodeBooleanVector(boolean[] value)
Encodes (aka "serializes") a vector of booleans and writes it down
this XDR stream.
|
void |
xdrEncodeByte(byte value)
Encodes (aka "serializes") a byte and write it down this XDR stream.
|
void |
xdrEncodeByteFixedVector(byte[] value,
int length)
Encodes (aka "serializes") a vector of bytes, which is nothing more
than a series of octets (or 8 bits wide bytes), each packed into its
very own 4 bytes (XDR int).
|
void |
xdrEncodeByteVector(byte[] value)
Encodes (aka "serializes") a vector of bytes, which is nothing more
than a series of octets (or 8 bits wide bytes), each packed into its
very own 4 bytes (XDR int).
|
void |
xdrEncodeDouble(double value)
Encodes (aka "serializes") a double (which is a 64 bits wide floating
point quantity) and write it down this XDR stream.
|
void |
xdrEncodeDoubleFixedVector(double[] value,
int length)
Encodes (aka "serializes") a vector of doubles and writes it down
this XDR stream.
|
void |
xdrEncodeDoubleVector(double[] value)
Encodes (aka "serializes") a vector of doubles and writes it down
this XDR stream.
|
void |
xdrEncodeDynamicOpaque(byte[] value)
Encodes (aka "serializes") a XDR opaque value, which is represented
by a vector of byte values.
|
void |
xdrEncodeFloat(float value)
Encodes (aka "serializes") a float (which is a 32 bits wide floating
point quantity) and write it down this XDR stream.
|
void |
xdrEncodeFloatFixedVector(float[] value,
int length)
Encodes (aka "serializes") a vector of floats and writes it down
this XDR stream.
|
void |
xdrEncodeFloatVector(float[] value)
Encodes (aka "serializes") a vector of floats and writes it down
this XDR stream.
|
abstract void |
xdrEncodeInt(int value)
Encodes (aka "serializes") a "XDR int" value and writes it down a
XDR stream.
|
void |
xdrEncodeIntFixedVector(int[] value,
int length)
Encodes (aka "serializes") a vector of ints and writes it down
this XDR stream.
|
void |
xdrEncodeIntVector(int[] value)
Encodes (aka "serializes") a vector of ints and writes it down
this XDR stream.
|
void |
xdrEncodeLong(long value)
Encodes (aka "serializes") a long (which is called a "hyper" in XDR
babble and is 64 bits wide) and write it down this XDR stream.
|
void |
xdrEncodeLongFixedVector(long[] value,
int length)
Encodes (aka "serializes") a vector of long integers and writes it down
this XDR stream.
|
void |
xdrEncodeLongVector(long[] value)
Encodes (aka "serializes") a vector of long integers and writes it down
this XDR stream.
|
void |
xdrEncodeOpaque(byte[] value)
Encodes (aka "serializes") a XDR opaque value, which is represented
by a vector of byte values.
|
void |
xdrEncodeOpaque(byte[] value,
int length)
Encodes (aka "serializes") a XDR opaque value, which is represented
by a vector of byte values.
|
abstract void |
xdrEncodeOpaque(byte[] value,
int offset,
int length)
Encodes (aka "serializes") a XDR opaque value, which is represented
by a vector of byte values, and starts at
offset with a
length of length . |
void |
xdrEncodeShort(short value)
Encodes (aka "serializes") a short (which is a 16 bits wide quantity)
and write it down this XDR stream.
|
void |
xdrEncodeShortFixedVector(short[] value,
int length)
Encodes (aka "serializes") a vector of short integers and writes it down
this XDR stream.
|
void |
xdrEncodeShortVector(short[] value)
Encodes (aka "serializes") a vector of short integers and writes it down
this XDR stream.
|
void |
xdrEncodeString(String value)
Encodes (aka "serializes") a string and writes it down this XDR stream.
|
void |
xdrEncodeStringFixedVector(String[] value,
int length)
Encodes (aka "serializes") a vector of strings and writes it down
this XDR stream.
|
void |
xdrEncodeStringVector(String[] value)
Encodes (aka "serializes") a vector of strings and writes it down
this XDR stream.
|
public void beginEncoding(InetAddress receiverAddress, int receiverPort) throws OncRpcException, IOException
receiverAddress
- Indicates the receiver of the XDR data. This can
be null
for XDR streams connected permanently to a
receiver (like in case of TCP/IP based XDR streams).receiverPort
- Port number of the receiver.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public void endEncoding() throws OncRpcException, IOException
endEncoding
is that
calling it is an indication that the current record is finished and any
bytes previously encoded should immediately be written to their intended
destination.
The endEncoding
method of XdrEncodingStream
does nothing.
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public void close() throws OncRpcException, IOException
close
is that it closes the encoding XDR stream. A closed XDR stream cannot
perform encoding operations and cannot be reopened.
The close
method of XdrEncodingStream
does nothing.
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public abstract void xdrEncodeInt(int value) throws OncRpcException, IOException
value
- The int value to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public abstract void xdrEncodeOpaque(byte[] value, int offset, int length) throws OncRpcException, IOException
offset
with a
length of length
. Only the opaque value is encoded, but
no length indication is preceeding the opaque value, so the receiver
has to know how long the opaque value will be. The encoded data is
always padded to be a multiple of four. If the given length is not a
multiple of four, zero bytes will be used for padding.
Derived classes must ensure that the proper semantic is maintained.
value
- The opaque value to be encoded in the form of a series of
bytes.offset
- Start offset in the data.length
- the number of bytes to encode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeDynamicOpaque(byte[] value) throws OncRpcException, IOException
value
- The opaque value to be encoded in the form of a series of
bytes.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeOpaque(byte[] value) throws OncRpcException, IOException
value
- The opaque value to be encoded in the form of a series of
bytes.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeOpaque(byte[] value, int length) throws OncRpcException, IOException
value
- The opaque value to be encoded in the form of a series of
bytes.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public final void xdrEncodeByteVector(byte[] value) throws OncRpcException, IOException
value
- Byte vector to encode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeByteFixedVector(byte[] value, int length) throws OncRpcException, IOException
value
- Byte vector to encode.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public final void xdrEncodeByte(byte value) throws OncRpcException, IOException
value
- Byte value to encode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeShort(short value) throws OncRpcException, IOException
value
- Short value to encode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeLong(long value) throws OncRpcException, IOException
value
- Long value to encode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeFloat(float value) throws OncRpcException, IOException
value
- Float value to encode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeDouble(double value) throws OncRpcException, IOException
value
- Double value to encode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeBoolean(boolean value) throws OncRpcException, IOException
value
- Boolean value to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeString(String value) throws OncRpcException, IOException
value
- String value to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeShortVector(short[] value) throws OncRpcException, IOException
value
- short vector to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeShortFixedVector(short[] value, int length) throws OncRpcException, IOException
value
- short vector to be encoded.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public final void xdrEncodeIntVector(int[] value) throws OncRpcException, IOException
value
- int vector to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeIntFixedVector(int[] value, int length) throws OncRpcException, IOException
value
- int vector to be encoded.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public final void xdrEncodeLongVector(long[] value) throws OncRpcException, IOException
value
- long vector to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeLongFixedVector(long[] value, int length) throws OncRpcException, IOException
value
- long vector to be encoded.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public final void xdrEncodeFloatVector(float[] value) throws OncRpcException, IOException
value
- float vector to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeFloatFixedVector(float[] value, int length) throws OncRpcException, IOException
value
- float vector to be encoded.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public final void xdrEncodeDoubleVector(double[] value) throws OncRpcException, IOException
value
- double vector to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeDoubleFixedVector(double[] value, int length) throws OncRpcException, IOException
value
- double vector to be encoded.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public final void xdrEncodeBooleanVector(boolean[] value) throws OncRpcException, IOException
value
- long vector to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeBooleanFixedVector(boolean[] value, int length) throws OncRpcException, IOException
value
- long vector to be encoded.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public final void xdrEncodeStringVector(String[] value) throws OncRpcException, IOException
value
- String vector to be encoded.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public final void xdrEncodeStringFixedVector(String[] value, int length) throws OncRpcException, IOException
value
- String vector to be encoded.length
- of vector to write. This parameter is used as a sanity
check.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IllegalArgumentException
- if the length of the vector does not
match the specified length.public void setCharacterEncoding(String characterEncoding)
characterEncoding
- the encoding to use for serializing strings.
If null
, the system's default encoding is to be used.public String getCharacterEncoding()
null
, then the system's default encoding is used.Copyright © 2015. All rights reserved.