Class ProtonDecoder
- java.lang.Object
-
- org.apache.qpid.protonj2.codec.decoders.ProtonDecoder
-
-
Constructor Summary
Constructors Constructor Description ProtonDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProtonDecoderState
getCachedDecoderState()
Return a singletonDecoderState
instance that is meant to be shared within single threaded decoder interactions.ProtonDecoderState
newDecoderState()
Creates a newDecoderState
instance that can be used when interacting with the Decoder.TypeDecoder<?>
peekNextTypeDecoder(ProtonBuffer buffer, DecoderState state)
Peeks ahead in the givenProtonBuffer
instance and returns aTypeDecoder
that can read the next encoded AMQP type from the buffer's bytes.Binary
readBinary(ProtonBuffer buffer, DecoderState state)
Reads an encodedBinary
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.ProtonBuffer
readBinaryAsBuffer(ProtonBuffer buffer, DecoderState state)
Reads an encodedBinary
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.Boolean
readBoolean(ProtonBuffer buffer, DecoderState state)
Reads an encodedBoolean
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.boolean
readBoolean(ProtonBuffer buffer, DecoderState state, boolean defaultValue)
Reads an encodedByte
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.Byte
readByte(ProtonBuffer buffer, DecoderState state)
Reads an encodedByte
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.byte
readByte(ProtonBuffer buffer, DecoderState state, byte defaultValue)
Reads an encodedByte
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.Character
readCharacter(ProtonBuffer buffer, DecoderState state)
Reads an encodedCharacter
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.char
readCharacter(ProtonBuffer buffer, DecoderState state, char defaultValue)
Reads an encodedCharacter
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.Decimal128
readDecimal128(ProtonBuffer buffer, DecoderState state)
Reads an encodedDecimal128
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.Decimal32
readDecimal32(ProtonBuffer buffer, DecoderState state)
Reads an encodedDecimal32
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.Decimal64
readDecimal64(ProtonBuffer buffer, DecoderState state)
Reads an encodedDecimal64
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.DeliveryTag
readDeliveryTag(ProtonBuffer buffer, DecoderState state)
This method expects to read aBinary
encoded type from the provided buffer and constructs aDeliveryTag
type that wraps the bytes encoded.java.lang.Double
readDouble(ProtonBuffer buffer, DecoderState state)
Reads an encodedDouble
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.double
readDouble(ProtonBuffer buffer, DecoderState state, double defaultValue)
Reads an encodedDouble
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.Float
readFloat(ProtonBuffer buffer, DecoderState state)
Reads an encodedFloat
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.float
readFloat(ProtonBuffer buffer, DecoderState state, float defaultValue)
Reads an encodedFloat
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.Integer
readInteger(ProtonBuffer buffer, DecoderState state)
Reads an encodedInteger
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.int
readInteger(ProtonBuffer buffer, DecoderState state, int defaultValue)
Reads an encodedInteger
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.<V> java.util.List<V>
readList(ProtonBuffer buffer, DecoderState state)
Reads an encodedList
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.Long
readLong(ProtonBuffer buffer, DecoderState state)
Reads an encodedLong
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.long
readLong(ProtonBuffer buffer, DecoderState state, long defaultValue)
Reads an encodedLong
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.<K,V>
java.util.Map<K,V>readMap(ProtonBuffer buffer, DecoderState state)
Reads an encodedMap
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.<T> T[]
readMultiple(ProtonBuffer buffer, DecoderState state, java.lang.Class<T> clazz)
Reads one or more encoded values from the givenProtonBuffer
an return it as an array ofObject
instances which the caller must then interpret.TypeDecoder<?>
readNextTypeDecoder(ProtonBuffer buffer, DecoderState state)
Reads from the givenProtonBuffer
instance and returns aTypeDecoder
that can read the next encoded AMQP type from the buffer's bytes.java.lang.Object
readObject(ProtonBuffer buffer, DecoderState state)
Reads an encoded value from the givenProtonBuffer
an return it as anObject
which the caller must then interpret.<T> T
readObject(ProtonBuffer buffer, DecoderState state, java.lang.Class<T> clazz)
Reads an encoded value from the givenProtonBuffer
an return it as anObject
which the caller must then interpret.java.lang.Short
readShort(ProtonBuffer buffer, DecoderState state)
Reads an encodedShort
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.short
readShort(ProtonBuffer buffer, DecoderState state, short defaultValue)
Reads an encodedShort
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.String
readString(ProtonBuffer buffer, DecoderState state)
Reads an encodedString
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.Symbol
readSymbol(ProtonBuffer buffer, DecoderState state)
Reads an encodedSymbol
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.String
readSymbol(ProtonBuffer buffer, DecoderState state, java.lang.String defaultValue)
Reads an encodedString
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.lang.Long
readTimestamp(ProtonBuffer buffer, DecoderState state)
Reads an encoded AMQP time stamp value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.long
readTimestamp(ProtonBuffer buffer, DecoderState state, long defaultValue)
Reads an encoded AMQP time stamp value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.UnsignedByte
readUnsignedByte(ProtonBuffer buffer, DecoderState state)
Reads an encodedUnsignedByte
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.byte
readUnsignedByte(ProtonBuffer buffer, DecoderState state, byte defaultValue)
Reads an encodedUnsignedByte
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.UnsignedInteger
readUnsignedInteger(ProtonBuffer buffer, DecoderState state)
Reads an encodedUnsignedInteger
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.int
readUnsignedInteger(ProtonBuffer buffer, DecoderState state, int defaultValue)
Reads an encodedUnsignedInteger
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.long
readUnsignedInteger(ProtonBuffer buffer, DecoderState state, long defaultValue)
Reads an encodedUnsignedInteger
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.UnsignedLong
readUnsignedLong(ProtonBuffer buffer, DecoderState state)
Reads an encodedUnsignedLong
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.long
readUnsignedLong(ProtonBuffer buffer, DecoderState state, long defaultValue)
Reads an encodedUnsignedLong
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.UnsignedShort
readUnsignedShort(ProtonBuffer buffer, DecoderState state)
Reads an encodedUnsignedShort
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.int
readUnsignedShort(ProtonBuffer buffer, DecoderState state, int defaultValue)
Reads an encodedUnsignedShort
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.short
readUnsignedShort(ProtonBuffer buffer, DecoderState state, short defaultValue)
Reads an encodedUnsignedShort
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.java.util.UUID
readUUID(ProtonBuffer buffer, DecoderState state)
Reads an encodedUUID
value from the givenProtonBuffer
assuming that the next value in the byte stream is that type.<V> ProtonDecoder
registerDescribedTypeDecoder(DescribedTypeDecoder<V> decoder)
Allows customDescribedTypeDecoder
instances to be registered with thisDecoder
which will be used if the described type encoding is encountered during decode operations.
-
-
-
Method Detail
-
newDecoderState
public ProtonDecoderState newDecoderState()
Description copied from interface:Decoder
Creates a newDecoderState
instance that can be used when interacting with the Decoder. For decoding that occurs on more than one thread while sharing a singleDecoder
instance a different state object per thread is required as theDecoderState
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 theDecoder
offers a utility cachedDecoderState
API that will return the same instance on each call which can reduce allocation overhead and make using theDecoder
simpler.- Specified by:
newDecoderState
in interfaceDecoder
- Returns:
- a newly constructed
EncoderState
instance.
-
getCachedDecoderState
public ProtonDecoderState getCachedDecoderState()
Description copied from interface:Decoder
Return a singletonDecoderState
instance that is meant to be shared within single threaded decoder interactions. If more than one thread makes use of this cachedDecoderState
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 interfaceDecoder
- Returns:
- a cached
DecoderState
linked to this Decoder instance that has been reset.
-
readObject
public java.lang.Object readObject(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encoded value from the givenProtonBuffer
an return it as anObject
which the caller must then interpret.- Specified by:
readObject
in interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, java.lang.Class<T> clazz) throws DecodeException
Description copied from interface:Decoder
Reads an encoded value from the givenProtonBuffer
an return it as anObject
which the caller must then interpret.- Specified by:
readObject
in interfaceDecoder
- Type Parameters:
T
- the type that will be used when casting and returning the decoded value.- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, java.lang.Class<T> clazz) throws DecodeException
Description copied from interface:Decoder
Reads one or more encoded values from the givenProtonBuffer
an return it as an array ofObject
instances which the caller must then interpret.- Specified by:
readMultiple
in interfaceDecoder
- Type Parameters:
T
- the type that will be used when casting and returning the decoded value.- Parameters:
buffer
- TheProtonBuffer
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 TypeDecoder<?> readNextTypeDecoder(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads from the givenProtonBuffer
instance and returns aTypeDecoder
that can read the next encoded AMQP type from the buffer's bytes. If an error occurs attempting to read and determine the next type decoder anDecodeException
is thrown.- Specified by:
readNextTypeDecoder
in interfaceDecoder
- Parameters:
buffer
- The buffer 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 read the next type in the buffer. - Throws:
DecodeException
- if an error occurs while reading the next type decoder.
-
peekNextTypeDecoder
public TypeDecoder<?> peekNextTypeDecoder(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Peeks ahead in the givenProtonBuffer
instance and returns aTypeDecoder
that can read the next encoded AMQP type from the buffer's bytes. If an error occurs attempting to read and determine the next type decoder anDecodeException
is thrown. The underlying buffer 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.- Specified by:
peekNextTypeDecoder
in interfaceDecoder
- Parameters:
buffer
- The buffer 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 buffer. - Throws:
DecodeException
- if an error occurs while peeking ahead for the next type decoder.
-
registerDescribedTypeDecoder
public <V> ProtonDecoder registerDescribedTypeDecoder(DescribedTypeDecoder<V> decoder)
Description copied from interface:Decoder
Allows customDescribedTypeDecoder
instances to be registered with thisDecoder
which will be used if the described type encoding is encountered during decode operations.- Specified by:
registerDescribedTypeDecoder
in interfaceDecoder
- Type Parameters:
V
- The type that the decoder reads.- Parameters:
decoder
- ADescribedTypeDecoder
instance to be registered with thisDecoder
- Returns:
- this
Decoder
instance.
-
readBoolean
public java.lang.Boolean readBoolean(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedBoolean
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, boolean defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedByte
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedByte
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, byte defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedByte
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedByte
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, byte defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedByte
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedCharacter
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, char defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedCharacter
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedDecimal32
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedDecimal64
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedDecimal128
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedShort
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, short defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedShort
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedShort
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, short defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedShort
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, int defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedShort
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedInteger
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, int defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedInteger
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedInteger
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, int defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedInteger
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, long defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedInteger
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedLong
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, long defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedLong
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedLong
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, long defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUnsignedLong
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedFloat
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, float defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedFloat
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedDouble
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, double defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedDouble
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedBinary
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedBinary
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
This method expects to read aBinary
encoded type from the provided buffer 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 interfaceDecoder
- Parameters:
buffer
- The buffer 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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedString
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedSymbol
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, java.lang.String defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encodedString
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encoded AMQP time stamp value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state, long defaultValue) throws DecodeException
Description copied from interface:Decoder
Reads an encoded AMQP time stamp value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedUUID
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedMap
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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(ProtonBuffer buffer, DecoderState state) throws DecodeException
Description copied from interface:Decoder
Reads an encodedList
value from the givenProtonBuffer
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 interfaceDecoder
- Parameters:
buffer
- TheProtonBuffer
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,
-
-