|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.http.message.BasicTokenIterator
@NotThreadSafe public class BasicTokenIterator
Basic implementation of a TokenIterator.
This implementation parses #token sequences as
defined by RFC 2616, section 2.
It extends that definition somewhat beyond US-ASCII.
| Field Summary | |
|---|---|
protected String |
currentHeader
The value of the current header. |
protected String |
currentToken
The token to be returned by the next call to currentToken. |
protected HeaderIterator |
headerIt
The iterator from which to obtain the next header. |
static String |
HTTP_SEPARATORS
The HTTP separator characters. |
protected int |
searchPos
The position after currentToken in currentHeader. |
| Constructor Summary | |
|---|---|
BasicTokenIterator(HeaderIterator headerIterator)
Creates a new instance of BasicTokenIterator. |
|
| Method Summary | |
|---|---|
protected String |
createToken(String value,
int start,
int end)
Creates a new token to be returned. |
protected int |
findNext(int from)
Determines the next token. |
protected int |
findTokenEnd(int from)
Determines the ending position of the current token. |
protected int |
findTokenSeparator(int from)
Determines the position of the next token separator. |
protected int |
findTokenStart(int from)
Determines the starting position of the next token. |
boolean |
hasNext()
Indicates whether there is another token in this iteration. |
protected boolean |
isHttpSeparator(char ch)
Checks whether a character is an HTTP separator. |
protected boolean |
isTokenChar(char ch)
Checks whether a character is a valid token character. |
protected boolean |
isTokenSeparator(char ch)
Checks whether a character is a token separator. |
protected boolean |
isWhitespace(char ch)
Checks whether a character is a whitespace character. |
Object |
next()
Returns the next token. |
String |
nextToken()
Obtains the next token from this iteration. |
void |
remove()
Removing tokens is not supported. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String HTTP_SEPARATORS
protected final HeaderIterator headerIt
protected String currentHeader
currentToken.
Undefined if the iteration is over.
protected String currentToken
currentToken.
null if the iteration is over.
protected int searchPos
currentToken in currentHeader.
Undefined if the iteration is over.
| Constructor Detail |
|---|
public BasicTokenIterator(HeaderIterator headerIterator)
BasicTokenIterator.
headerIterator - the iterator for the headers to tokenize| Method Detail |
|---|
public boolean hasNext()
TokenIterator
hasNext in interface Iterator<Object>hasNext in interface TokenIteratortrue if there is another token,
false otherwise
public String nextToken()
throws NoSuchElementException,
ParseException
nextToken in interface TokenIteratorNoSuchElementException - if the iteration is already over
ParseException - if an invalid header value is encountered
public final Object next()
throws NoSuchElementException,
ParseException
nextToken(), but with generic return type.
next in interface Iterator<Object>NoSuchElementException - if there are no more tokens
ParseException - if an invalid header value is encountered
public final void remove()
throws UnsupportedOperationException
remove in interface Iterator<Object>UnsupportedOperationException - always
protected int findNext(int from)
throws ParseException
currentToken.
The return value indicates the position after the token
in currentHeader. If necessary, the next header
will be obtained from headerIt.
If not found, currentToken is set to null.
from - the position in the current header at which to
start the search, -1 to search in the first header
ParseException - if an invalid header value is encountered
protected String createToken(String value,
int start,
int end)
findNext after the token is identified.
The default implementation simply calls
String.substring.
value - the full header value from which to create a tokenstart - the index of the first token characterend - the index after the last token character
protected int findTokenStart(int from)
from - the position in the current header at which to
start the search
protected int findTokenSeparator(int from)
from - the position in the current header at which to
start the search
ParseException - if a new token is found before a token separator.
RFC 2616, section 2.1 explicitly requires a comma between
tokens for #.protected int findTokenEnd(int from)
from - the position of the first character of the token
from does not
point to a token character in the current header value.protected boolean isTokenSeparator(char ch)
ch - the character to check
true if the character is a token separator,
false otherwiseprotected boolean isWhitespace(char ch)
ch - the character to check
true if the character is whitespace,
false otherwiseprotected boolean isTokenChar(char ch)
ch - the character to check
true if the character is a valid token start,
false otherwiseprotected boolean isHttpSeparator(char ch)
ch - the character to check
true if the character is an HTTP separator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||