Class ProtonEncoder
- java.lang.Object
-
- org.apache.qpid.protonj2.codec.encoders.ProtonEncoder
-
-
Constructor Summary
Constructors Constructor Description ProtonEncoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProtonEncoderState
getCachedEncoderState()
Return a singletonEncoderState
instance that is meant to be shared within single threaded encoder interactions.TypeEncoder<?>
getTypeEncoder(Class<?> typeClass)
Lookup aTypeEncoder
that would be used to encode the givenClass
.TypeEncoder<?>
getTypeEncoder(Class<?> typeClass, Object instance)
Lookup aTypeEncoder
by first checking the given typeClass
and then if none found to deduce a valid TypeEncoder from theObject
specified.TypeEncoder<?>
getTypeEncoder(Object value)
Lookup aTypeEncoder
that would be used to encode the givenObject
.ProtonEncoderState
newEncoderState()
Creates a newEncoderState
instance that can be used when interacting with the Encoder.<V> ProtonEncoder
registerDescribedTypeEncoder(DescribedTypeEncoder<V> encoder)
Register aDescribedTypeEncoder
which can be used when writing custom types using this encoder.void
writeArray(ProtonBuffer buffer, EncoderState state, boolean[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, byte[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, char[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, double[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, float[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, int[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, long[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, short[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, Object[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, UUID[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, Decimal128[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, Decimal32[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, Decimal64[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, Symbol[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, UnsignedByte[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, UnsignedInteger[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, UnsignedLong[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeArray(ProtonBuffer buffer, EncoderState state, UnsignedShort[] value)
Write the given array as with the proper array type encoding to the given buffer.void
writeBinary(ProtonBuffer buffer, EncoderState state, byte[] value)
Writes the contents of the givenbyte
value into the providedProtonBuffer
instance as an AMQP Binary type.void
writeBinary(ProtonBuffer buffer, EncoderState state, ProtonBuffer value)
Writes the contents of the givenProtonBuffer
value into the providedProtonBuffer
instance as an AMQP Binary type.void
writeBinary(ProtonBuffer buffer, EncoderState state, Binary value)
Writes the contents of the givenBinary
value into the providedProtonBuffer
instance as an AMQP Binary type.void
writeBoolean(ProtonBuffer buffer, EncoderState state, boolean value)
Write aBoolean
type encoding to the given buffer.void
writeBoolean(ProtonBuffer buffer, EncoderState state, Boolean value)
Write aBoolean
type encoding to the given buffer.void
writeByte(ProtonBuffer buffer, EncoderState state, byte value)
Write aByte
type encoding to the given buffer.void
writeByte(ProtonBuffer buffer, EncoderState state, Byte value)
Write aByte
type encoding to the given buffer.void
writeCharacter(ProtonBuffer buffer, EncoderState state, char value)
Write aCharacter
type encoding to the given buffer.void
writeCharacter(ProtonBuffer buffer, EncoderState state, Character value)
Write aCharacter
type encoding to the given buffer.void
writeDecimal128(ProtonBuffer buffer, EncoderState state, Decimal128 value)
Write aDecimal128
type encoding to the given buffer.void
writeDecimal32(ProtonBuffer buffer, EncoderState state, Decimal32 value)
Write aDecimal32
type encoding to the given buffer.void
writeDecimal64(ProtonBuffer buffer, EncoderState state, Decimal64 value)
Write aDecimal64
type encoding to the given buffer.void
writeDeliveryTag(ProtonBuffer buffer, EncoderState state, DeliveryTag value)
Writes the contents of the givenDeliveryTag
value into the providedProtonBuffer
instance as an AMQP Binary type.void
writeDescribedType(ProtonBuffer buffer, EncoderState state, DescribedType value)
Write aDescribedType
type encoding to the given buffer.void
writeDouble(ProtonBuffer buffer, EncoderState state, double value)
Write aDouble
type encoding to the given buffer.void
writeDouble(ProtonBuffer buffer, EncoderState state, Double value)
Write aDouble
type encoding to the given buffer.void
writeFloat(ProtonBuffer buffer, EncoderState state, float value)
Write aFloat
type encoding to the given buffer.void
writeFloat(ProtonBuffer buffer, EncoderState state, Float value)
Write aFloat
type encoding to the given buffer.void
writeInteger(ProtonBuffer buffer, EncoderState state, int value)
Write aInteger
type encoding to the given buffer.void
writeInteger(ProtonBuffer buffer, EncoderState state, Integer value)
Write aInteger
type encoding to the given buffer.<T> void
writeList(ProtonBuffer buffer, EncoderState state, List<T> value)
Write aList
type encoding to the given buffer.void
writeLong(ProtonBuffer buffer, EncoderState state, long value)
Write aLong
type encoding to the given buffer.void
writeLong(ProtonBuffer buffer, EncoderState state, Long value)
Write aLong
type encoding to the given buffer.<K,V>
voidwriteMap(ProtonBuffer buffer, EncoderState state, Map<K,V> value)
Write aMap
type encoding to the given buffer.void
writeNull(ProtonBuffer buffer, EncoderState state)
Write a Null type encoding to the given buffer.void
writeObject(ProtonBuffer buffer, EncoderState state, Object value)
Write the proper type encoding for the providedObject
to the given buffer if anTypeEncoder
can be found for it in the collection of registered type encoders..void
writeShort(ProtonBuffer buffer, EncoderState state, short value)
Write aShort
type encoding to the given buffer.void
writeShort(ProtonBuffer buffer, EncoderState state, Short value)
Write aShort
type encoding to the given buffer.void
writeString(ProtonBuffer buffer, EncoderState state, String value)
Write aString
type encoding to the given buffer.void
writeSymbol(ProtonBuffer buffer, EncoderState state, String value)
Write aSymbol
type encoding to the given buffer.void
writeSymbol(ProtonBuffer buffer, EncoderState state, Symbol value)
Write aSymbol
type encoding to the given buffer.void
writeTimestamp(ProtonBuffer buffer, EncoderState state, long value)
Write a Time stamp type encoding to the given buffer.void
writeTimestamp(ProtonBuffer buffer, EncoderState state, Date value)
Write a Time stamp type encoding to the given buffer.void
writeUnsignedByte(ProtonBuffer buffer, EncoderState state, byte value)
Write anUnsignedByte
type encoding to the given buffer.void
writeUnsignedByte(ProtonBuffer buffer, EncoderState state, UnsignedByte value)
Write anUnsignedByte
type encoding to the given buffer.void
writeUnsignedInteger(ProtonBuffer buffer, EncoderState state, byte value)
Write aUnsignedInteger
type encoding to the given buffer.void
writeUnsignedInteger(ProtonBuffer buffer, EncoderState state, int value)
Write aUnsignedInteger
type encoding to the given buffer.void
writeUnsignedInteger(ProtonBuffer buffer, EncoderState state, long value)
Write aUnsignedInteger
type encoding to the given buffer using the provided value with appropriate range checks to ensure invalid input is not accepted.void
writeUnsignedInteger(ProtonBuffer buffer, EncoderState state, UnsignedInteger value)
Write aUnsignedInteger
type encoding to the given buffer.void
writeUnsignedLong(ProtonBuffer buffer, EncoderState state, byte value)
Write aUnsignedLong
type encoding to the given buffer.void
writeUnsignedLong(ProtonBuffer buffer, EncoderState state, long value)
Write aUnsignedLong
type encoding to the given buffer.void
writeUnsignedLong(ProtonBuffer buffer, EncoderState state, UnsignedLong value)
Write aUnsignedLong
type encoding to the given buffer.void
writeUnsignedShort(ProtonBuffer buffer, EncoderState state, int value)
Write aUnsignedShort
type encoding to the given buffer using the provided value with appropriate range checks to ensure invalid input is not accepted.void
writeUnsignedShort(ProtonBuffer buffer, EncoderState state, short value)
Write aUnsignedShort
type encoding to the given buffer.void
writeUnsignedShort(ProtonBuffer buffer, EncoderState state, UnsignedShort value)
Write aUnsignedShort
type encoding to the given buffer.void
writeUUID(ProtonBuffer buffer, EncoderState state, UUID value)
Write aUUID
type encoding to the given buffer.
-
-
-
Method Detail
-
newEncoderState
public ProtonEncoderState newEncoderState()
Description copied from interface:Encoder
Creates a newEncoderState
instance that can be used when interacting with the Encoder. For encoding that occurs on more than one thread while sharing a singleEncoder
instance a different state object per thread is required as theEncoderState
object can retain some state information during the encode process that could be corrupted if more than one thread were to share a single instance. For single threaded encoding work theEncoder
offers a utility cachedEncoderState
API that will return the same instance on each call which can reduce allocation overhead and make using theEncoder
simpler.- Specified by:
newEncoderState
in interfaceEncoder
- Returns:
- a newly constructed
EncoderState
instance.
-
getCachedEncoderState
public ProtonEncoderState getCachedEncoderState()
Description copied from interface:Encoder
Return a singletonEncoderState
instance that is meant to be shared within single threaded encoder interactions. If more than one thread makes use of this cacheEncoderState
the results of any encoding 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:
getCachedEncoderState
in interfaceEncoder
- Returns:
- a cached
EncoderState
linked to this Encoder instance.
-
writeNull
public void writeNull(ProtonBuffer buffer, EncoderState state) throws EncodeException
Description copied from interface:Encoder
Write a Null type encoding to the given buffer.- Specified by:
writeNull
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeBoolean
public void writeBoolean(ProtonBuffer buffer, EncoderState state, boolean value) throws EncodeException
Description copied from interface:Encoder
Write aBoolean
type encoding to the given buffer.- Specified by:
writeBoolean
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeBoolean
public void writeBoolean(ProtonBuffer buffer, EncoderState state, Boolean value) throws EncodeException
Description copied from interface:Encoder
Write aBoolean
type encoding to the given buffer.- Specified by:
writeBoolean
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedByte
public void writeUnsignedByte(ProtonBuffer buffer, EncoderState state, UnsignedByte value) throws EncodeException
Description copied from interface:Encoder
Write anUnsignedByte
type encoding to the given buffer.- Specified by:
writeUnsignedByte
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedByte
public void writeUnsignedByte(ProtonBuffer buffer, EncoderState state, byte value) throws EncodeException
Description copied from interface:Encoder
Write anUnsignedByte
type encoding to the given buffer.- Specified by:
writeUnsignedByte
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedShort
public void writeUnsignedShort(ProtonBuffer buffer, EncoderState state, UnsignedShort value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedShort
type encoding to the given buffer.- Specified by:
writeUnsignedShort
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedShort
public void writeUnsignedShort(ProtonBuffer buffer, EncoderState state, short value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedShort
type encoding to the given buffer.- Specified by:
writeUnsignedShort
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedShort
public void writeUnsignedShort(ProtonBuffer buffer, EncoderState state, int value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedShort
type encoding to the given buffer using the provided value with appropriate range checks to ensure invalid input is not accepted.- Specified by:
writeUnsignedShort
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedInteger
public void writeUnsignedInteger(ProtonBuffer buffer, EncoderState state, UnsignedInteger value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedInteger
type encoding to the given buffer.- Specified by:
writeUnsignedInteger
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedInteger
public void writeUnsignedInteger(ProtonBuffer buffer, EncoderState state, byte value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedInteger
type encoding to the given buffer.- Specified by:
writeUnsignedInteger
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedInteger
public void writeUnsignedInteger(ProtonBuffer buffer, EncoderState state, int value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedInteger
type encoding to the given buffer.- Specified by:
writeUnsignedInteger
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedInteger
public void writeUnsignedInteger(ProtonBuffer buffer, EncoderState state, long value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedInteger
type encoding to the given buffer using the provided value with appropriate range checks to ensure invalid input is not accepted.- Specified by:
writeUnsignedInteger
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedLong
public void writeUnsignedLong(ProtonBuffer buffer, EncoderState state, byte value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedLong
type encoding to the given buffer.- Specified by:
writeUnsignedLong
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedLong
public void writeUnsignedLong(ProtonBuffer buffer, EncoderState state, long value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedLong
type encoding to the given buffer.- Specified by:
writeUnsignedLong
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUnsignedLong
public void writeUnsignedLong(ProtonBuffer buffer, EncoderState state, UnsignedLong value) throws EncodeException
Description copied from interface:Encoder
Write aUnsignedLong
type encoding to the given buffer.- Specified by:
writeUnsignedLong
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeByte
public void writeByte(ProtonBuffer buffer, EncoderState state, byte value) throws EncodeException
Description copied from interface:Encoder
Write aByte
type encoding to the given buffer.- Specified by:
writeByte
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeByte
public void writeByte(ProtonBuffer buffer, EncoderState state, Byte value) throws EncodeException
Description copied from interface:Encoder
Write aByte
type encoding to the given buffer.- Specified by:
writeByte
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeShort
public void writeShort(ProtonBuffer buffer, EncoderState state, short value) throws EncodeException
Description copied from interface:Encoder
Write aShort
type encoding to the given buffer.- Specified by:
writeShort
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeShort
public void writeShort(ProtonBuffer buffer, EncoderState state, Short value) throws EncodeException
Description copied from interface:Encoder
Write aShort
type encoding to the given buffer.- Specified by:
writeShort
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeInteger
public void writeInteger(ProtonBuffer buffer, EncoderState state, int value) throws EncodeException
Description copied from interface:Encoder
Write aInteger
type encoding to the given buffer.- Specified by:
writeInteger
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeInteger
public void writeInteger(ProtonBuffer buffer, EncoderState state, Integer value) throws EncodeException
Description copied from interface:Encoder
Write aInteger
type encoding to the given buffer.- Specified by:
writeInteger
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeLong
public void writeLong(ProtonBuffer buffer, EncoderState state, long value) throws EncodeException
Description copied from interface:Encoder
Write aLong
type encoding to the given buffer.- Specified by:
writeLong
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeLong
public void writeLong(ProtonBuffer buffer, EncoderState state, Long value) throws EncodeException
Description copied from interface:Encoder
Write aLong
type encoding to the given buffer.- Specified by:
writeLong
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeFloat
public void writeFloat(ProtonBuffer buffer, EncoderState state, float value) throws EncodeException
Description copied from interface:Encoder
Write aFloat
type encoding to the given buffer.- Specified by:
writeFloat
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeFloat
public void writeFloat(ProtonBuffer buffer, EncoderState state, Float value) throws EncodeException
Description copied from interface:Encoder
Write aFloat
type encoding to the given buffer.- Specified by:
writeFloat
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeDouble
public void writeDouble(ProtonBuffer buffer, EncoderState state, double value) throws EncodeException
Description copied from interface:Encoder
Write aDouble
type encoding to the given buffer.- Specified by:
writeDouble
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeDouble
public void writeDouble(ProtonBuffer buffer, EncoderState state, Double value) throws EncodeException
Description copied from interface:Encoder
Write aDouble
type encoding to the given buffer.- Specified by:
writeDouble
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeDecimal32
public void writeDecimal32(ProtonBuffer buffer, EncoderState state, Decimal32 value) throws EncodeException
Description copied from interface:Encoder
Write aDecimal32
type encoding to the given buffer.- Specified by:
writeDecimal32
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeDecimal64
public void writeDecimal64(ProtonBuffer buffer, EncoderState state, Decimal64 value) throws EncodeException
Description copied from interface:Encoder
Write aDecimal64
type encoding to the given buffer.- Specified by:
writeDecimal64
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeDecimal128
public void writeDecimal128(ProtonBuffer buffer, EncoderState state, Decimal128 value) throws EncodeException
Description copied from interface:Encoder
Write aDecimal128
type encoding to the given buffer.- Specified by:
writeDecimal128
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeCharacter
public void writeCharacter(ProtonBuffer buffer, EncoderState state, char value) throws EncodeException
Description copied from interface:Encoder
Write aCharacter
type encoding to the given buffer.- Specified by:
writeCharacter
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeCharacter
public void writeCharacter(ProtonBuffer buffer, EncoderState state, Character value) throws EncodeException
Description copied from interface:Encoder
Write aCharacter
type encoding to the given buffer.- Specified by:
writeCharacter
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeTimestamp
public void writeTimestamp(ProtonBuffer buffer, EncoderState state, long value) throws EncodeException
Description copied from interface:Encoder
Write a Time stamp type encoding to the given buffer.- Specified by:
writeTimestamp
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeTimestamp
public void writeTimestamp(ProtonBuffer buffer, EncoderState state, Date value) throws EncodeException
Description copied from interface:Encoder
Write a Time stamp type encoding to the given buffer.- Specified by:
writeTimestamp
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeUUID
public void writeUUID(ProtonBuffer buffer, EncoderState state, UUID value) throws EncodeException
Description copied from interface:Encoder
Write aUUID
type encoding to the given buffer.- Specified by:
writeUUID
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeBinary
public void writeBinary(ProtonBuffer buffer, EncoderState state, Binary value) throws EncodeException
Description copied from interface:Encoder
Writes the contents of the givenBinary
value into the providedProtonBuffer
instance as an AMQP Binary type.If the provided value to write is null an AMQP null type is encoded into the target buffer.
- Specified by:
writeBinary
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeBinary
public void writeBinary(ProtonBuffer buffer, EncoderState state, ProtonBuffer value) throws EncodeException
Description copied from interface:Encoder
Writes the contents of the givenProtonBuffer
value into the providedProtonBuffer
instance as an AMQP Binary type. This method does not modify the read index of the value given such that is can be read later or written again without needing to reset the read index manually.If the provided value to write is null an AMQP null type is encoded into the target buffer.
- Specified by:
writeBinary
in interfaceEncoder
- Parameters:
buffer
- the target buffer where the binary value is to be encodedstate
- theEncoderState
instance that manages the calling threads state tracking.value
- theProtonBuffer
value to be encoded as an AMQP binary instance.- Throws:
EncodeException
- if an error occurs while performing the encode
-
writeBinary
public void writeBinary(ProtonBuffer buffer, EncoderState state, byte[] value) throws EncodeException
Description copied from interface:Encoder
Writes the contents of the givenbyte
value into the providedProtonBuffer
instance as an AMQP Binary type.If the provided value to write is null an AMQP null type is encoded into the target buffer.
- Specified by:
writeBinary
in interfaceEncoder
- Parameters:
buffer
- the target buffer where the binary value is to be encodedstate
- theEncoderState
instance that manages the calling threads state tracking.value
- theProtonBuffer
value to be encoded as an AMQP binary instance.- Throws:
EncodeException
- if an error occurs while performing the encode
-
writeDeliveryTag
public void writeDeliveryTag(ProtonBuffer buffer, EncoderState state, DeliveryTag value) throws EncodeException
Description copied from interface:Encoder
Writes the contents of the givenDeliveryTag
value into the providedProtonBuffer
instance as an AMQP Binary type.If the provided value to write is null an AMQP null type is encoded into the target buffer.
- Specified by:
writeDeliveryTag
in interfaceEncoder
- Parameters:
buffer
- the target buffer where the binary value is to be encodedstate
- theEncoderState
instance that manages the calling threads state tracking.value
- theDeliveryTag
value to be encoded as an AMQP binary instance.- Throws:
EncodeException
- if an error occurs while performing the encode
-
writeString
public void writeString(ProtonBuffer buffer, EncoderState state, String value) throws EncodeException
Description copied from interface:Encoder
Write aString
type encoding to the given buffer.- Specified by:
writeString
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeSymbol
public void writeSymbol(ProtonBuffer buffer, EncoderState state, Symbol value) throws EncodeException
Description copied from interface:Encoder
Write aSymbol
type encoding to the given buffer.- Specified by:
writeSymbol
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeSymbol
public void writeSymbol(ProtonBuffer buffer, EncoderState state, String value) throws EncodeException
Description copied from interface:Encoder
Write aSymbol
type encoding to the given buffer. The providedString
instance should contain only ASCII characters and the encoder should throw anEncodeException
if a non-ASCII character is encountered.- Specified by:
writeSymbol
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeList
public <T> void writeList(ProtonBuffer buffer, EncoderState state, List<T> value) throws EncodeException
Description copied from interface:Encoder
Write aList
type encoding to the given buffer.- Specified by:
writeList
in interfaceEncoder
- Type Parameters:
T
- The type that comprises theList
entries.- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeMap
public <K,V> void writeMap(ProtonBuffer buffer, EncoderState state, Map<K,V> value) throws EncodeException
Description copied from interface:Encoder
Write aMap
type encoding to the given buffer.- Specified by:
writeMap
in interfaceEncoder
- Type Parameters:
K
- the type that comprises theMap
keys.V
- the type that comprises theMap
values.- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeDescribedType
public void writeDescribedType(ProtonBuffer buffer, EncoderState state, DescribedType value) throws EncodeException
Description copied from interface:Encoder
Write aDescribedType
type encoding to the given buffer.- Specified by:
writeDescribedType
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, boolean[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, byte[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, short[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, int[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, long[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, float[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, double[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, char[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, Object[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, Decimal32[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, Decimal64[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, Decimal128[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, Symbol[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, UnsignedByte[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, UnsignedShort[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, UnsignedInteger[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, UnsignedLong[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, UUID[] value) throws EncodeException
Description copied from interface:Encoder
Write the given array as with the proper array type encoding to the given buffer.- Specified by:
writeArray
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
writeObject
public void writeObject(ProtonBuffer buffer, EncoderState state, Object value) throws EncodeException
Description copied from interface:Encoder
Write the proper type encoding for the providedObject
to the given buffer if anTypeEncoder
can be found for it in the collection of registered type encoders..- Specified by:
writeObject
in interfaceEncoder
- Parameters:
buffer
- The buffer where the write operation is targetedstate
- TheEncoderState
to use for any intermediate encoding work.value
- The value to be encoded into the provided buffer.- Throws:
EncodeException
- if an error occurs during the encode operation.
-
registerDescribedTypeEncoder
public <V> ProtonEncoder registerDescribedTypeEncoder(DescribedTypeEncoder<V> encoder)
Description copied from interface:Encoder
Register aDescribedTypeEncoder
which can be used when writing custom types using this encoder. When an Object write is performed the type encoder registry will be consulted in order to find the best match for the givenObject
instance.- Specified by:
registerDescribedTypeEncoder
in interfaceEncoder
- Type Parameters:
V
- The type that the encoder handles.- Parameters:
encoder
- A newDescribedTypeEncoder
that will be used when encoding its matching type.- Returns:
- this
Encoder
instance.
-
getTypeEncoder
public TypeEncoder<?> getTypeEncoder(Object value)
Description copied from interface:Encoder
Lookup aTypeEncoder
that would be used to encode the givenObject
.- Specified by:
getTypeEncoder
in interfaceEncoder
- Parameters:
value
- The value which should be used to resolve theTypeEncoder
that encodes it.- Returns:
- the matching
TypeEncoder
for the given value or null if no match found.
-
getTypeEncoder
public TypeEncoder<?> getTypeEncoder(Class<?> typeClass)
Description copied from interface:Encoder
Lookup aTypeEncoder
that would be used to encode the givenClass
.- Specified by:
getTypeEncoder
in interfaceEncoder
- Parameters:
typeClass
- TheClass
which should be used to resolve theTypeEncoder
that encodes it.- Returns:
- the matching
TypeEncoder
for the given value or null if no match found.
-
getTypeEncoder
public TypeEncoder<?> getTypeEncoder(Class<?> typeClass, Object instance)
Lookup aTypeEncoder
by first checking the given typeClass
and then if none found to deduce a valid TypeEncoder from theObject
specified.- Parameters:
typeClass
- TheClass
for which a type specific encoder is requested.instance
- AnObject
instance to use as a fall back if no encoder found for theClass
- Returns:
- a
TypeEncoder
if a match to the given query is found or null of non can be deduced.
-
-