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

public Class BasicListHeaderIterator

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

Implementation of a HeaderIterator based on a List. For use by HeaderGroup.
Since
4.0

Field Summary

Modifier and TypeField and Description
protected final List<Header>
allHeaders

A list 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.

protected int
lastIndex

The position of the last returned header.

Constructor Summary

AccessConstructor and Description
public
BasicListHeaderIterator(final List<Header>
a list 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.

Removes the header that was returned last.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allHeadersback to summary
protected final List<Header> allHeaders

A list of headers to iterate over. Not all elements of this array are necessarily part of the iteration.

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.

lastIndexback to summary
protected int lastIndex

The position of the last returned header. Negative if none has been returned so far.

Constructor Detail

BasicListHeaderIteratorback to summary
public BasicListHeaderIterator(final List<Header> headers, final String name)

Creates a new header iterator.

Parameters
headers:List<Header>

a list 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.

Removes the header that was returned last.

Annotations
@Override
Exceptions
UnsupportedOperationException:

Doc from java.util.Iterator.remove.

if the remove operation is not supported by this iterator