Package org.acplt.oncrpc
Class XdrDecodingStream
java.lang.Object
org.acplt.oncrpc.XdrDecodingStream
- Direct Known Subclasses:
XdrBufferDecodingStream
,XdrHttpDecodingStream
,XdrTcpDecodingStream
,XdrUdpDecodingStream
Defines the abstract base class for all decoding XDR streams. A decoding
XDR stream returns data in the form of Java data types which it reads
from a data source (for instance, network or memory buffer) in the
platform-independent XDR format.
Derived classes need to implement the xdrDecodeInt()
,
xdrDecodeOpaque(int)
and
xdrDecodeOpaque(byte[], int, int)
methods to make this complete
mess workable.
- Version:
- $Revision: 1.3 $ $Date: 2003/08/14 13:48:33 $ $State: Exp $ $Locker: $
- Author:
- Harald Albrecht
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
Encoding to use when deserializing strings ornull
if the system's default encoding should be used. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
Initiates decoding of the next XDR record.void
close()
Closes this decoding XDR stream and releases any system resources associated with this stream.void
End decoding of the current XDR record.Get the character encoding for deserializing strings.abstract InetAddress
Returns the Internet address of the sender of the current XDR data.abstract int
Returns the port number of the sender of the current XDR data.void
setCharacterEncoding
(String characterEncoding) Set the character encoding for deserializing strings.final boolean
Decodes (aka "deserializes") a boolean read from a XDR stream.final boolean[]
xdrDecodeBooleanFixedVector
(int length) Decodes (aka "deserializes") a vector of booleans read from a XDR stream.final boolean[]
Decodes (aka "deserializes") a vector of booleans read from a XDR stream.final byte
Decodes (aka "deserializes") a byte read from this XDR stream.final byte[]
xdrDecodeByteFixedVector
(int length) Decodes (aka "deserializes") 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).final byte[]
Decodes (aka "deserializes") 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).final double
Decodes (aka "deserializes") a double (which is a 64 bits wide floating point entity) read from a XDR stream.final double[]
xdrDecodeDoubleFixedVector
(int length) Decodes (aka "deserializes") a vector of doubles read from a XDR stream.final double[]
Decodes (aka "deserializes") a vector of doubles read from a XDR stream.final byte[]
Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values.final float
Decodes (aka "deserializes") a float (which is a 32 bits wide floating point entity) read from a XDR stream.final float[]
xdrDecodeFloatFixedVector
(int length) Decodes (aka "deserializes") a vector of floats read from a XDR stream.final float[]
Decodes (aka "deserializes") a vector of floats read from a XDR stream.abstract int
Decodes (aka "deserializes") a "XDR int" value received from a XDR stream.final int[]
xdrDecodeIntFixedVector
(int length) Decodes (aka "deserializes") a vector of ints read from a XDR stream.final int[]
Decodes (aka "deserializes") a vector of ints read from a XDR stream.final long
Decodes (aka "deserializes") a long (which is called a "hyper" in XDR babble and is 64 bits wide) read from a XDR stream.final long[]
xdrDecodeLongFixedVector
(int length) Decodes (aka "deserializes") a vector of longs read from a XDR stream.final long[]
Decodes (aka "deserializes") a vector of longs read from a XDR stream.final void
xdrDecodeOpaque
(byte[] opaque) Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values.abstract void
xdrDecodeOpaque
(byte[] opaque, int offset, int length) Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values, and starts atoffset
with a length oflength
.abstract byte[]
xdrDecodeOpaque
(int length) Decodes (aka "deserializes") an opaque value, which is nothing more than a series of octets (or 8 bits wide bytes).final short
Decodes (aka "deserializes") a short (which is a 16 bit quantity) read from this XDR stream.final short[]
xdrDecodeShortFixedVector
(int length) Decodes (aka "deserializes") a vector of short integers read from a XDR stream.final short[]
Decodes (aka "deserializes") a vector of short integers read from a XDR stream.final String
Decodes (aka "deserializes") a string read from a XDR stream.final String[]
xdrDecodeStringFixedVector
(int length) Decodes (aka "deserializes") a vector of strings read from a XDR stream.final String[]
Decodes (aka "deserializes") a vector of strings read from a XDR stream.
-
Field Details
-
characterEncoding
Encoding to use when deserializing strings ornull
if the system's default encoding should be used.
-
-
Constructor Details
-
XdrDecodingStream
public XdrDecodingStream()
-
-
Method Details
-
getSenderAddress
Returns the Internet address of the sender of the current XDR data. This method should only be called afterbeginDecoding()
, otherwise it might return stale information.- Returns:
- InetAddress of the sender of the current XDR data.
-
getSenderPort
public abstract int getSenderPort()Returns the port number of the sender of the current XDR data. This method should only be called afterbeginDecoding()
, otherwise it might return stale information.- Returns:
- Port number of the sender of the current XDR data.
-
beginDecoding
Initiates decoding of the next XDR record. This typically involves filling the internal buffer with the next datagram from the network, or reading the next chunk of data from a stream-oriented connection. In case of memory-based communication this might involve waiting for some other process to fill the buffer and signal availability of new XDR data.- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
endDecoding
End decoding of the current XDR record. The general contract ofendDecoding
is that calling it is an indication that the current record is no more interesting to the caller and any allocated data for this record can be freed.The
endDecoding
method ofXdrDecodingStream
does nothing.- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
close
Closes this decoding XDR stream and releases any system resources associated with this stream. The general contract ofclose
is that it closes the decoding XDR stream. A closed XDR stream cannot perform decoding operations and cannot be reopened.The
close
method ofXdrDecodingStream
does nothing.- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeInt
Decodes (aka "deserializes") a "XDR int" value received from a XDR stream. A XDR int is 32 bits wide -- the same width Java's "int" data type has. This method is one of the basic methods all other methods can rely on. Because it's so basic, derived classes have to implement it.- Returns:
- The decoded int value.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeOpaque
Decodes (aka "deserializes") an opaque value, which is nothing more than a series of octets (or 8 bits wide bytes). Because the length of the opaque value is given, we don't need to retrieve it from the XDR stream.Note that this is a basic abstract method, which needs to be implemented in derived classes.
- Parameters:
length
- Length of opaque data to decode.- Returns:
- Opaque data as a byte vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeOpaque
public abstract void xdrDecodeOpaque(byte[] opaque, int offset, int length) throws OncRpcException, IOException Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values, and starts atoffset
with a length oflength
. Only the opaque value is decoded, so the caller has to know how long the opaque value will be. The decoded data is always padded to be a multiple of four (because that's what the sender does).Derived classes must ensure that the proper semantic is maintained.
- Parameters:
opaque
- Byte vector which will receive the decoded opaque value.offset
- Start offset in the byte vector.length
- the number of bytes to decode.- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.IndexOutOfBoundsException
- if the givenopaque
byte vector isn't large enough to receive the result.
-
xdrDecodeOpaque
Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values. Only the opaque value is decoded, so the caller has to know how long the opaque value will be. The decoded data is always padded to be a multiple of four (because that's what the sender does).- Parameters:
opaque
- Byte vector which will receive the decoded opaque value.- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeDynamicOpaque
Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values. The length of the opaque value to decode is pulled off of the XDR stream, so the caller does not need to know the exact length in advance. The decoded data is always padded to be a multiple of four (because that's what the sender does).- Returns:
- The byte vector containing the decoded data.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeByteVector
Decodes (aka "deserializes") 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). Byte vectors are decoded together with a preceeding length value. This way the receiver doesn't need to know the length of the vector in advance.- Returns:
- The byte vector containing the decoded data.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeByteFixedVector
Decodes (aka "deserializes") 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).- Parameters:
length
- of vector to read.- Returns:
- The byte vector containing the decoded data.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeByte
Decodes (aka "deserializes") a byte read from this XDR stream.- Returns:
- Decoded byte value.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeShort
Decodes (aka "deserializes") a short (which is a 16 bit quantity) read from this XDR stream.- Returns:
- Decoded short value.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeLong
Decodes (aka "deserializes") a long (which is called a "hyper" in XDR babble and is 64 bits wide) read from a XDR stream.- Returns:
- Decoded long value.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeFloat
Decodes (aka "deserializes") a float (which is a 32 bits wide floating point entity) read from a XDR stream.- Returns:
- Decoded float value.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeDouble
Decodes (aka "deserializes") a double (which is a 64 bits wide floating point entity) read from a XDR stream.- Returns:
- Decoded double value.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeBoolean
Decodes (aka "deserializes") a boolean read from a XDR stream.- Returns:
- Decoded boolean value.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeString
Decodes (aka "deserializes") a string read from a XDR stream. If a character encoding has been set for this stream, then this will be used for conversion.- Returns:
- Decoded String value.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeShortVector
Decodes (aka "deserializes") a vector of short integers read from a XDR stream.- Returns:
- Decoded vector of short integers.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeShortFixedVector
Decodes (aka "deserializes") a vector of short integers read from a XDR stream.- Parameters:
length
- of vector to read.- Returns:
- Decoded vector of short integers.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeIntVector
Decodes (aka "deserializes") a vector of ints read from a XDR stream.- Returns:
- Decoded int vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeIntFixedVector
Decodes (aka "deserializes") a vector of ints read from a XDR stream.- Parameters:
length
- of vector to read.- Returns:
- Decoded int vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeLongVector
Decodes (aka "deserializes") a vector of longs read from a XDR stream.- Returns:
- Decoded long vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeLongFixedVector
Decodes (aka "deserializes") a vector of longs read from a XDR stream.- Parameters:
length
- of vector to read.- Returns:
- Decoded long vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeFloatVector
Decodes (aka "deserializes") a vector of floats read from a XDR stream.- Returns:
- Decoded float vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeFloatFixedVector
Decodes (aka "deserializes") a vector of floats read from a XDR stream.- Parameters:
length
- of vector to read.- Returns:
- Decoded float vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeDoubleVector
Decodes (aka "deserializes") a vector of doubles read from a XDR stream.- Returns:
- Decoded double vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeDoubleFixedVector
Decodes (aka "deserializes") a vector of doubles read from a XDR stream.- Parameters:
length
- of vector to read.- Returns:
- Decoded double vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeBooleanVector
Decodes (aka "deserializes") a vector of booleans read from a XDR stream.- Returns:
- Decoded boolean vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeBooleanFixedVector
Decodes (aka "deserializes") a vector of booleans read from a XDR stream.- Parameters:
length
- of vector to read.- Returns:
- Decoded boolean vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeStringVector
Decodes (aka "deserializes") a vector of strings read from a XDR stream.- Returns:
- Decoded String vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
xdrDecodeStringFixedVector
Decodes (aka "deserializes") a vector of strings read from a XDR stream.- Parameters:
length
- of vector to read.- Returns:
- Decoded String vector.
- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.
-
setCharacterEncoding
Set the character encoding for deserializing strings.- Parameters:
characterEncoding
- the encoding to use for deserializing strings. Ifnull
, the system's default encoding is to be used.
-
getCharacterEncoding
Get the character encoding for deserializing strings.- Returns:
- the encoding currently used for deserializing strings.
If
null
, then the system's default encoding is used.
-