Class BasicListHeaderIterator

java.lang.Object
org.apache.hc.core5.http.message.BasicListHeaderIterator
All Implemented Interfaces:
Iterator<Header>

class BasicListHeaderIterator extends Object implements Iterator<Header>
Iterator of Headers. For use by HeaderGroup.
Since:
4.0
  • Field Details

    • allHeaders

      private final List<Header> allHeaders
      A list of headers to iterate over. Not all elements of this array are necessarily part of the iteration.
    • currentIndex

      private int currentIndex
      The position of the next header in allHeaders. Negative if the iteration is over.
    • lastIndex

      private int lastIndex
      The position of the last returned header. Negative if none has been returned so far.
    • headerName

      private final String headerName
      The header name to filter by. null to iterate over all headers in the array.
  • Constructor Details

    • BasicListHeaderIterator

      public BasicListHeaderIterator(List<Header> headers, String name)
      Creates a new header iterator.
      Parameters:
      headers - a list of headers over which to iterate
      name - the name of the headers over which to iterate, or null for any
  • Method Details

    • findNext

      protected int findNext(int pos)
      Determines the index of the next header.
      Parameters:
      pos - one less than the index to consider first, -1 to search for the first header
      Returns:
      the index of the next header that matches the filter name, or negative if there are no more headers
    • filterHeader

      private boolean filterHeader(int index)
      Checks whether a header is part of the iteration.
      Parameters:
      index - the index of the header to check
      Returns:
      true if the header should be part of the iteration, false to skip
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Header>
    • next

      public Header next() throws NoSuchElementException
      Obtains the next header from this iteration.
      Specified by:
      next in interface Iterator<Header>
      Returns:
      the next header in this iteration
      Throws:
      NoSuchElementException - if there are no more headers
    • remove

      public void remove() throws UnsupportedOperationException
      Removes the header that was returned last.
      Specified by:
      remove in interface Iterator<Header>
      Throws:
      UnsupportedOperationException