Methods Summary |
---|
protected boolean | filterHeader(int index)Checks whether a header is part of the iteration.
if (this.headerName == null)
return true;
// non-header elements, including null, will trigger exceptions
final String name = ((Header)this.allHeaders.get(index)).getName();
return this.headerName.equalsIgnoreCase(name);
|
protected int | findNext(int from)Determines the index of the next header.
if (from < -1)
return -1;
final int to = this.allHeaders.size()-1;
boolean found = false;
while (!found && (from < to)) {
from++;
found = filterHeader(from);
}
return found ? from : -1;
|
public boolean | hasNext()
return (this.currentIndex >= 0);
|
public final java.lang.Object | next()Returns the next header.
Same as {@link #nextHeader nextHeader}, but not type-safe.
return nextHeader();
|
public org.apache.http.Header | nextHeader()Obtains the next header from this iteration.
final int current = this.currentIndex;
if (current < 0) {
throw new NoSuchElementException("Iteration already finished.");
}
this.lastIndex = current;
this.currentIndex = findNext(current);
return (Header) this.allHeaders.get(current);
|
public void | remove()Removes the header that was returned last.
if (this.lastIndex < 0) {
throw new IllegalStateException("No header to remove.");
}
this.allHeaders.remove(this.lastIndex);
this.lastIndex = -1;
this.currentIndex--; // adjust for the removed element
|