java.lang.Object
software.amazon.awssdk.crt.eventstream.Header

public class Header extends Object
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 Details

    • createHeader

      public static Header createHeader(String name, boolean value)
      Create a header with name of boolean value
      Parameters:
      name - name for the header.
      value - value for the header.
      Returns:
      new Header instance
    • createHeader

      public static Header createHeader(String name, byte value)
      Create a header with name of byte or int8 value
      Parameters:
      name - name for the header
      value - value for the header
      Returns:
      new Header instance
    • createHeader

      public static Header createHeader(String name, String value)
      Create a header with name of String value
      Parameters:
      name - name for the header
      value - value for the header
      Returns:
      new Header instance
    • createHeader

      public static Header createHeader(String name, short value)
      Create a header with name of short or int16 value
      Parameters:
      name - name for the header
      value - value for the header
      Returns:
      new Header instance
    • createHeader

      public static Header createHeader(String name, int value)
      Create a header with name of int or int32 value
      Parameters:
      name - name for the header
      value - value for the header
      Returns:
      new Header instance
    • createHeader

      public static Header createHeader(String name, long value)
      Create a header with name of long or int64 value
      Parameters:
      name - name for the header
      value - value for the header
      Returns:
      new Header instance
    • createHeader

      public static Header createHeader(String name, Date value)
      Create a header with name of Date (assumed to be UTC) value
      Parameters:
      name - name for the header
      value - value for the header
      Returns:
      new Header instance
    • createHeader

      public static Header createHeader(String name, byte[] value)
      Create a header with name of byte[] value
      Parameters:
      name - name for the header
      value - value for the header
      Returns:
      new Header instance
    • createHeader

      public static Header createHeader(String name, UUID value)
      Create a header with name of UUID value
      Parameters:
      name - name for the header
      value - value for the header
      Returns:
      new Header instance
    • fromByteBuffer

      public static Header fromByteBuffer(ByteBuffer buffer)
      Marshals buffer into a Header instance
      Parameters:
      buffer - buffer to read the header data from
      Returns:
      New instance of Header
    • writeToByteBuffer

      public void writeToByteBuffer(ByteBuffer buffer)
      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

      public String getName()
      Gets the name of the header as a (UTF-8) string
      Returns:
      utf-8 encoded string for the header name
    • getHeaderType

      public HeaderType 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

      public Date 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

      public String 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

      public UUID 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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object