@NotThreadSafe public class BasicListHeaderIterator extends java.lang.Object implements HeaderIterator
Modifier and Type | Field and Description |
---|---|
protected java.util.List<Header> |
allHeaders
A list of headers to iterate over.
|
protected int |
currentIndex
The position of the next header in
allHeaders . |
protected java.lang.String |
headerName
The header name to filter by.
|
protected int |
lastIndex
The position of the last returned header.
|
Constructor and Description |
---|
BasicListHeaderIterator(java.util.List<Header> headers,
java.lang.String name)
Creates a new header iterator.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
filterHeader(int index)
Checks whether a header is part of the iteration.
|
protected int |
findNext(int pos)
Determines the index of the next header.
|
boolean |
hasNext()
Indicates whether there is another header in this iteration.
|
java.lang.Object |
next()
Returns the next header.
|
Header |
nextHeader()
Obtains the next header from this iteration.
|
void |
remove()
Removes the header that was returned last.
|
protected final java.util.List<Header> allHeaders
protected int currentIndex
allHeaders
.
Negative if the iteration is over.protected int lastIndex
protected java.lang.String headerName
null
to iterate over all headers in the array.public BasicListHeaderIterator(java.util.List<Header> headers, java.lang.String name)
headers
- a list of headers over which to iteratename
- the name of the headers over which to iterate, or
null
for anyprotected int findNext(int pos)
pos
- one less than the index to consider first,
-1 to search for the first headerprotected boolean filterHeader(int index)
index
- the index of the header to checktrue
if the header should be part of the
iteration, false
to skippublic boolean hasNext()
HeaderIterator
hasNext
in interface java.util.Iterator<java.lang.Object>
hasNext
in interface HeaderIterator
true
if there is another header,
false
otherwisepublic Header nextHeader() throws java.util.NoSuchElementException
nextHeader
in interface HeaderIterator
java.util.NoSuchElementException
- if there are no more headerspublic final java.lang.Object next() throws java.util.NoSuchElementException
nextHeader
, but not type-safe.next
in interface java.util.Iterator<java.lang.Object>
java.util.NoSuchElementException
- if there are no more headerspublic void remove() throws java.lang.UnsupportedOperationException
remove
in interface java.util.Iterator<java.lang.Object>
java.lang.UnsupportedOperationException