java.lang.Object | |
↳ | org.apache.http.message.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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | HTTP_SEPARATORS | The HTTP separator characters. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
currentHeader | The value of the current header. | ||||||||||
currentToken | The token to be returned by the next call to currentToken. | ||||||||||
headerIt | The iterator from which to obtain the next header. | ||||||||||
searchPos | The position after currentToken in currentHeader. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new instance of BasicTokenIterator.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Indicates whether there is another token in this iteration.
| |||||||||||
Returns the next token.
| |||||||||||
Obtains the next token from this iteration.
| |||||||||||
Removing tokens is not supported.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new token to be returned.
| |||||||||||
Determines the next token.
| |||||||||||
Determines the ending position of the current token.
| |||||||||||
Determines the position of the next token separator.
| |||||||||||
Determines the starting position of the next token.
| |||||||||||
Checks whether a character is an HTTP separator.
| |||||||||||
Checks whether a character is a valid token character.
| |||||||||||
Checks whether a character is a token separator.
| |||||||||||
Checks whether a character is a whitespace character.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface java.util.Iterator
| |||||||||||
From interface org.apache.http.TokenIterator
|
The HTTP separator characters. Defined in RFC 2616, section 2.2.
The value of the current header. This is the header value that includes currentToken. Undefined if the iteration is over.
The token to be returned by the next call to currentToken.
null
if the iteration is over.
The iterator from which to obtain the next header.
The position after currentToken in currentHeader. Undefined if the iteration is over.
Creates a new instance of BasicTokenIterator.
headerIterator | the iterator for the headers to tokenize |
---|
Indicates whether there is another token in this iteration.
true
if there is another token,
false
otherwise
Returns the next token. Same as nextToken(), but with generic return type.
NoSuchElementException | if there are no more tokens |
---|---|
ParseException | if an invalid header value is encountered |
Obtains the next token from this iteration.
NoSuchElementException | if the iteration is already over |
---|---|
ParseException | if an invalid header value is encountered |
Removing tokens is not supported.
UnsupportedOperationException | always |
---|
Creates a new token to be returned.
Called from findNext after the token is identified.
The default implementation simply calls
String.substring.
If header values are significantly longer than tokens, and some
tokens are permanently referenced by the application, there can
be problems with garbage collection. A substring will hold a
reference to the full characters of the original string and
therefore occupies more memory than might be expected.
To avoid this, override this method and create a new string
instead of a substring.
value | the full header value from which to create a token |
---|---|
start | the index of the first token character |
end | the index after the last token character |
Determines the next token.
If found, the token is stored in 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 |
---|
Determines the ending position of the current token. This method will not leave the current header value, since the end of the header value is a token boundary.
from | the position of the first character of the token |
---|
from
does not
point to a token character in the current header value.
Determines the position of the next token separator. Because of multi-header joining rules, the end of a header value is a token separator. This method does therefore not need to iterate over headers.
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 #. |
---|
Determines the starting position of the next token. This method will iterate over headers if necessary.
from | the position in the current header at which to start the search |
---|
Checks whether a character is an HTTP separator. The implementation in this class checks only for the HTTP separators defined in RFC 2616, section 2.2. If you need to detect other separators beyond the US-ASCII character set, override this method.
ch | the character to check |
---|
true
if the character is an HTTP separator
Checks whether a character is a valid token character. Whitespace, control characters, and HTTP separators are not valid token characters. The HTTP specification (RFC 2616, section 2.2) defines tokens only for the US-ASCII character set, this method extends the definition to other character sets.
ch | the character to check |
---|
true
if the character is a valid token start,
false
otherwise
Checks whether a character is a token separator. RFC 2616, section 2.1 defines comma as the separator for #token sequences. The end of a header value will also separate tokens, but that is not a character check.
ch | the character to check |
---|
true
if the character is a token separator,
false
otherwise
Checks whether a character is a whitespace character. RFC 2616, section 2.2 defines space and horizontal tab as whitespace. The optional preceeding line break is irrelevant, since header continuation is handled transparently when parsing messages.
ch | the character to check |
---|
true
if the character is whitespace,
false
otherwise