| java.lang.Object org.apache.http.message.BasicTokenIterator
BasicTokenIterator | public class BasicTokenIterator implements TokenIterator(Code) | | 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.
version: $Revision: 602520 $ |
Method Summary | |
protected String | createToken(String value, int start, int end) Creates a new token to be returned.
Called from
BasicTokenIterator.findNext findNext after the token is identified.
The default implementation simply calls
java.lang.String.substring 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. | protected int | findNext(int from) Determines the next token.
If found, the token is stored in
BasicTokenIterator.currentToken .
The return value indicates the position after the token
in
BasicTokenIterator.currentHeader . | 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.
Because of multi-header joining rules, the end of a
header value is a token separator. | protected int | findTokenStart(int from) Determines the starting position of the next token. | public boolean | hasNext() | protected boolean | isHttpSeparator(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. | protected boolean | isTokenChar(char ch) Checks whether a character is a valid token character.
Whitespace, control characters, and HTTP separators are not
valid token characters. | protected boolean | isTokenSeparator(char ch) Checks whether a character is a token separator.
RFC 2616, section 2.1 defines comma as the separator for
#token sequences. | protected boolean | isWhitespace(char ch) Checks whether a character is a whitespace character. | final public Object | next() Returns the next token. | public String | nextToken() Obtains the next token from this iteration. | final public void | remove() Removing tokens is not supported. |
HTTP_SEPARATORS | final public static String HTTP_SEPARATORS(Code) | | The HTTP separator characters. Defined in RFC 2616, section 2.2.
|
headerIt | final protected HeaderIterator headerIt(Code) | | The iterator from which to obtain the next header.
|
BasicTokenIterator | public BasicTokenIterator(HeaderIterator headerIterator)(Code) | | Creates a new instance of
BasicTokenIterator .
Parameters: headerIterator - the iterator for the headers to tokenize |
createToken | protected String createToken(String value, int start, int end)(Code) | | Creates a new token to be returned.
Called from
BasicTokenIterator.findNext findNext after the token is identified.
The default implementation simply calls
java.lang.String.substring 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.
Parameters: value - the full header value from which to create a token Parameters: start - the index of the first token character Parameters: end - the index after the last token character a string representing the token identified by the arguments |
findTokenEnd | protected int findTokenEnd(int from)(Code) | | 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.
Parameters: from - the position of the first character of the token the position after the last character of the token.The behavior is undefined if from does notpoint to a token character in the current header value. |
findTokenSeparator | protected int findTokenSeparator(int from)(Code) | | 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.
Parameters: from - the position in the current header at which tostart the search the position of a token separator in the current header,or at the end throws: ParseException - if a new token is found before a token separator.RFC 2616, section 2.1 explicitly requires a comma betweentokens for #. |
findTokenStart | protected int findTokenStart(int from)(Code) | | Determines the starting position of the next token.
This method will iterate over headers if necessary.
Parameters: from - the position in the current header at which tostart the search the position of the token start in the current header,negative if no token start could be found |
hasNext | public boolean hasNext()(Code) | | |
isHttpSeparator | protected boolean isHttpSeparator(char ch)(Code) | | 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.
Parameters: ch - the character to check true if the character is an HTTP separator |
isTokenChar | protected boolean isTokenChar(char ch)(Code) | | 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.
Parameters: ch - the character to check true if the character is a valid token start,false otherwise |
isTokenSeparator | protected boolean isTokenSeparator(char ch)(Code) | | 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.
Parameters: ch - the character to check true if the character is a token separator,false otherwise |
isWhitespace | protected boolean isWhitespace(char ch)(Code) | | 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.
Parameters: ch - the character to check true if the character is whitespace,false otherwise |
|
|