Package org.apache.hc.core5.http.message
Class BasicHeaderIterator
- java.lang.Object
-
- org.apache.hc.core5.http.message.BasicHeaderIterator
-
-
Field Summary
Fields Modifier and Type Field Description private Header[]
allHeaders
An array of headers to iterate over.private int
currentIndex
The position of the next header inallHeaders
.private java.lang.String
headerName
The header name to filter by.
-
Constructor Summary
Constructors Constructor Description BasicHeaderIterator(Header[] headers, java.lang.String name)
Creates a new header iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
filterHeader(int index)
Checks whether a header is part of the iteration.private int
findNext(int pos)
Determines the index of the next header.boolean
hasNext()
Header
next()
Obtains the next header from this iteration.void
remove()
Removing headers is not supported.
-
-
-
Field Detail
-
allHeaders
private final Header[] allHeaders
An array of headers to iterate over. Not all elements of this array are necessarily part of the iteration. This array will never be modified by the iterator. Derived implementations are expected to adhere to this restriction.
-
currentIndex
private int currentIndex
The position of the next header inallHeaders
. Negative if the iteration is over.
-
headerName
private final java.lang.String headerName
The header name to filter by.null
to iterate over all headers in the array.
-
-
Constructor Detail
-
BasicHeaderIterator
public BasicHeaderIterator(Header[] headers, java.lang.String name)
Creates a new header iterator.- Parameters:
headers
- an array of headers over which to iteratename
- the name of the headers over which to iterate, ornull
for any
-
-
Method Detail
-
findNext
private 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 interfacejava.util.Iterator<Header>
-
next
public Header next() throws java.util.NoSuchElementException
Obtains the next header from this iteration.- Specified by:
next
in interfacejava.util.Iterator<Header>
- Returns:
- the next header in this iteration
- Throws:
java.util.NoSuchElementException
- if there are no more headers
-
remove
public void remove() throws java.lang.UnsupportedOperationException
Removing headers is not supported.- Specified by:
remove
in interfacejava.util.Iterator<Header>
- Throws:
java.lang.UnsupportedOperationException
- always
-
-