Package org.apache.qpid.protonj2.codec
Interface StreamDecoder
-
- All Known Implementing Classes:
ProtonStreamDecoder
public interface StreamDecoder
Decode AMQP types from aInputStream
instance. When reading from an input stream care should be take to capture the stream position and state and reset if not enough bytes are available for the decoder to complete reading an encoded type as the decoder is not required to handle partially available type encodings.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StreamDecoderState
getCachedDecoderState()
Return a singletonStreamDecoderState
instance that is meant to be shared within single threaded decoder interactions.StreamDecoderState
newDecoderState()
Creates a newStreamDecoderState
instance that can be used when interacting with the Decoder.StreamTypeDecoder<?>
peekNextTypeDecoder(InputStream stream, StreamDecoderState state)
Peeks ahead in the givenInputStream
instance and returns aTypeDecoder
that can read the next encoded AMQP type from the stream's bytes.Binary
readBinary(InputStream stream, StreamDecoderState state)
Reads an encodedBinary
value from the givenInputStream
assuming that the next value in the byte stream is that type.ProtonBuffer
readBinaryAsBuffer(InputStream stream, StreamDecoderState state)
Reads an encodedBinary
value from the givenInputStream
assuming that the next value in the byte stream is that type.Boolean
readBoolean(InputStream stream, StreamDecoderState state)
Reads an encodedBoolean
value from the givenInputStream
assuming that the next value in the byte stream is that type.boolean
readBoolean(InputStream stream, StreamDecoderState state, boolean defaultValue)
Reads an encodedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type.Byte
readByte(InputStream stream, StreamDecoderState state)
Reads an encodedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type.byte
readByte(InputStream stream, StreamDecoderState state, byte defaultValue)
Reads an encodedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type.Character
readCharacter(InputStream stream, StreamDecoderState state)
Reads an encodedCharacter
value from the givenInputStream
assuming that the next value in the byte stream is that type.char
readCharacter(InputStream stream, StreamDecoderState state, char defaultValue)
Reads an encodedCharacter
value from the givenInputStream
assuming that the next value in the byte stream is that type.Decimal128
readDecimal128(InputStream stream, StreamDecoderState state)
Reads an encodedDecimal128
value from the givenInputStream
assuming that the next value in the byte stream is that type.Decimal32
readDecimal32(InputStream stream, StreamDecoderState state)
Reads an encodedDecimal32
value from the givenInputStream
assuming that the next value in the byte stream is that type.Decimal64
readDecimal64(InputStream stream, StreamDecoderState state)
Reads an encodedDecimal64
value from the givenInputStream
assuming that the next value in the byte stream is that type.DeliveryTag
readDeliveryTag(InputStream stream, StreamDecoderState state)
This method expects to read aBinary
encoded type from the provided stream and constructs aDeliveryTag
type that wraps the bytes encoded.Double
readDouble(InputStream stream, StreamDecoderState state)
Reads an encodedDouble
value from the givenInputStream
assuming that the next value in the byte stream is that type.double
readDouble(InputStream stream, StreamDecoderState state, double defaultValue)
Reads an encodedDouble
value from the givenInputStream
assuming that the next value in the byte stream is that type.Float
readFloat(InputStream stream, StreamDecoderState state)
Reads an encodedFloat
value from the givenInputStream
assuming that the next value in the byte stream is that type.float
readFloat(InputStream stream, StreamDecoderState state, float defaultValue)
Reads an encodedFloat
value from the givenInputStream
assuming that the next value in the byte stream is that type.Integer
readInteger(InputStream stream, StreamDecoderState state)
Reads an encodedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type.int
readInteger(InputStream stream, StreamDecoderState state, int defaultValue)
Reads an encodedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type.<V> List<V>
readList(InputStream stream, StreamDecoderState state)
Reads an encodedList
value from the givenInputStream
assuming that the next value in the byte stream is that type.Long
readLong(InputStream stream, StreamDecoderState state)
Reads an encodedLong
value from the givenInputStream
assuming that the next value in the byte stream is that type.long
readLong(InputStream stream, StreamDecoderState state, long defaultValue)
Reads an encodedLong
value from the givenInputStream
assuming that the next value in the byte stream is that type.<K,V>
Map<K,V>readMap(InputStream stream, StreamDecoderState state)
Reads an encodedMap
value from the givenInputStream
assuming that the next value in the byte stream is that type.<T> T[]
readMultiple(InputStream stream, StreamDecoderState state, Class<T> clazz)
Reads one or more encoded values from the givenInputStream
an return it as an array ofObject
instances which the caller must then interpret.StreamTypeDecoder<?>
readNextTypeDecoder(InputStream stream, StreamDecoderState state)
Reads from the givenInputStream
instance and returns aStreamTypeDecoder
that can read the next encoded AMQP type from the stream's bytes.Object
readObject(InputStream stream, StreamDecoderState state)
Reads an encoded value from the givenInputStream
an return it as anObject
which the caller must then interpret.<T> T
readObject(InputStream stream, StreamDecoderState state, Class<T> clazz)
Reads an encoded value from the givenInputStream
an return it as anObject
which the caller must then interpret.Short
readShort(InputStream stream, StreamDecoderState state)
Reads an encodedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type.short
readShort(InputStream stream, StreamDecoderState state, short defaultValue)
Reads an encodedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type.String
readString(InputStream stream, StreamDecoderState state)
Reads an encodedString
value from the givenInputStream
assuming that the next value in the byte stream is that type.Symbol
readSymbol(InputStream stream, StreamDecoderState state)
Reads an encodedSymbol
value from the givenInputStream
assuming that the next value in the byte stream is that type.String
readSymbol(InputStream stream, StreamDecoderState state, String defaultValue)
Reads an encodedString
value from the givenInputStream
assuming that the next value in the byte stream is that type.Long
readTimestamp(InputStream stream, StreamDecoderState state)
Reads an encoded AMQP time stamp value from the givenInputStream
assuming that the next value in the byte stream is that type.long
readTimestamp(InputStream stream, StreamDecoderState state, long defaultValue)
Reads an encoded AMQP time stamp value from the givenInputStream
assuming that the next value in the byte stream is that type.UnsignedByte
readUnsignedByte(InputStream stream, StreamDecoderState state)
Reads an encodedUnsignedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type.byte
readUnsignedByte(InputStream stream, StreamDecoderState state, byte defaultValue)
Reads an encodedUnsignedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type.UnsignedInteger
readUnsignedInteger(InputStream stream, StreamDecoderState state)
Reads an encodedUnsignedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type.int
readUnsignedInteger(InputStream stream, StreamDecoderState state, int defaultValue)
Reads an encodedUnsignedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type.long
readUnsignedInteger(InputStream stream, StreamDecoderState state, long defaultValue)
Reads an encodedUnsignedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type.UnsignedLong
readUnsignedLong(InputStream stream, StreamDecoderState state)
Reads an encodedUnsignedLong
value from the givenInputStream
assuming that the next value in the byte stream is that type.long
readUnsignedLong(InputStream stream, StreamDecoderState state, long defaultValue)
Reads an encodedUnsignedLong
value from the givenInputStream
assuming that the next value in the byte stream is that type.UnsignedShort
readUnsignedShort(InputStream stream, StreamDecoderState state)
Reads an encodedUnsignedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type.int
readUnsignedShort(InputStream stream, StreamDecoderState state, int defaultValue)
Reads an encodedUnsignedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type.short
readUnsignedShort(InputStream stream, StreamDecoderState state, short defaultValue)
Reads an encodedUnsignedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type.UUID
readUUID(InputStream stream, StreamDecoderState state)
Reads an encodedUUID
value from the givenInputStream
assuming that the next value in the byte stream is that type.<V> StreamDecoder
registerDescribedTypeDecoder(StreamDescribedTypeDecoder<V> decoder)
Allows customStreamDescribedTypeDecoder
instances to be registered with thisStreamDecoder
which will be used if the described type encoding is encountered during decode operations.
-
-
-
Method Detail
-
newDecoderState
StreamDecoderState newDecoderState()
Creates a newStreamDecoderState
instance that can be used when interacting with the Decoder. For decoding that occurs on more than one thread while sharing a singleStreamDecoder
instance a different state object per thread is required as theStreamDecoderState
object can retain some state information during the decode process that could be corrupted if more than one thread were to share a single instance. For single threaded decoding work theStreamDecoder
offers a utility cachedStreamDecoderState
API that will return the same instance on each call which can reduce allocation overhead and make using theStreamDecoder
simpler.- Returns:
- a newly constructed
EncoderState
instance.
-
getCachedDecoderState
StreamDecoderState getCachedDecoderState()
Return a singletonStreamDecoderState
instance that is meant to be shared within single threaded decoder interactions. If more than one thread makes use of this cachedStreamDecoderState
the results of any decoding done using this state object is not guaranteed to be correct. The returned instance will have its reset method called to ensure that any previously stored state data is cleared before the next use.- Returns:
- a cached
StreamDecoderState
linked to this Decoder instance that has been reset.
-
readBoolean
Boolean readBoolean(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedBoolean
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readBoolean
boolean readBoolean(InputStream stream, StreamDecoderState state, boolean defaultValue) throws DecodeException
Reads an encodedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readByte
Byte readByte(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readByte
byte readByte(InputStream stream, StreamDecoderState state, byte defaultValue) throws DecodeException
Reads an encodedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedByte
UnsignedByte readUnsignedByte(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUnsignedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedByte
byte readUnsignedByte(InputStream stream, StreamDecoderState state, byte defaultValue) throws DecodeException
Reads an encodedUnsignedByte
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readCharacter
Character readCharacter(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedCharacter
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readCharacter
char readCharacter(InputStream stream, StreamDecoderState state, char defaultValue) throws DecodeException
Reads an encodedCharacter
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readDecimal32
Decimal32 readDecimal32(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedDecimal32
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readDecimal64
Decimal64 readDecimal64(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedDecimal64
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readDecimal128
Decimal128 readDecimal128(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedDecimal128
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readShort
Short readShort(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readShort
short readShort(InputStream stream, StreamDecoderState state, short defaultValue) throws DecodeException
Reads an encodedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedShort
UnsignedShort readUnsignedShort(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUnsignedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedShort
short readUnsignedShort(InputStream stream, StreamDecoderState state, short defaultValue) throws DecodeException
Reads an encodedUnsignedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedShort
int readUnsignedShort(InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeException
Reads an encodedUnsignedShort
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readInteger
Integer readInteger(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readInteger
int readInteger(InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeException
Reads an encodedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedInteger
UnsignedInteger readUnsignedInteger(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUnsignedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedInteger
int readUnsignedInteger(InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeException
Reads an encodedUnsignedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedInteger
long readUnsignedInteger(InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeException
Reads an encodedUnsignedInteger
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readLong
Long readLong(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedLong
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readLong
long readLong(InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeException
Reads an encodedLong
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedLong
UnsignedLong readUnsignedLong(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUnsignedLong
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUnsignedLong
long readUnsignedLong(InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeException
Reads an encodedUnsignedLong
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readFloat
Float readFloat(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedFloat
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readFloat
float readFloat(InputStream stream, StreamDecoderState state, float defaultValue) throws DecodeException
Reads an encodedFloat
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readDouble
Double readDouble(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedDouble
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readDouble
double readDouble(InputStream stream, StreamDecoderState state, double defaultValue) throws DecodeException
Reads an encodedDouble
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readBinary
Binary readBinary(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedBinary
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readBinaryAsBuffer
ProtonBuffer readBinaryAsBuffer(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedBinary
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source and returned in a
ProtonBuffer
. - Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readDeliveryTag
DeliveryTag readDeliveryTag(InputStream stream, StreamDecoderState state) throws DecodeException
This method expects to read aBinary
encoded type from the provided stream and constructs aDeliveryTag
type that wraps the bytes encoded. If the encoding is a NULL AMQP type then this method returnsnull
.- Parameters:
stream
- TheInputStream
to read a Binary encoded value fromstate
- The current encoding state.- Returns:
- a new DeliveryTag instance or null if an AMQP NULL encoding is found.
- Throws:
DecodeException
- if an error occurs while decoding theDeliveryTag
instance.
-
readString
String readString(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedString
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readSymbol
Symbol readSymbol(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedSymbol
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readSymbol
String readSymbol(InputStream stream, StreamDecoderState state, String defaultValue) throws DecodeException
Reads an encodedString
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readTimestamp
Long readTimestamp(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encoded AMQP time stamp value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source and return a
Long
with the time value. - Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readTimestamp
long readTimestamp(InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeException
Reads an encoded AMQP time stamp value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.defaultValue
- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readUUID
UUID readUUID(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUUID
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readObject
Object readObject(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encoded value from the givenInputStream
an return it as anObject
which the caller must then interpret.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not able to be decoded.
-
readObject
<T> T readObject(InputStream stream, StreamDecoderState state, Class<T> clazz) throws DecodeException
Reads an encoded value from the givenInputStream
an return it as anObject
which the caller must then interpret.- Type Parameters:
T
- the type that will be used when casting and returning the decoded value.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.clazz
- TheClass
type that should be used to cast the returned value.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not able to be decoded.
-
readMultiple
<T> T[] readMultiple(InputStream stream, StreamDecoderState state, Class<T> clazz) throws DecodeException
Reads one or more encoded values from the givenInputStream
an return it as an array ofObject
instances which the caller must then interpret.- Type Parameters:
T
- the type that will be used when casting and returning the decoded value.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.clazz
- TheClass
type that should be used to cast the returned array.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not able to be decoded.
-
readMap
<K,V> Map<K,V> readMap(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedMap
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Type Parameters:
K
- The key type for the map that is being read.V
- The value type for the map that is being read.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readList
<V> List<V> readList(InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedList
value from the givenInputStream
assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Type Parameters:
V
- The value type for the list that is being read.- Parameters:
stream
- TheInputStream
where the read operation takes place.state
- TheDecoderState
that the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException
- if the value fails to decode is not of the expected type,
-
readNextTypeDecoder
StreamTypeDecoder<?> readNextTypeDecoder(InputStream stream, StreamDecoderState state) throws DecodeException
Reads from the givenInputStream
instance and returns aStreamTypeDecoder
that can read the next encoded AMQP type from the stream's bytes. If an error occurs attempting to read and determine the next type decoder anDecodeException
is thrown.- Parameters:
stream
- The stream to read from to determine the nextTypeDecoder
needed.state
- TheDecoderState
value that can be used for intermediate decoding tasks.- Returns:
- a
StreamTypeDecoder
instance that can read the next type in the stream. - Throws:
DecodeException
- if an error occurs while reading the next type decoder.
-
peekNextTypeDecoder
StreamTypeDecoder<?> peekNextTypeDecoder(InputStream stream, StreamDecoderState state) throws DecodeException
Peeks ahead in the givenInputStream
instance and returns aTypeDecoder
that can read the next encoded AMQP type from the stream's bytes. If an error occurs attempting to read and determine the next type decoder anDecodeException
is thrown. The underlying stream is not modified as a result of the peek operation and the returnedTypeDecoder
will fail to properly read the type until the encoding bytes are read. If the provided stream does not offer support for the mark API than this method can throw anUnsupportedOperationException
.- Parameters:
stream
- The stream to read from to determine the nextTypeDecoder
needed.state
- TheDecoderState
value that can be used for intermediate decoding tasks.- Returns:
- a
TypeDecoder
instance that can provide insight into the next type in the stream. - Throws:
DecodeException
- if an error occurs while peeking ahead for the next type decoder.
-
registerDescribedTypeDecoder
<V> StreamDecoder registerDescribedTypeDecoder(StreamDescribedTypeDecoder<V> decoder)
Allows customStreamDescribedTypeDecoder
instances to be registered with thisStreamDecoder
which will be used if the described type encoding is encountered during decode operations.- Type Parameters:
V
- The type that the decoder reads.- Parameters:
decoder
- AStreamDescribedTypeDecoder
instance to be registered with thisStreamDecoder
- Returns:
- this
StreamDecoder
instance.
-
-