Class Header

All Implemented Interfaces:
Cloneable

public class Header extends NameValuePair
Represents a header field in an http Request or Response.
  • Constructor Details

    • Header

      public Header()
      Creates a new Header with a null name and value, and no elements.
    • Header

      public Header(String name, String value)
      Creates a new Header with the given name and value, and no elements.
      Parameters:
      name - The name. May be null.
      value - The value. May be null.
    • Header

      public Header(String name, String value, Header.Element... elements)
      Creates a new Header with the given name, value, and elements. If elements is null, then an empty set of elements will be used instead.
      Parameters:
      name - The name. May be null.
      value - The value. May be null.
      elements - The elements. May be null. If null, then getElements() will return an empty array, rather than null.
  • Method Details

    • getElements

      public Header.Element[] getElements()
      Returns an array of Elements for this Header. This array returned will never be null. A new array instance will be returned for every invocation of this method.
      Returns:
      array of Elements. This will never be null.
    • setElements

      public void setElements(Header.Element... elements)
      Sets the elements. If the elements param is null, this will set the empty set of elements. That is, getElements() will return an empty array rather than null.
      Parameters:
      elements - The Elements. May be null. Replaces the old array of elements.
    • toString

      public String toString()
      Overrides:
      toString in class NameValuePair