Class Header
java.lang.Object
software.amazon.awssdk.crt.eventstream.Header
Event-stream header. This object can be represented in many types, so before
using
the getValueAs*() functions, check the value of getHeaderType() and then
decide
which getValueAs*() function to call based on the returned type.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Header
createHeader
(String name, boolean value) Create a header with name of boolean valuestatic Header
createHeader
(String name, byte value) Create a header with name of byte or int8 valuestatic Header
createHeader
(String name, byte[] value) Create a header with name of byte[] valuestatic Header
createHeader
(String name, int value) Create a header with name of int or int32 valuestatic Header
createHeader
(String name, long value) Create a header with name of long or int64 valuestatic Header
createHeader
(String name, short value) Create a header with name of short or int16 valuestatic Header
createHeader
(String name, String value) Create a header with name of String valuestatic Header
createHeader
(String name, Date value) Create a header with name of Date (assumed to be UTC) valuestatic Header
createHeader
(String name, UUID value) Create a header with name of UUID valueboolean
static Header
fromByteBuffer
(ByteBuffer buffer) Marshals buffer into a Header instanceGets the header type of the value.getName()
Gets the name of the header as a (UTF-8) stringint
boolean
Gets the value as a boolean.byte
Gets the value as a byte or int8.byte[]
Gets the value as a byte[].int
Gets the value as an int or int32.long
Gets the value as a long or int64.short
Gets the value as a short or int16.Gets the value as a utf-8 encoded string.Gets the value as a Date.Gets the value as a UUID.int
hashCode()
void
writeToByteBuffer
(ByteBuffer buffer) Writes the value of this header into a buffer, using the wire representation of the header.
-
Method Details
-
createHeader
Create a header with name of boolean value- Parameters:
name
- name for the header.value
- value for the header.- Returns:
- new Header instance
-
createHeader
Create a header with name of byte or int8 value- Parameters:
name
- name for the headervalue
- value for the header- Returns:
- new Header instance
-
createHeader
Create a header with name of String value- Parameters:
name
- name for the headervalue
- value for the header- Returns:
- new Header instance
-
createHeader
Create a header with name of short or int16 value- Parameters:
name
- name for the headervalue
- value for the header- Returns:
- new Header instance
-
createHeader
Create a header with name of int or int32 value- Parameters:
name
- name for the headervalue
- value for the header- Returns:
- new Header instance
-
createHeader
Create a header with name of long or int64 value- Parameters:
name
- name for the headervalue
- value for the header- Returns:
- new Header instance
-
createHeader
Create a header with name of Date (assumed to be UTC) value- Parameters:
name
- name for the headervalue
- value for the header- Returns:
- new Header instance
-
createHeader
Create a header with name of byte[] value- Parameters:
name
- name for the headervalue
- value for the header- Returns:
- new Header instance
-
createHeader
Create a header with name of UUID value- Parameters:
name
- name for the headervalue
- value for the header- Returns:
- new Header instance
-
fromByteBuffer
Marshals buffer into a Header instance- Parameters:
buffer
- buffer to read the header data from- Returns:
- New instance of Header
-
writeToByteBuffer
Writes the value of this header into a buffer, using the wire representation of the header.- Parameters:
buffer
- buffer to write this header into
-
getName
Gets the name of the header as a (UTF-8) string- Returns:
- utf-8 encoded string for the header name
-
getHeaderType
Gets the header type of the value.- Returns:
- HeaderType for this header
-
getValueAsBoolean
public boolean getValueAsBoolean()Gets the value as a boolean. This assumes you've already checked getHeaderType() returns BooleanTrue or BooleanFalse- Returns:
- the value as a boolean
-
getValueAsByte
public byte getValueAsByte()Gets the value as a byte or int8. This assumes you've already checked getHeaderType() returns Byte- Returns:
- the value as a byte
-
getValueAsShort
public short getValueAsShort()Gets the value as a short or int16. This assumes you've already checked getHeaderType() returns Int16- Returns:
- the value as a short
-
getValueAsInt
public int getValueAsInt()Gets the value as an int or int32. This assumes you've already checked getHeaderType() returns Int32- Returns:
- the value as a int
-
getValueAsLong
public long getValueAsLong()Gets the value as a long or int64. This assumes you've already checked getHeaderType() returns Int64- Returns:
- the value as a long
-
getValueAsTimestamp
Gets the value as a Date. This assumes you've already checked getHeaderType() returns TimeStamp- Returns:
- the value as a Date
-
getValueAsBytes
public byte[] getValueAsBytes()Gets the value as a byte[]. This assumes you've already checked getHeaderType() returns ByteBuf- Returns:
- the value as a byte[]
-
getValueAsString
Gets the value as a utf-8 encoded string. This assumes you've already checked getHeaderType() returns String- Returns:
- the value as a utf-8 encoded string
-
getValueAsUUID
Gets the value as a UUID. This assumes you've already checked getHeaderType() returns UUID- Returns:
- the value as a UUID
-
getTotalByteLength
public int getTotalByteLength()- Returns:
- the total binary wire representation length of this header.
-
equals
-
hashCode
public int hashCode()
-