Package com.zeroc.Ice
Class InputStream
java.lang.Object
com.zeroc.Ice.InputStream
Interface to read sequence of bytes encoded using the Ice encoding and
recreate the corresponding Slice types.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructing an InputStream without providing a communicator means the stream will use the default encoding version.InputStream
(byte[] data) Constructing an InputStream without providing a communicator means the stream will use the default encoding version.InputStream
(Communicator communicator) This constructor uses the communicator's default encoding version.InputStream
(Communicator communicator, byte[] data) This constructor uses the communicator's default encoding version.InputStream
(Communicator communicator, EncodingVersion encoding) This constructor uses the given communicator and encoding version.InputStream
(Communicator communicator, EncodingVersion encoding, byte[] data) This constructor uses the given communicator and encoding version.InputStream
(Communicator communicator, EncodingVersion encoding, com.zeroc.IceInternal.Buffer buf) InputStream
(Communicator communicator, EncodingVersion encoding, com.zeroc.IceInternal.Buffer buf, boolean adopt) InputStream
(Communicator communicator, EncodingVersion encoding, ByteBuffer buf) This constructor uses the given communicator and encoding version.InputStream
(Communicator communicator, com.zeroc.IceInternal.Buffer buf) InputStream
(Communicator communicator, com.zeroc.IceInternal.Buffer buf, boolean adopt) InputStream
(Communicator communicator, ByteBuffer buf) This constructor uses the communicator's default encoding version.InputStream
(EncodingVersion encoding) This constructor uses the given encoding version.InputStream
(EncodingVersion encoding, byte[] data) This constructor uses the given encoding version.InputStream
(EncodingVersion encoding, com.zeroc.IceInternal.Buffer buf) InputStream
(EncodingVersion encoding, com.zeroc.IceInternal.Buffer buf, boolean adopt) InputStream
(EncodingVersion encoding, ByteBuffer buf) This constructor uses the given encoding version.InputStream
(com.zeroc.IceInternal.Buffer buf) InputStream
(com.zeroc.IceInternal.Buffer buf, boolean adopt) InputStream
(com.zeroc.IceInternal.Instance instance, EncodingVersion encoding) InputStream
(com.zeroc.IceInternal.Instance instance, EncodingVersion encoding, boolean direct) InputStream
(com.zeroc.IceInternal.Instance instance, EncodingVersion encoding, byte[] data) InputStream
(com.zeroc.IceInternal.Instance instance, EncodingVersion encoding, com.zeroc.IceInternal.Buffer buf, boolean adopt) InputStream
(com.zeroc.IceInternal.Instance instance, EncodingVersion encoding, ByteBuffer data) InputStream
(ByteBuffer buf) Constructing an InputStream without providing a communicator means the stream will use the default encoding version. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Releases any data retained by encapsulations.void
Ends the current encapsulation.endException
(boolean preserve) Marks the end of a user exception.void
endSlice()
Indicates that the end of a value or exception slice has been reached.endValue
(boolean preserve) Marks the end of a class instance.com.zeroc.IceInternal.Buffer
Retrieves the closure object associated with this stream.int
Determines the size of the current encapsulation, excluding the encapsulation header.Determines the current encoding version.void
initialize
(Communicator communicator) Initializes the stream to use the communicator's default encoding version.void
initialize
(Communicator communicator, EncodingVersion encoding) Initializes the stream to use the given communicator and encoding version.com.zeroc.IceInternal.Instance
instance()
boolean
isEmpty()
Determines whether the stream is empty.int
pos()
Determines the current position in the stream.void
pos
(int n) Sets the current position in the stream.int
readAndCheckSeqSize
(int minSize) Reads and validates a sequence size.byte[]
readBlob
(int sz) Reads a blob of bytes from the stream.boolean
readBool()
Extracts a boolean value from the stream.readBool
(int tag) Extracts an optional boolean value from the stream.boolean[]
Extracts a sequence of boolean values from the stream.Optional<boolean[]>
readBoolSeq
(int tag) Extracts an optional boolean sequence from the stream.byte
readByte()
Extracts a byte value from the stream.readByte
(int tag) Extracts an optional byte value from the stream.Returns a byte buffer representing a sequence of bytes.byte[]
Extracts a sequence of byte values from the stream.Optional<byte[]>
readByteSeq
(int tag) Extracts an optional byte sequence from the stream.double
Extracts a double value from the stream.readDouble
(int tag) Extracts an optional double value from the stream.Returns a double buffer representing a sequence of doubles.double[]
Extracts a sequence of double values from the stream.Optional<double[]>
readDoubleSeq
(int tag) Extracts an optional double sequence from the stream.byte[]
readEncapsulation
(EncodingVersion encoding) Returns a blob of bytes representing an encapsulation.int
readEnum
(int maxValue) Read an enumerated value.float
Extracts a float value from the stream.readFloat
(int tag) Extracts an optional float value from the stream.Returns a float buffer representing a sequence of floats.float[]
Extracts a sequence of float values from the stream.Optional<float[]>
readFloatSeq
(int tag) Extracts an optional float sequence from the stream.int
readInt()
Extracts an int value from the stream.readInt
(int tag) Extracts an optional int value from the stream.Returns an int buffer representing a sequence of ints.int[]
Extracts a sequence of int values from the stream.Optional<int[]>
readIntSeq
(int tag) Extracts an optional int sequence from the stream.long
readLong()
Extracts a long value from the stream.readLong
(int tag) Extracts an optional long value from the stream.Returns a long buffer representing a sequence of longs.long[]
Extracts a sequence of long values from the stream.Optional<long[]>
readLongSeq
(int tag) Extracts an optional long sequence from the stream.boolean
readOptional
(int tag, OptionalFormat expectedFormat) Determine if an optional value is available for reading.void
Indicates that unmarshaling is complete, except for any class instances.Extracts a proxy from the stream.readProxy
(int tag) Extracts an optional proxy from the stream.Extracts an optional proxy from the stream.<T extends ObjectPrx>
T<T extends Serializable>
Optional<T>readSerializable
(int tag, Class<T> cl) Extracts a optional serializable Java object from the stream.<T extends Serializable>
TreadSerializable
(Class<T> cl) Extracts a serializable Java object from the stream.short
Extracts a short value from the stream.readShort
(int tag) Extracts an optional short value from the stream.Returns a short buffer representing a sequence of shorts.short[]
Extracts a sequence of short values from the stream.Optional<short[]>
readShortSeq
(int tag) Extracts an optional short sequence from the stream.int
readSize()
Extracts a size from the stream.Extracts a string from the stream.readString
(int tag) Extracts an optional string value from the stream.String[]
Extracts a sequence of string values from the stream.readStringSeq
(int tag) Extracts an optional string sequence from the stream.void
Extracts an optional Slice value from the stream.<T extends Value>
voidExtracts an optional Slice value from the stream.void
Extracts a Slice value from the stream.<T extends Value>
voidExtracts a Slice value from the stream.void
reset()
Resets this stream.void
resize
(int sz) Resizes the stream to a new size.void
setClassResolver
(Function<String, Class<?>> r) Sets the class resolver, which the stream will use when attempting to unmarshal a value or exception.setClosure
(Object p) Associates a closure object with this stream.void
Sets the compact ID resolver to use when unmarshaling value and exception instances.void
Sets the logger to use when logging trace messages.void
setSliceValues
(boolean b) Determines the behavior of the stream when extracting instances of Slice classes.void
setTraceSlicing
(boolean b) Determines whether the stream logs messages about slicing instances of Slice values.void
Sets the value factory manager to use when unmarshaling value instances.int
size()
Determines the current size of the stream.void
skip
(int size) Skip the given number of bytes.Skips an empty encapsulation.Skips over an encapsulation.void
skipSize()
Skip over a size value.void
Skips over a value or exception slice.Reads the start of an encapsulation.void
Marks the start of a user exception.Reads the start of a value or exception slice.void
Marks the start of a class instance.void
swap
(InputStream other) Swaps the contents of one stream with another.void
Extracts a user exception from the stream and throws it.void
throwException
(UserExceptionFactory factory) Extracts a user exception from the stream and throws it.
-
Constructor Details
-
InputStream
public InputStream()Constructing an InputStream without providing a communicator means the stream will use the default encoding version. A communicator is required in order to unmarshal proxies. You can supply a communicator later by calling initialize(). -
InputStream
public InputStream(byte[] data) Constructing an InputStream without providing a communicator means the stream will use the default encoding version. A communicator is required in order to unmarshal proxies. You can supply a communicator later by calling initialize().- Parameters:
data
- The byte array containing encoded Slice types.
-
InputStream
Constructing an InputStream without providing a communicator means the stream will use the default encoding version. A communicator is required in order to unmarshal proxies. You can supply a communicator later by calling initialize().- Parameters:
buf
- The byte buffer containing encoded Slice types.
-
InputStream
public InputStream(com.zeroc.IceInternal.Buffer buf) -
InputStream
public InputStream(com.zeroc.IceInternal.Buffer buf, boolean adopt) -
InputStream
This constructor uses the communicator's default encoding version.- Parameters:
communicator
- The communicator to use when initializing the stream.
-
InputStream
This constructor uses the communicator's default encoding version.- Parameters:
communicator
- The communicator to use when initializing the stream.data
- The byte array containing encoded Slice types.
-
InputStream
This constructor uses the communicator's default encoding version.- Parameters:
communicator
- The communicator to use when initializing the stream.buf
- The byte buffer containing encoded Slice types.
-
InputStream
-
InputStream
-
InputStream
This constructor uses the given encoding version.- Parameters:
encoding
- The encoding version to use when extracting data.
-
InputStream
This constructor uses the given encoding version.- Parameters:
encoding
- The encoding version to use when extracting data.data
- The byte array containing encoded Slice types.
-
InputStream
This constructor uses the given encoding version.- Parameters:
encoding
- The encoding version to use when extracting data.buf
- The byte buffer containing encoded Slice types.
-
InputStream
-
InputStream
-
InputStream
This constructor uses the given communicator and encoding version.- Parameters:
communicator
- The communicator to use when initializing the stream.encoding
- The desired encoding version.
-
InputStream
This constructor uses the given communicator and encoding version.- Parameters:
communicator
- The communicator to use when initializing the stream.encoding
- The desired encoding version.data
- The byte array containing encoded Slice types.
-
InputStream
This constructor uses the given communicator and encoding version.- Parameters:
communicator
- The communicator to use when initializing the stream.encoding
- The desired encoding version.buf
- The byte buffer containing encoded Slice types.
-
InputStream
public InputStream(Communicator communicator, EncodingVersion encoding, com.zeroc.IceInternal.Buffer buf) -
InputStream
public InputStream(Communicator communicator, EncodingVersion encoding, com.zeroc.IceInternal.Buffer buf, boolean adopt) -
InputStream
-
InputStream
public InputStream(com.zeroc.IceInternal.Instance instance, EncodingVersion encoding, boolean direct) -
InputStream
-
InputStream
public InputStream(com.zeroc.IceInternal.Instance instance, EncodingVersion encoding, ByteBuffer data) -
InputStream
public InputStream(com.zeroc.IceInternal.Instance instance, EncodingVersion encoding, com.zeroc.IceInternal.Buffer buf, boolean adopt)
-
-
Method Details
-
initialize
Initializes the stream to use the communicator's default encoding version.- Parameters:
communicator
- The communicator to use when initializing the stream.
-
initialize
Initializes the stream to use the given communicator and encoding version.- Parameters:
communicator
- The communicator to use when initializing the stream.encoding
- The desired encoding version.
-
reset
public void reset()Resets this stream. This method allows the stream to be reused, to avoid creating unnecessary garbage. -
clear
public void clear()Releases any data retained by encapsulations. Thereset()
method internally callsclear
. -
setValueFactoryManager
Sets the value factory manager to use when unmarshaling value instances. If the stream was initialized with a communicator, the communicator's value factory manager will be used by default.- Parameters:
vfm
- The value factory manager.
-
setLogger
Sets the logger to use when logging trace messages. If the stream was initialized with a communicator, the communicator's logger will be used by default.- Parameters:
logger
- The logger to use for logging trace messages.
-
setCompactIdResolver
Sets the compact ID resolver to use when unmarshaling value and exception instances. If the stream was initialized with a communicator, the communicator's resolver will be used by default.- Parameters:
r
- The compact ID resolver.
-
setClassResolver
Sets the class resolver, which the stream will use when attempting to unmarshal a value or exception. If the stream was initialized with a communicator, the communicator's resolver will be used by default.- Parameters:
r
- The class resolver.
-
setSliceValues
public void setSliceValues(boolean b) Determines the behavior of the stream when extracting instances of Slice classes. An instance is "sliced" when a factory cannot be found for a Slice type ID. The stream's default behavior is to slice instances.- Parameters:
b
- Iftrue
(the default), slicing is enabled; iffalse
, slicing is disabled. If slicing is disabled and the stream encounters a Slice type ID during decoding for which no value factory is installed, it raisesNoValueFactoryException
.
-
setTraceSlicing
public void setTraceSlicing(boolean b) Determines whether the stream logs messages about slicing instances of Slice values.- Parameters:
b
- True to enable logging, false to disable logging.
-
getClosure
Retrieves the closure object associated with this stream.- Returns:
- The closure object.
-
setClosure
Associates a closure object with this stream.- Parameters:
p
- The new closure object.- Returns:
- The previous closure object, or null.
-
instance
public com.zeroc.IceInternal.Instance instance() -
swap
Swaps the contents of one stream with another.- Parameters:
other
- The other stream.
-
resize
public void resize(int sz) Resizes the stream to a new size.- Parameters:
sz
- The new size.
-
getBuffer
public com.zeroc.IceInternal.Buffer getBuffer() -
startValue
public void startValue()Marks the start of a class instance. -
endValue
Marks the end of a class instance.- Parameters:
preserve
- Pass true and the stream will preserve the unknown slices of the instance, or false to discard the unknown slices.- Returns:
- An object that encapsulates the unknown slice data.
-
startException
public void startException()Marks the start of a user exception. -
endException
Marks the end of a user exception.- Parameters:
preserve
- Pass true and the stream will preserve the unknown slices of the exception, or false to discard the unknown slices.- Returns:
- An object that encapsulates the unknown slice data.
-
startEncapsulation
Reads the start of an encapsulation.- Returns:
- The encoding version used by the encapsulation.
-
endEncapsulation
public void endEncapsulation()Ends the current encapsulation. -
skipEmptyEncapsulation
Skips an empty encapsulation.- Returns:
- The encapsulation's encoding version.
-
readEncapsulation
Returns a blob of bytes representing an encapsulation. The encapsulation's encoding version is returned in the argument.- Parameters:
encoding
- The encapsulation's encoding version.- Returns:
- The encoded encapsulation.
-
getEncoding
Determines the current encoding version.- Returns:
- The encoding version.
-
getEncapsulationSize
public int getEncapsulationSize()Determines the size of the current encapsulation, excluding the encapsulation header.- Returns:
- The size of the encapsulated data.
-
skipEncapsulation
Skips over an encapsulation.- Returns:
- The encoding version of the skipped encapsulation.
-
startSlice
Reads the start of a value or exception slice.- Returns:
- The Slice type ID for this slice.
-
endSlice
public void endSlice()Indicates that the end of a value or exception slice has been reached. -
skipSlice
public void skipSlice()Skips over a value or exception slice. -
readPendingValues
public void readPendingValues()Indicates that unmarshaling is complete, except for any class instances. The application must call this method only if the stream actually contains class instances. CallingreadPendingValues
triggers the calls to consumers provided withreadValue(java.util.function.Consumer<T>, java.lang.Class<T>)
to inform the application that unmarshaling of an instance is complete. -
readSize
public int readSize()Extracts a size from the stream.- Returns:
- The extracted size.
-
readAndCheckSeqSize
public int readAndCheckSeqSize(int minSize) Reads and validates a sequence size.- Parameters:
minSize
- The minimum size required by the sequence type.- Returns:
- The extracted size.
-
readBlob
public byte[] readBlob(int sz) Reads a blob of bytes from the stream.- Parameters:
sz
- The number of bytes to read.- Returns:
- The requested bytes as a byte array.
-
readOptional
Determine if an optional value is available for reading.- Parameters:
tag
- The tag associated with the value.expectedFormat
- The optional format for the value.- Returns:
- True if the value is present, false otherwise.
-
readByte
public byte readByte()Extracts a byte value from the stream.- Returns:
- The extracted byte.
-
readByte
Extracts an optional byte value from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readByteSeq
public byte[] readByteSeq()Extracts a sequence of byte values from the stream.- Returns:
- The extracted byte sequence.
-
readByteSeq
Extracts an optional byte sequence from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readByteBuffer
Returns a byte buffer representing a sequence of bytes. This method does not copy the data.- Returns:
- A byte buffer "slice" of the internal buffer.
-
readSerializable
Extracts a serializable Java object from the stream.- Type Parameters:
T
- The serializable type.- Parameters:
cl
- The class for the serializable type.- Returns:
- The deserialized Java object.
-
readSerializable
Extracts a optional serializable Java object from the stream.- Type Parameters:
T
- The serializable type.- Parameters:
tag
- The numeric tag associated with the value.cl
- The class for the serializable type.- Returns:
- The optional value (if any).
-
readBool
public boolean readBool()Extracts a boolean value from the stream.- Returns:
- The extracted boolean.
-
readBool
Extracts an optional boolean value from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readBoolSeq
public boolean[] readBoolSeq()Extracts a sequence of boolean values from the stream.- Returns:
- The extracted boolean sequence.
-
readBoolSeq
Extracts an optional boolean sequence from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readShort
public short readShort()Extracts a short value from the stream.- Returns:
- The extracted short.
-
readShort
Extracts an optional short value from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readShortSeq
public short[] readShortSeq()Extracts a sequence of short values from the stream.- Returns:
- The extracted short sequence.
-
readShortSeq
Extracts an optional short sequence from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readShortBuffer
Returns a short buffer representing a sequence of shorts. This method does not copy the data.- Returns:
- A short buffer "slice" of the internal buffer.
-
readInt
public int readInt()Extracts an int value from the stream.- Returns:
- The extracted int.
-
readInt
Extracts an optional int value from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readIntSeq
public int[] readIntSeq()Extracts a sequence of int values from the stream.- Returns:
- The extracted int sequence.
-
readIntSeq
Extracts an optional int sequence from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readIntBuffer
Returns an int buffer representing a sequence of ints. This method does not copy the data.- Returns:
- An int buffer "slice" of the internal buffer.
-
readLong
public long readLong()Extracts a long value from the stream.- Returns:
- The extracted long.
-
readLong
Extracts an optional long value from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readLongSeq
public long[] readLongSeq()Extracts a sequence of long values from the stream.- Returns:
- The extracted long sequence.
-
readLongSeq
Extracts an optional long sequence from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readLongBuffer
Returns a long buffer representing a sequence of longs. This method does not copy the data.- Returns:
- A long buffer "slice" of the internal buffer.
-
readFloat
public float readFloat()Extracts a float value from the stream.- Returns:
- The extracted float.
-
readFloat
Extracts an optional float value from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readFloatSeq
public float[] readFloatSeq()Extracts a sequence of float values from the stream.- Returns:
- The extracted float sequence.
-
readFloatSeq
Extracts an optional float sequence from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readFloatBuffer
Returns a float buffer representing a sequence of floats. This method does not copy the data.- Returns:
- A float buffer "slice" of the internal buffer.
-
readDouble
public double readDouble()Extracts a double value from the stream.- Returns:
- The extracted double.
-
readDouble
Extracts an optional double value from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readDoubleSeq
public double[] readDoubleSeq()Extracts a sequence of double values from the stream.- Returns:
- The extracted double sequence.
-
readDoubleSeq
Extracts an optional double sequence from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readDoubleBuffer
Returns a double buffer representing a sequence of doubles. This method does not copy the data.- Returns:
- A double buffer "slice" of the internal buffer.
-
readString
Extracts a string from the stream.- Returns:
- The extracted string.
-
readString
Extracts an optional string value from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readStringSeq
Extracts a sequence of string values from the stream.- Returns:
- The extracted string sequence.
-
readStringSeq
Extracts an optional string sequence from the stream.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readProxy
Extracts a proxy from the stream. The stream must have been initialized with a communicator.- Returns:
- The extracted proxy.
-
readProxy
-
readProxy
Extracts an optional proxy from the stream. The stream must have been initialized with a communicator.- Parameters:
tag
- The numeric tag associated with the value.- Returns:
- The optional value (if any).
-
readProxy
Extracts an optional proxy from the stream. The stream must have been initialized with a communicator.- Type Parameters:
T
- The proxy type.- Parameters:
tag
- The numeric tag associated with the value.cast
- The uncheckedCast function to call on the unmarshaled proxy to obtain the correct proxy type.- Returns:
- The optional value (if any).
-
readEnum
public int readEnum(int maxValue) Read an enumerated value.- Parameters:
maxValue
- The maximum enumerator value in the definition.- Returns:
- The enumerator.
-
readValue
Extracts a Slice value from the stream.- Type Parameters:
T
- The value type.- Parameters:
cb
- The consumer to notify when the extracted instance is available. The stream extracts Slice values in stages. The Ice run time calls accept on the consumer when the corresponding instance has been fully unmarshaled.cls
- The type of the Ice.Value to unmarshal.
-
readValue
Extracts a Slice value from the stream.- Parameters:
cb
- The consumer to notify when the extracted instance is available. The stream extracts Slice values in stages. The Ice run time calls accept on the consumer when the corresponding instance has been fully unmarshaled.
-
readValue
Extracts an optional Slice value from the stream.- Type Parameters:
T
- The value type.- Parameters:
tag
- The numeric tag associated with the value.cb
- The consumer to notify when the extracted instance is available. The stream extracts Slice values in stages. The Ice run time calls accept on the consumer when the corresponding instance has been fully unmarshaled.cls
- The type of the Ice.Value to unmarshal.
-
readValue
Extracts an optional Slice value from the stream.- Parameters:
tag
- The numeric tag associated with the value.cb
- The consumer to notify when the extracted instance is available. The stream extracts Slice values in stages. The Ice run time calls accept on the consumer when the corresponding instance has been fully unmarshaled.
-
throwException
Extracts a user exception from the stream and throws it.- Throws:
UserException
- The user exception that was unmarshaled.
-
throwException
Extracts a user exception from the stream and throws it. The caller can supply a factory to instantiate exception instances.- Parameters:
factory
- The user exception factory, or null to use the stream's default behavior.- Throws:
UserException
- The user exception that was unmarshaled.
-
skip
public void skip(int size) Skip the given number of bytes.- Parameters:
size
- The number of bytes to skip.
-
skipSize
public void skipSize()Skip over a size value. -
pos
public int pos()Determines the current position in the stream.- Returns:
- The current position.
-
pos
public void pos(int n) Sets the current position in the stream.- Parameters:
n
- The new position.
-
size
public int size()Determines the current size of the stream.- Returns:
- The current size.
-
isEmpty
public boolean isEmpty()Determines whether the stream is empty.- Returns:
- True if the internal buffer has no data, false otherwise.
-