java.lang.Object
com.zeroc.Ice.InputStream
Interface to read sequence of bytes encoded using the Slice encoding and recreate the corresponding
Slice types.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInputStream
(Communicator communicator, byte[] data) This constructor uses the communicator's default encoding version.InputStream
(Communicator communicator, EncodingVersion encoding, byte[] data) This constructor uses the given communicator and encoding version.InputStream
(Communicator communicator, EncodingVersion encoding, ByteBuffer buf) This constructor uses the given communicator and encoding version.InputStream
(Communicator communicator, ByteBuffer buf) This constructor uses the communicator's default encoding version. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Releases any data retained by encapsulations.void
Ends the current encapsulation.Marks the end of a user exception.void
endSlice()
Indicates that the end of a value or exception slice has been reached.endValue()
Marks the end of a class instance.int
Determines the size of the current encapsulation, excluding the encapsulation header.Determines the current encoding version.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>
TExtracts a proxy from the stream.<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 a Slice value from the stream.<T extends Value>
voidExtracts a Slice value from the stream.void
reset()
Resets this stream.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.void
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.
-
Constructor Details
-
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
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.
-
-
Method Details
-
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
. -
swap
Swaps the contents of one stream with another.- Parameters:
other
- The other stream.
-
startValue
public void startValue()Marks the start of a class instance. -
endValue
Marks the end of a class instance.- 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.- 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
public void startSlice()Reads the start of a value or exception 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
Extracts a proxy from the stream. The stream must have been initialized with a communicator.- Type Parameters:
T
- the proxy type- Parameters:
cast
- the uncheckedCast function to call on the unmarshaled proxy to obtain the correct proxy type- Returns:
- The extracted proxy.
-
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.
-
throwException
Extracts a user exception from the stream and throws it.- 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.
-