Package org.apache.qpid.protonj2.codec
Interface StreamDecoder
-
- All Known Implementing Classes:
ProtonStreamDecoder
public interface StreamDecoderDecode AMQP types from aInputStream
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StreamDecoderStategetCachedDecoderState()Return a singletonStreamDecoderStateinstance that is meant to be shared within single threaded decoder interactions.StreamDecoderStatenewDecoderState()Creates a newStreamDecoderStateinstance that can be used when interacting with the Decoder.StreamTypeDecoder<?>peekNextTypeDecoder(java.io.InputStream stream, StreamDecoderState state)Peeks ahead in the givenInputStreaminstance and returns aTypeDecoderthat can read the next encoded AMQP type from the stream's bytes.BinaryreadBinary(java.io.InputStream stream, StreamDecoderState state)Reads an encodedBinaryvalue from the givenInputStreamassuming that the next value in the byte stream is that type.ProtonBufferreadBinaryAsBuffer(java.io.InputStream stream, StreamDecoderState state)Reads an encodedBinaryvalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.BooleanreadBoolean(java.io.InputStream stream, StreamDecoderState state)Reads an encodedBooleanvalue from the givenInputStreamassuming that the next value in the byte stream is that type.booleanreadBoolean(java.io.InputStream stream, StreamDecoderState state, boolean defaultValue)Reads an encodedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.BytereadByte(java.io.InputStream stream, StreamDecoderState state)Reads an encodedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type.bytereadByte(java.io.InputStream stream, StreamDecoderState state, byte defaultValue)Reads an encodedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.CharacterreadCharacter(java.io.InputStream stream, StreamDecoderState state)Reads an encodedCharactervalue from the givenInputStreamassuming that the next value in the byte stream is that type.charreadCharacter(java.io.InputStream stream, StreamDecoderState state, char defaultValue)Reads an encodedCharactervalue from the givenInputStreamassuming that the next value in the byte stream is that type.Decimal128readDecimal128(java.io.InputStream stream, StreamDecoderState state)Reads an encodedDecimal128value from the givenInputStreamassuming that the next value in the byte stream is that type.Decimal32readDecimal32(java.io.InputStream stream, StreamDecoderState state)Reads an encodedDecimal32value from the givenInputStreamassuming that the next value in the byte stream is that type.Decimal64readDecimal64(java.io.InputStream stream, StreamDecoderState state)Reads an encodedDecimal64value from the givenInputStreamassuming that the next value in the byte stream is that type.DeliveryTagreadDeliveryTag(java.io.InputStream stream, StreamDecoderState state)This method expects to read aBinaryencoded type from the provided stream and constructs aDeliveryTagtype that wraps the bytes encoded.java.lang.DoublereadDouble(java.io.InputStream stream, StreamDecoderState state)Reads an encodedDoublevalue from the givenInputStreamassuming that the next value in the byte stream is that type.doublereadDouble(java.io.InputStream stream, StreamDecoderState state, double defaultValue)Reads an encodedDoublevalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.FloatreadFloat(java.io.InputStream stream, StreamDecoderState state)Reads an encodedFloatvalue from the givenInputStreamassuming that the next value in the byte stream is that type.floatreadFloat(java.io.InputStream stream, StreamDecoderState state, float defaultValue)Reads an encodedFloatvalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.IntegerreadInteger(java.io.InputStream stream, StreamDecoderState state)Reads an encodedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type.intreadInteger(java.io.InputStream stream, StreamDecoderState state, int defaultValue)Reads an encodedIntegervalue from the givenInputStreamassuming 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 encodedListvalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.LongreadLong(java.io.InputStream stream, StreamDecoderState state)Reads an encodedLongvalue from the givenInputStreamassuming that the next value in the byte stream is that type.longreadLong(java.io.InputStream stream, StreamDecoderState state, long defaultValue)Reads an encodedLongvalue from the givenInputStreamassuming 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 encodedMapvalue from the givenInputStreamassuming 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 givenInputStreaman return it as an array ofObjectinstances which the caller must then interpret.StreamTypeDecoder<?>readNextTypeDecoder(java.io.InputStream stream, StreamDecoderState state)Reads from the givenInputStreaminstance and returns aStreamTypeDecoderthat can read the next encoded AMQP type from the stream's bytes.java.lang.ObjectreadObject(java.io.InputStream stream, StreamDecoderState state)Reads an encoded value from the givenInputStreaman return it as anObjectwhich the caller must then interpret.<T> TreadObject(java.io.InputStream stream, StreamDecoderState state, java.lang.Class<T> clazz)Reads an encoded value from the givenInputStreaman return it as anObjectwhich the caller must then interpret.java.lang.ShortreadShort(java.io.InputStream stream, StreamDecoderState state)Reads an encodedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type.shortreadShort(java.io.InputStream stream, StreamDecoderState state, short defaultValue)Reads an encodedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.StringreadString(java.io.InputStream stream, StreamDecoderState state)Reads an encodedStringvalue from the givenInputStreamassuming that the next value in the byte stream is that type.SymbolreadSymbol(java.io.InputStream stream, StreamDecoderState state)Reads an encodedSymbolvalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.StringreadSymbol(java.io.InputStream stream, StreamDecoderState state, java.lang.String defaultValue)Reads an encodedStringvalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.lang.LongreadTimestamp(java.io.InputStream stream, StreamDecoderState state)Reads an encoded AMQP time stamp value from the givenInputStreamassuming that the next value in the byte stream is that type.longreadTimestamp(java.io.InputStream stream, StreamDecoderState state, long defaultValue)Reads an encoded AMQP time stamp value from the givenInputStreamassuming that the next value in the byte stream is that type.UnsignedBytereadUnsignedByte(java.io.InputStream stream, StreamDecoderState state)Reads an encodedUnsignedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type.bytereadUnsignedByte(java.io.InputStream stream, StreamDecoderState state, byte defaultValue)Reads an encodedUnsignedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type.UnsignedIntegerreadUnsignedInteger(java.io.InputStream stream, StreamDecoderState state)Reads an encodedUnsignedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type.intreadUnsignedInteger(java.io.InputStream stream, StreamDecoderState state, int defaultValue)Reads an encodedUnsignedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type.longreadUnsignedInteger(java.io.InputStream stream, StreamDecoderState state, long defaultValue)Reads an encodedUnsignedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type.UnsignedLongreadUnsignedLong(java.io.InputStream stream, StreamDecoderState state)Reads an encodedUnsignedLongvalue from the givenInputStreamassuming that the next value in the byte stream is that type.longreadUnsignedLong(java.io.InputStream stream, StreamDecoderState state, long defaultValue)Reads an encodedUnsignedLongvalue from the givenInputStreamassuming that the next value in the byte stream is that type.UnsignedShortreadUnsignedShort(java.io.InputStream stream, StreamDecoderState state)Reads an encodedUnsignedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type.intreadUnsignedShort(java.io.InputStream stream, StreamDecoderState state, int defaultValue)Reads an encodedUnsignedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type.shortreadUnsignedShort(java.io.InputStream stream, StreamDecoderState state, short defaultValue)Reads an encodedUnsignedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type.java.util.UUIDreadUUID(java.io.InputStream stream, StreamDecoderState state)Reads an encodedUUIDvalue from the givenInputStreamassuming that the next value in the byte stream is that type.<V> StreamDecoderregisterDescribedTypeDecoder(StreamDescribedTypeDecoder<V> decoder)Allows customStreamDescribedTypeDecoderinstances to be registered with thisStreamDecoderwhich will be used if the described type encoding is encountered during decode operations.
-
-
-
Method Detail
-
newDecoderState
StreamDecoderState newDecoderState()
Creates a newStreamDecoderStateinstance that can be used when interacting with the Decoder. For decoding that occurs on more than one thread while sharing a singleStreamDecoderinstance a different state object per thread is required as theStreamDecoderStateobject 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 theStreamDecoderoffers a utility cachedStreamDecoderStateAPI that will return the same instance on each call which can reduce allocation overhead and make using theStreamDecodersimpler.- Returns:
- a newly constructed
EncoderStateinstance.
-
getCachedDecoderState
StreamDecoderState getCachedDecoderState()
Return a singletonStreamDecoderStateinstance that is meant to be shared within single threaded decoder interactions. If more than one thread makes use of this cachedStreamDecoderStatethe results of any decoding done using this state object is not guaranteed to be correct. The returned instance will have its reset method called to ensure that any previously stored state data is cleared before the next use.- Returns:
- a cached
StreamDecoderStatelinked to this Decoder instance that has been reset.
-
readBoolean
java.lang.Boolean readBoolean(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedBooleanvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readBoolean
boolean readBoolean(java.io.InputStream stream, StreamDecoderState state, boolean defaultValue) throws DecodeExceptionReads an encodedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.Byte readByte(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readByte
byte readByte(java.io.InputStream stream, StreamDecoderState state, byte defaultValue) throws DecodeExceptionReads an encodedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.defaultValue- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedByte
UnsignedByte readUnsignedByte(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUnsignedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedByte
byte readUnsignedByte(java.io.InputStream stream, StreamDecoderState state, byte defaultValue) throws DecodeExceptionReads an encodedUnsignedBytevalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.Character readCharacter(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedCharactervalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readCharacter
char readCharacter(java.io.InputStream stream, StreamDecoderState state, char defaultValue) throws DecodeExceptionReads an encodedCharactervalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.defaultValue- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readDecimal32
Decimal32 readDecimal32(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedDecimal32value from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readDecimal64
Decimal64 readDecimal64(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedDecimal64value from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readDecimal128
Decimal128 readDecimal128(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedDecimal128value from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.Short readShort(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readShort
short readShort(java.io.InputStream stream, StreamDecoderState state, short defaultValue) throws DecodeExceptionReads an encodedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.defaultValue- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedShort
UnsignedShort readUnsignedShort(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUnsignedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedShort
short readUnsignedShort(java.io.InputStream stream, StreamDecoderState state, short defaultValue) throws DecodeExceptionReads an encodedUnsignedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.defaultValue- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedShort
int readUnsignedShort(java.io.InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeExceptionReads an encodedUnsignedShortvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.Integer readInteger(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readInteger
int readInteger(java.io.InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeExceptionReads an encodedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.defaultValue- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedInteger
UnsignedInteger readUnsignedInteger(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUnsignedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedInteger
int readUnsignedInteger(java.io.InputStream stream, StreamDecoderState state, int defaultValue) throws DecodeExceptionReads an encodedUnsignedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.defaultValue- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedInteger
long readUnsignedInteger(java.io.InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeExceptionReads an encodedUnsignedIntegervalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.Long readLong(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedLongvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readLong
long readLong(java.io.InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeExceptionReads an encodedLongvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.defaultValue- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedLong
UnsignedLong readUnsignedLong(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedUnsignedLongvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readUnsignedLong
long readUnsignedLong(java.io.InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeExceptionReads an encodedUnsignedLongvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.Float readFloat(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedFloatvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readFloat
float readFloat(java.io.InputStream stream, StreamDecoderState state, float defaultValue) throws DecodeExceptionReads an encodedFloatvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.Double readDouble(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedDoublevalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readDouble
double readDouble(java.io.InputStream stream, StreamDecoderState state, double defaultValue) throws DecodeExceptionReads an encodedDoublevalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.defaultValue- A default value to return if the next encoded value is a Null encoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readBinary
Binary readBinary(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedBinaryvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readBinaryAsBuffer
ProtonBuffer readBinaryAsBuffer(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedBinaryvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source and returned in a
ProtonBuffer. - Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readDeliveryTag
DeliveryTag readDeliveryTag(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
This method expects to read aBinaryencoded type from the provided stream and constructs aDeliveryTagtype that wraps the bytes encoded. If the encoding is a NULL AMQP type then this method returnsnull.- Parameters:
stream- TheInputStreamto 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 theDeliveryTaginstance.
-
readString
java.lang.String readString(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedStringvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readSymbol
Symbol readSymbol(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads an encodedSymbolvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.String readSymbol(java.io.InputStream stream, StreamDecoderState state, java.lang.String defaultValue) throws DecodeExceptionReads an encodedStringvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.lang.Long readTimestamp(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encoded AMQP time stamp value from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source and return a
Longwith the time value. - Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readTimestamp
long readTimestamp(java.io.InputStream stream, StreamDecoderState state, long defaultValue) throws DecodeExceptionReads an encoded AMQP time stamp value from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat 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
java.util.UUID readUUID(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedUUIDvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readObject
java.lang.Object readObject(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encoded value from the givenInputStreaman return it as anObjectwhich the caller must then interpret.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not able to be decoded.
-
readObject
<T> T readObject(java.io.InputStream stream, StreamDecoderState state, java.lang.Class<T> clazz) throws DecodeExceptionReads an encoded value from the givenInputStreaman return it as anObjectwhich the caller must then interpret.- Type Parameters:
T- the type that will be used when casting and returning the decoded value.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.clazz- TheClasstype that should be used to cast the returned value.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not able to be decoded.
-
readMultiple
<T> T[] readMultiple(java.io.InputStream stream, StreamDecoderState state, java.lang.Class<T> clazz) throws DecodeExceptionReads one or more encoded values from the givenInputStreaman return it as an array ofObjectinstances which the caller must then interpret.- Type Parameters:
T- the type that will be used when casting and returning the decoded value.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.clazz- TheClasstype that should be used to cast the returned array.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not able to be decoded.
-
readMap
<K,V> java.util.Map<K,V> readMap(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedMapvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readList
<V> java.util.List<V> readList(java.io.InputStream stream, StreamDecoderState state) throws DecodeExceptionReads an encodedListvalue from the givenInputStreamassuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should mark the and reset the input to make a further read attempt.- Parameters:
stream- TheInputStreamwhere the read operation takes place.state- TheDecoderStatethat the decoder can use when decoding.- Returns:
- the value read from the provided byte source.
- Throws:
DecodeException- if the value fails to decode is not of the expected type,
-
readNextTypeDecoder
StreamTypeDecoder<?> readNextTypeDecoder(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Reads from the givenInputStreaminstance and returns aStreamTypeDecoderthat 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 anDecodeExceptionis thrown.- Parameters:
stream- The stream to read from to determine the nextTypeDecoderneeded.state- TheDecoderStatevalue that can be used for intermediate decoding tasks.- Returns:
- a
StreamTypeDecoderinstance that can read the next type in the stream. - Throws:
DecodeException- if an error occurs while reading the next type decoder.
-
peekNextTypeDecoder
StreamTypeDecoder<?> peekNextTypeDecoder(java.io.InputStream stream, StreamDecoderState state) throws DecodeException
Peeks ahead in the givenInputStreaminstance and returns aTypeDecoderthat 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 anDecodeExceptionis thrown. The underlying stream is not modified as a result of the peek operation and the returnedTypeDecoderwill fail to properly read the type until the encoding bytes are read. If the provided stream does not offer support for the mark API than this method can throw anUnsupportedOperationException.- Parameters:
stream- The stream to read from to determine the nextTypeDecoderneeded.state- TheDecoderStatevalue that can be used for intermediate decoding tasks.- Returns:
- a
TypeDecoderinstance that can provide insight into the next type in the stream. - Throws:
DecodeException- if an error occurs while peeking ahead for the next type decoder.
-
registerDescribedTypeDecoder
<V> StreamDecoder registerDescribedTypeDecoder(StreamDescribedTypeDecoder<V> decoder)
Allows customStreamDescribedTypeDecoderinstances to be registered with thisStreamDecoderwhich will be used if the described type encoding is encountered during decode operations.- Type Parameters:
V- The type that the decoder reads.- Parameters:
decoder- AStreamDescribedTypeDecoderinstance to be registered with thisStreamDecoder- Returns:
- this
StreamDecoderinstance.
-
-