Class HttpFields.Mutable

  • All Implemented Interfaces:
    java.lang.Iterable<HttpField>, HttpFields
    Enclosing interface:
    HttpFields

    public static class HttpFields.Mutable
    extends java.lang.Object
    implements java.lang.Iterable<HttpField>, HttpFields
    HTTP Fields. A collection of HTTP header and or Trailer fields.

    This class is not synchronized as it is expected that modifications will only be performed by a single thread.

    The cookie handling provided by this class is guided by the Servlet specification and RFC6265.

    • Constructor Detail

      • Mutable

        protected Mutable()
        Initialize an empty HttpFields.
    • Method Detail

      • add

        public HttpFields.Mutable add​(java.lang.String name,
                                      java.lang.String value)
        Add to or set a field. If the field is allowed to have multiple values, add will add multiple headers of the same name.
        Parameters:
        name - the name of the field
        value - the value of the field.
        Returns:
        this builder
      • add

        public HttpFields.Mutable add​(HttpHeader header,
                                      java.lang.String value)
        Add to or set a field. If the field is allowed to have multiple values, add will add multiple headers of the same name.
        Parameters:
        header - the header
        value - the value of the field.
        Returns:
        this builder
      • addCSV

        public HttpFields.Mutable addCSV​(HttpHeader header,
                                         java.lang.String... values)
        Add comma separated values, but only if not already present.
        Parameters:
        header - The header to add the value(s) to
        values - The value(s) to add
        Returns:
        this builder
      • addCSV

        public HttpFields.Mutable addCSV​(java.lang.String name,
                                         java.lang.String... values)
        Add comma separated values, but only if not already present.
        Parameters:
        name - The header to add the value(s) to
        values - The value(s) to add
        Returns:
        this builder
      • addDateField

        public HttpFields.Mutable addDateField​(java.lang.String name,
                                               long date)
        Sets the value of a date field.
        Parameters:
        name - the field name
        date - the field date value
        Returns:
        this builder
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • getField

        public HttpField getField​(int index)
        Get a Field by index.
        Specified by:
        getField in interface HttpFields
        Parameters:
        index - the field index
        Returns:
        A Field value or null if the Field value has not been set
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • iterator

        public java.util.Iterator<HttpField> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<HttpField>
      • listIterator

        public java.util.ListIterator<HttpField> listIterator()
      • put

        public HttpFields.Mutable put​(java.lang.String name,
                                      java.lang.String value)
        Set a field.
        Parameters:
        name - the name of the field
        value - the value of the field. If null the field is cleared.
        Returns:
        this builder
      • put

        public HttpFields.Mutable put​(HttpHeader header,
                                      java.lang.String value)
        Set a field.
        Parameters:
        header - the header name of the field
        value - the value of the field. If null the field is cleared.
        Returns:
        this builder
      • put

        public HttpFields.Mutable put​(java.lang.String name,
                                      java.util.List<java.lang.String> list)
        Set a field.
        Parameters:
        name - the name of the field
        list - the List value of the field. If null the field is cleared.
        Returns:
        this builder
      • putDateField

        public HttpFields.Mutable putDateField​(HttpHeader name,
                                               long date)
        Sets the value of a date field.
        Parameters:
        name - the field name
        date - the field date value
        Returns:
        this builder
      • putDateField

        public HttpFields.Mutable putDateField​(java.lang.String name,
                                               long date)
        Sets the value of a date field.
        Parameters:
        name - the field name
        date - the field date value
        Returns:
        this builder
      • putLongField

        public HttpFields.Mutable putLongField​(HttpHeader name,
                                               long value)
        Sets the value of an long field.
        Parameters:
        name - the field name
        value - the field long value
        Returns:
        this builder
      • putLongField

        public HttpFields.Mutable putLongField​(java.lang.String name,
                                               long value)
        Sets the value of an long field.
        Parameters:
        name - the field name
        value - the field long value
        Returns:
        this builder
      • remove

        public HttpFields.Mutable remove​(HttpHeader name)
        Remove a field.
        Parameters:
        name - the field to remove
        Returns:
        this builder
      • remove

        public HttpFields.Mutable remove​(java.lang.String name)
        Remove a field.
        Parameters:
        name - the field to remove
        Returns:
        this builder
      • size

        public int size()
        Specified by:
        size in interface HttpFields
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object