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

public Class BasicHeaderIterator

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

Basic implementation of a HeaderIterator.
Since
4.0

Field Summary

Modifier and TypeField and Description
protected final Header[]
allHeaders

An array of headers to iterate over.

protected int
currentIndex

The position of the next header in allHeaders.

protected 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
protected 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.

protected 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 org.apache.http.HeaderIterator.hasNext.

Indicates whether there is another header in this iteration.
public final Object

Returns:

the next header in this iteration
next
()

Implements java.util.Iterator.next.

Returns the next header.
public Header

Returns:

the next header in this iteration
nextHeader
()

Implements org.apache.http.HeaderIterator.nextHeader.

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
protected 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
protected int currentIndex

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

headerNameback to summary
protected 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
protected 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
protected 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 org.apache.http.HeaderIterator.hasNext.

Doc from org.apache.http.HeaderIterator.hasNext.

Indicates whether there is another header in this iteration.

Returns:boolean

true if there is another header, false otherwise

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

Implements java.util.Iterator.next.

Returns the next header. Same as nextHeader, but not type-safe.

Returns:Object

the next header in this iteration

Annotations
@Override
Exceptions
NoSuchElementException:
if there are no more headers
nextHeaderback to summary
public Header nextHeader() throws NoSuchElementException

Implements org.apache.http.HeaderIterator.nextHeader.

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