Class ProtonStreamDecoder
- java.lang.Object
-
- org.apache.qpid.protonj2.codec.decoders.ProtonStreamDecoder
-
- All Implemented Interfaces:
StreamDecoder
public final class ProtonStreamDecoder extends java.lang.Object implements StreamDecoder
The default AMQP Decoder implementation.
-
-
Constructor Summary
Constructors Constructor Description ProtonStreamDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProtonStreamDecoderState
getCachedDecoderState()
Return a singletonStreamDecoderState
instance that is meant to be shared within single threaded decoder interactions.ProtonStreamDecoderState
newDecoderState()
Creates a newStreamDecoderState
instance that can be used when interacting with the Decoder.StreamTypeDecoder<?>
peekNextTypeDecoder(java.io.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(java.io.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(java.io.InputStream stream, StreamDecoderState state)
Reads an encodedBinary
value from the givenInputStream
assuming that the next value in the byte stream is that type.java.lang.Boolean
readBoolean(java.io.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(java.io.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.java.lang.Byte
readByte(java.io.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(java.io.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.java.lang.Character
readCharacter(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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.java.lang.Double
readDouble(java.io.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(java.io.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.java.lang.Float
readFloat(java.io.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(java.io.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.java.lang.Integer
readInteger(java.io.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(java.io.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> java.util.List<V>
readList(java.io.InputStream stream, StreamDecoderState state)
Reads an encodedList
value from the givenInputStream
assuming that the next value in the byte stream is that type.java.lang.Long
readLong(java.io.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(java.io.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>
java.util.Map<K,V>readMap(java.io.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(java.io.InputStream stream, StreamDecoderState state, java.lang.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(java.io.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.java.lang.Object
readObject(java.io.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(java.io.InputStream stream, StreamDecoderState state, java.lang.Class<T> clazz)
Reads an encoded value from the givenInputStream
an return it as anObject
which the caller must then interpret.java.lang.Short
readShort(java.io.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(java.io.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.java.lang.String
readString(java.io.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(java.io.InputStream stream, StreamDecoderState state)
Reads an encodedSymbol
value from the givenInputStream
assuming that the next value in the byte stream is that type.java.lang.String
readSymbol(java.io.InputStream stream, StreamDecoderState state, java.lang.String defaultValue)
Reads an encodedString
value from the givenInputStream
assuming that the next value in the byte stream is that type.java.lang.Long
readTimestamp(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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(java.io.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.java.util.UUID
readUUID(java.io.InputStream stream, StreamDecoderState state)
Reads an encodedUUID
value from the givenInputStream
assuming that the next value in the byte stream is that type.<V> ProtonStreamDecoder
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
public ProtonStreamDecoderState newDecoderState()
Description copied from interface:StreamDecoder
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.- Specified by:
newDecoderState
in interfaceStreamDecoder
- Returns:
- a newly constructed
EncoderState
instance.
-
getCachedDecoderState
public ProtonStreamDecoderState getCachedDecoderState()
Description copied from interface:StreamDecoder
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.- Specified by:
getCachedDecoderState
in interfaceStreamDecoder
- Returns:
- a cached
StreamDecoderState
linked to this Decoder instance that has been reset.
-
readObject
public java.lang.Object readObject(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
Reads an encoded value from the givenInputStream
an return it as anObject
which the caller must then interpret.- Specified by:
readObject
in interfaceStreamDecoder
- 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
public <T> T readObject(java.io.InputStream stream, StreamDecoderState state, java.lang.Class<T> clazz) throws DecodeException
Description copied from interface:StreamDecoder
Reads an encoded value from the givenInputStream
an return it as anObject
which the caller must then interpret.- Specified by:
readObject
in interfaceStreamDecoder
- 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
public <T> T[] readMultiple(java.io.InputStream stream, StreamDecoderState state, java.lang.Class<T> clazz) throws DecodeException
Description copied from interface:StreamDecoder
Reads one or more encoded values from the givenInputStream
an return it as an array ofObject
instances which the caller must then interpret.- Specified by:
readMultiple
in interfaceStreamDecoder
- 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.
-
readNextTypeDecoder
public StreamTypeDecoder<?> readNextTypeDecoder(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readNextTypeDecoder
in interfaceStreamDecoder
- 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
public StreamTypeDecoder<?> peekNextTypeDecoder(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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
.- Specified by:
peekNextTypeDecoder
in interfaceStreamDecoder
- 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
public <V> ProtonStreamDecoder registerDescribedTypeDecoder(StreamDescribedTypeDecoder<V> decoder)
Description copied from interface:StreamDecoder
Allows customStreamDescribedTypeDecoder
instances to be registered with thisStreamDecoder
which will be used if the described type encoding is encountered during decode operations.- Specified by:
registerDescribedTypeDecoder
in interfaceStreamDecoder
- Type Parameters:
V
- The type that the decoder reads.- Parameters:
decoder
- AStreamDescribedTypeDecoder
instance to be registered with thisStreamDecoder
- Returns:
- this
StreamDecoder
instance.
-
readBoolean
public java.lang.Boolean readBoolean(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readBoolean
in interfaceStreamDecoder
- 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
public boolean readBoolean(java.io.InputStream stream, StreamDecoderState state, boolean defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readBoolean
in interfaceStreamDecoder
- 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
public java.lang.Byte readByte(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readByte
in interfaceStreamDecoder
- 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
public byte readByte(java.io.InputStream stream, StreamDecoderState state, byte defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readByte
in interfaceStreamDecoder
- 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
public UnsignedByte readUnsignedByte(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedByte
in interfaceStreamDecoder
- 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
public byte readUnsignedByte(java.io.InputStream stream, StreamDecoderState state, byte defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedByte
in interfaceStreamDecoder
- 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
public java.lang.Character readCharacter(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readCharacter
in interfaceStreamDecoder
- 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
public char readCharacter(java.io.InputStream stream, StreamDecoderState state, char defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readCharacter
in interfaceStreamDecoder
- 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
public Decimal32 readDecimal32(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readDecimal32
in interfaceStreamDecoder
- 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
public Decimal64 readDecimal64(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readDecimal64
in interfaceStreamDecoder
- 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
public Decimal128 readDecimal128(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readDecimal128
in interfaceStreamDecoder
- 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
public java.lang.Short readShort(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readShort
in interfaceStreamDecoder
- 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
public short readShort(java.io.InputStream stream, StreamDecoderState state, short defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readShort
in interfaceStreamDecoder
- 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
public UnsignedShort readUnsignedShort(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedShort
in interfaceStreamDecoder
- 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
public short readUnsignedShort(java.io.InputStream stream, StreamDecoderState state, short defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedShort
in interfaceStreamDecoder
- 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
public int readUnsignedShort(java.io.InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedShort
in interfaceStreamDecoder
- 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
public java.lang.Integer readInteger(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readInteger
in interfaceStreamDecoder
- 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
public int readInteger(java.io.InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readInteger
in interfaceStreamDecoder
- 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
public UnsignedInteger readUnsignedInteger(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedInteger
in interfaceStreamDecoder
- 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
public int readUnsignedInteger(java.io.InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedInteger
in interfaceStreamDecoder
- 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
public long readUnsignedInteger(java.io.InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedInteger
in interfaceStreamDecoder
- 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
public java.lang.Long readLong(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readLong
in interfaceStreamDecoder
- 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
public long readLong(java.io.InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readLong
in interfaceStreamDecoder
- 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
public UnsignedLong readUnsignedLong(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedLong
in interfaceStreamDecoder
- 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
public long readUnsignedLong(java.io.InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUnsignedLong
in interfaceStreamDecoder
- 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
public java.lang.Float readFloat(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readFloat
in interfaceStreamDecoder
- 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
public float readFloat(java.io.InputStream stream, StreamDecoderState state, float defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readFloat
in interfaceStreamDecoder
- 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
public java.lang.Double readDouble(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readDouble
in interfaceStreamDecoder
- 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
public double readDouble(java.io.InputStream stream, StreamDecoderState state, double defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readDouble
in interfaceStreamDecoder
- 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
public Binary readBinary(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readBinary
in interfaceStreamDecoder
- 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
public ProtonBuffer readBinaryAsBuffer(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readBinaryAsBuffer
in interfaceStreamDecoder
- 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
public DeliveryTag readDeliveryTag(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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
.- Specified by:
readDeliveryTag
in interfaceStreamDecoder
- 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
public java.lang.String readString(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readString
in interfaceStreamDecoder
- 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
public Symbol readSymbol(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readSymbol
in interfaceStreamDecoder
- 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
public java.lang.String readSymbol(java.io.InputStream stream, StreamDecoderState state, java.lang.String defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readSymbol
in interfaceStreamDecoder
- 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
public java.lang.Long readTimestamp(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readTimestamp
in interfaceStreamDecoder
- 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
public long readTimestamp(java.io.InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readTimestamp
in interfaceStreamDecoder
- 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
public java.util.UUID readUUID(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readUUID
in interfaceStreamDecoder
- 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,
-
readMap
public <K,V> java.util.Map<K,V> readMap(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readMap
in interfaceStreamDecoder
- 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
public <V> java.util.List<V> readList(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Description copied from interface:StreamDecoder
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.- Specified by:
readList
in interfaceStreamDecoder
- 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,
-
-