Top Description Fields Constructors Methods
org.apache.hc.core5.http.message

public Class BasicHeaderIterator

extends Object
implements Iterator<Header>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Imports
java.util.Iterator, .NoSuchElementException, org.apache.hc.core5.http.Header, org.apache.hc.core5.util.Args

java.util.Iterator of org.apache.hc.core5.http.Headers.
Since
4.0

Field Summary

Modifier and TypeField and Description
private final Header[]
allHeaders

An array of headers to iterate over.

private int
currentIndex

The position of the next header in allHeaders.

private final String
headerName

The header name to filter by.

Constructor Summary

AccessConstructor and Description
public
BasicHeaderIterator(final Header[]
an array of headers over which to iterate
headers
,
final String
the name of the headers over which to iterate, or null for any
name
)

Creates a new header iterator.

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

true if the header should be part of the iteration, false to skip
filterHeader
(final int
the index of the header to check
index
)

Checks whether a header is part of the iteration.

private int

Returns:

the index of the next header that matches the filter name, or negative if there are no more headers
findNext
(final int
one less than the index to consider first, -1 to search for the first header
pos
)

Determines the index of the next header.

public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public Header

Returns:

the next header in this iteration
next
()

Implements java.util.Iterator.next.

Obtains the next header from this iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removing headers is not supported.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allHeadersback to summary
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.

currentIndexback to summary
private int currentIndex

The position of the next header in allHeaders. Negative if the iteration is over.

headerNameback to summary
private final String headerName

The header name to filter by. null to iterate over all headers in the array.

Constructor Detail

BasicHeaderIteratorback to summary
public BasicHeaderIterator(final Header[] headers, final String name)

Creates a new header iterator.

Parameters
headers:Header[]

an array of headers over which to iterate

name:String

the name of the headers over which to iterate, or null for any

Method Detail

filterHeaderback to summary
private boolean filterHeader(final int index)

Checks whether a header is part of the iteration.

Parameters
index:int

the index of the header to check

Returns:boolean

true if the header should be part of the iteration, false to skip

findNextback to summary
private int findNext(final int pos)

Determines the index of the next header.

Parameters
pos:int

one less than the index to consider first, -1 to search for the first header

Returns:int

the index of the next header that matches the filter name, or negative if there are no more headers

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Header next() throws NoSuchElementException

Implements java.util.Iterator.next.

Obtains the next header from this iteration.

Returns:Header

the next header in this iteration

Annotations
@Override
Exceptions
NoSuchElementException:
if there are no more headers
removeback to summary
public void remove() throws UnsupportedOperationException

Overrides default java.util.Iterator.remove.

Removing headers is not supported.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always