Interface Headers

    • Method Detail

      • size

        int size()
        Get the number of headers in this object.
        Returns:
        the number of headers; never negative
      • isEmpty

        boolean isEmpty()
        Determine whether this object has no headers.
        Returns:
        true if there are no headers, or false if there is at least one header
      • allWithName

        Iterator<Header> allWithName​(String key)
        Get the collection of Header objects whose keys all match the specified key.
        Parameters:
        key - the key; may not be null
        Returns:
        the iterator over headers with the specified key; may be null if there are no headers with the specified key
      • lastWithName

        Header lastWithName​(String key)
        Return the last Header with the specified key.
        Parameters:
        key - the key for the header; may not be null
        Returns:
        the last Header, or null if there are no headers with the specified key
      • add

        Headers add​(Header header)
        Add the given Header to this collection.
        Parameters:
        header - the header; may not be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • add

        Headers add​(String key,
                    SchemaAndValue schemaAndValue)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        schemaAndValue - the SchemaAndValue for the header; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • add

        Headers add​(String key,
                    Object value,
                    Schema schema)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        schema - the schema for the header's value; may not be null if the value is not null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addString

        Headers addString​(String key,
                          String value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addBoolean

        Headers addBoolean​(String key,
                           boolean value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addByte

        Headers addByte​(String key,
                        byte value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addShort

        Headers addShort​(String key,
                         short value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addInt

        Headers addInt​(String key,
                       int value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addLong

        Headers addLong​(String key,
                        long value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addFloat

        Headers addFloat​(String key,
                         float value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addDouble

        Headers addDouble​(String key,
                          double value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addBytes

        Headers addBytes​(String key,
                         byte[] value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addList

        Headers addList​(String key,
                        List<?> value,
                        Schema schema)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        schema - the schema describing the list value; may not be null
        Returns:
        this object to facilitate chaining multiple methods; never null
        Throws:
        DataException - if the header's value is invalid
      • addMap

        Headers addMap​(String key,
                       Map<?,​?> value,
                       Schema schema)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        schema - the schema describing the map value; may not be null
        Returns:
        this object to facilitate chaining multiple methods; never null
        Throws:
        DataException - if the header's value is invalid
      • addStruct

        Headers addStruct​(String key,
                          Struct value)
        Add to this collection a Header with the given key and value.
        Parameters:
        key - the header's key; may not be null
        value - the header's value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
        Throws:
        DataException - if the header's value is invalid
      • addDecimal

        Headers addDecimal​(String key,
                           BigDecimal value)
        Add to this collection a Header with the given key and Decimal value.
        Parameters:
        key - the header's key; may not be null
        value - the header's Decimal value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addDate

        Headers addDate​(String key,
                        Date value)
        Add to this collection a Header with the given key and Date value.
        Parameters:
        key - the header's key; may not be null
        value - the header's Date value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addTime

        Headers addTime​(String key,
                        Date value)
        Add to this collection a Header with the given key and Time value.
        Parameters:
        key - the header's key; may not be null
        value - the header's Time value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • addTimestamp

        Headers addTimestamp​(String key,
                             Date value)
        Add to this collection a Header with the given key and Timestamp value.
        Parameters:
        key - the header's key; may not be null
        value - the header's Timestamp value; may be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • remove

        Headers remove​(String key)
        Removes all Header objects whose key matches the specified key.
        Parameters:
        key - the key; may not be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • retainLatest

        Headers retainLatest​(String key)
        Removes all but the latest Header objects whose key matches the specified key.
        Parameters:
        key - the key; may not be null
        Returns:
        this object to facilitate chaining multiple methods; never null
      • retainLatest

        Headers retainLatest()
        Removes all but the last Header object with each key.
        Returns:
        this object to facilitate chaining multiple methods; never null
      • clear

        Headers clear()
        Removes all headers from this object.
        Returns:
        this object to facilitate chaining multiple methods; never null
      • duplicate

        Headers duplicate()
        Create a copy of this Headers object. The new copy will contain all of the same Header objects as this object.
        Returns:
        the copy; never null
      • apply

        Headers apply​(Headers.HeaderTransform transform)
        Get all Headers, apply the transform to each and store the result in place of the original.
        Parameters:
        transform - the transform to apply; may not be null
        Returns:
        this object to facilitate chaining multiple methods; never null
        Throws:
        DataException - if the header's value is invalid
      • apply

        Headers apply​(String key,
                      Headers.HeaderTransform transform)
        Get all Headers with the given key, apply the transform to each and store the result in place of the original.
        Parameters:
        key - the header's key; may not be null
        transform - the transform to apply; may not be null
        Returns:
        this object to facilitate chaining multiple methods; never null
        Throws:
        DataException - if the header's value is invalid