Class HeaderMap

  • All Implemented Interfaces:
    java.lang.Iterable<HeaderValues>

    public final class HeaderMap
    extends java.lang.Object
    implements java.lang.Iterable<HeaderValues>
    An optimized array-backed header map.
    Author:
    David M. Lloyd
    • Constructor Detail

      • HeaderMap

        public HeaderMap()
    • Method Detail

      • get

        public HeaderValues get​(java.lang.String headerName)
      • getFirst

        public java.lang.String getFirst​(HttpString headerName)
      • getFirst

        public java.lang.String getFirst​(java.lang.String headerName)
      • get

        public java.lang.String get​(HttpString headerName,
                                    int index)
                             throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • get

        public java.lang.String get​(java.lang.String headerName,
                                    int index)
                             throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • getLast

        public java.lang.String getLast​(HttpString headerName)
      • getLast

        public java.lang.String getLast​(java.lang.String headerName)
      • count

        public int count​(HttpString headerName)
      • count

        public int count​(java.lang.String headerName)
      • size

        public int size()
      • fastIterate

        public long fastIterate()
        Do a fast iteration of this header map without creating any objects.
        Returns:
        an opaque iterating cookie, or -1 if no iteration is possible
        See Also:
        fiNext(long), fiCurrent(long)
      • fastIterateNonEmpty

        public long fastIterateNonEmpty()
        Do a fast iteration of this header map without creating any objects, only considering non-empty header values.
        Returns:
        an opaque iterating cookie, or -1 if no iteration is possible
      • fiNext

        public long fiNext​(long cookie)
        Find the next index in a fast iteration.
        Parameters:
        cookie - the previous cookie value
        Returns:
        the next cookie value, or -1L if iteration is done
      • fiNextNonEmpty

        public long fiNextNonEmpty​(long cookie)
        Find the next non-empty index in a fast iteration.
        Parameters:
        cookie - the previous cookie value
        Returns:
        the next cookie value, or -1L if iteration is done
      • fiCurrent

        public HeaderValues fiCurrent​(long cookie)
        Return the value at the current index in a fast iteration.
        Parameters:
        cookie - the iteration cookie value
        Returns:
        the values object at this position
        Throws:
        java.util.NoSuchElementException - if the cookie value is invalid
      • eachValue

        public java.lang.Iterable<java.lang.String> eachValue​(HttpString headerName)
      • iterator

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

        public java.util.Collection<HttpString> getHeaderNames()
      • addFirst

        public HeaderMap addFirst​(HttpString headerName,
                                  java.lang.String headerValue)
      • addAll

        public HeaderMap addAll​(HttpString headerName,
                                java.util.Collection<java.lang.String> headerValues)
      • putAll

        public HeaderMap putAll​(HttpString headerName,
                                java.util.Collection<java.lang.String> headerValues)
      • remove

        public java.util.Collection<java.lang.String> remove​(HttpString headerName)
      • remove

        public java.util.Collection<java.lang.String> remove​(java.lang.String headerName)
      • contains

        public boolean contains​(HttpString headerName)
      • contains

        public boolean contains​(java.lang.String headerName)
      • equals

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

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

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