TokenIterator.
This implementation parses #token sequences as
defined by RFC 2616, section 2.
It extends that definition somewhat beyond US-ASCII.
| Modifier and Type | Field and Description |
|---|---|
| protected String | currentHeader
The value of the current header. |
| protected String | currentToken
The token to be returned by the next call to |
| protected final HeaderIterator | headerIt
The iterator from which to obtain the next header. |
| public static final String | HTTP_SEPARATORS
The HTTP separator characters. |
| protected int | searchPos
The position after |
| Access | Constructor and Description |
|---|---|
| public | BasicTokenIterator(final HeaderIterator
the iterator for the headers to tokenize headerIterator)Creates a new instance of |
| Modifier and Type | Method and Description |
|---|---|
| protected String | Returns: a string representing the token identified by the argumentsthe full header value from which to create a token value, final int the index of the first token character start, final int the index after the last token character end)Creates a new token to be returned. |
| protected int | Returns: the position after the found token in the current header, or negative if there was no next tokenthe position in the current header at which to
start the search, -1 to search in the first header pos)Determines the next token. |
| protected int | Returns: the position after the last character of the token. The behavior is undefined iffrom does not
point to a token character in the current header value.the position of the first character of the token from)Determines the ending position of the current token. |
| protected int | Returns: the position of a token separator in the current header, or at the endthe position in the current header at which to
start the search pos)Determines the position of the next token separator. |
| protected int | Returns: the position of the token start in the current header, negative if no token start could be foundthe position in the current header at which to
start the search pos)Determines the starting position of the next token. |
| public boolean | hasNext()
Implements org. |
| protected boolean | Returns: true if the character is an HTTP separatorthe character to check ch)Checks whether a character is an HTTP separator. |
| protected boolean | Returns: true if the character is a valid token start,
false otherwisethe character to check ch)Checks whether a character is a valid token character. |
| protected boolean | Returns: true if the character is a token separator,
false otherwisethe character to check ch)Checks whether a character is a token separator. |
| protected boolean | Returns: true if the character is whitespace,
false otherwisethe character to check ch)Checks whether a character is a whitespace character. |
| public final Object | Returns: the next token in this iterationImplements java. |
| public String | Returns: the next token in this iterationImplements org. |
| public final void |
| currentHeader | back to summary |
|---|---|
| protected String currentHeader The value of the current header.
This is the header value that includes | |
| currentToken | back to summary |
|---|---|
| protected String currentToken The token to be returned by the next call to | |
| headerIt | back to summary |
|---|---|
| protected final HeaderIterator headerIt The iterator from which to obtain the next header. | |
| HTTP_SEPARATORS | back to summary |
|---|---|
| public static final String HTTP_SEPARATORS The HTTP separator characters. Defined in RFC 2616, section 2.2. | |
| searchPos | back to summary |
|---|---|
| protected int searchPos The position after | |
| BasicTokenIterator | back to summary |
|---|---|
| public BasicTokenIterator(final HeaderIterator headerIterator) Creates a new instance of
| |
| createToken | back to summary |
|---|---|
| protected String createToken(final String value, final int start, final int end) Creates a new token to be returned.
Called from 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. | |
| findNext | back to summary |
|---|---|
| protected int findNext(final int pos) throws ParseException Determines the next token.
If found, the token is stored in
| |
| findTokenEnd | back to summary |
|---|---|
| protected int findTokenEnd(final int from) 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.
| |
| findTokenSeparator | back to summary |
|---|---|
| protected int findTokenSeparator(final int pos) 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.
| |
| findTokenStart | back to summary |
|---|---|
| protected int findTokenStart(final int pos) Determines the starting position of the next token. This method will iterate over headers if necessary.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements org. Doc from org. Indicates whether there is another token in this iteration.
| |
| isHttpSeparator | back to summary |
|---|---|
| protected boolean isHttpSeparator(final char ch) 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.
| |
| isTokenChar | back to summary |
|---|---|
| protected boolean isTokenChar(final char ch) 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.
| |
| isTokenSeparator | back to summary |
|---|---|
| protected boolean isTokenSeparator(final char ch) Checks whether a character is a token separator.
RFC 2616, section 2.1 defines comma as the separator for
| |
| isWhitespace | back to summary |
|---|---|
| protected boolean isWhitespace(final char ch) 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.
| |
| next | back to summary |
|---|---|
| public final Object next() throws NoSuchElementException, ParseException Implements java. Returns the next token.
Same as
| |
| nextToken | back to summary |
|---|---|
| public String nextToken() throws NoSuchElementException, ParseException Implements org. Obtains the next token from this iteration.
| |
| remove | back to summary |
|---|---|
| public final void remove() throws UnsupportedOperationException Overrides default java. Removing tokens is not supported.
| |