|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.StreamTokenizer org.melati.util.HttpHeader.Tokenizer
public static class HttpHeader.Tokenizer
Tokenizer for parsing occurences of a field.
Header fields have format defined in RFC 2616 and have the same general form as in RFC 822 section 3.1.
This is for fields consisting of tokens, quoted strings and separators and not those consisting of an arbitrary sequence of octets. Tokens are US ASCII characters other than:
The convenience methods defined here provide some guidance on how to interact with the super-type but you can also use inherited methods.
We assume that the next token is always already read when a method starts to interpret a sequence of tokens. In other words the first token is read by the constructor(s) and then each such method returns as a result of reading a token or EOF that it cannot process but without pushing it back. The next token to be interpreted is hence the current token described by the inherited instance variables.
Note that whitespace is automatically skipped by the supertype.
Field Summary |
---|
Fields inherited from class java.io.StreamTokenizer |
---|
nval, sval, TT_EOF, TT_EOL, TT_NUMBER, TT_WORD, ttype |
Method Summary | |
---|---|
boolean |
isSVal()
Convenience method to test for token or quoted string. |
int |
nextLToken()
Same as nextToken() but does not throw an IOException
and handles erroneous line breaks. |
void |
readChar(char c)
Read the given character that comes next. |
double |
readNVal()
Read the number token that comes next. |
float |
readQValue()
Read a token sequence of the form "; q = 0.42" and return the number. |
String |
readSVal()
Read the word token or quoted string that comes next. |
protected HttpHeader.TokenAndQValue |
readTokenAndQValue(HttpHeader.TokenAndQValue result)
Read a word or quoted string token optionally followed by a string of the form "; q = 0.42" and initialises the given object. |
String |
readWord()
Read the word token that comes next. |
void |
readWord(String word)
Read the given word token that comes next. |
int |
skipAnyCommaSeparator()
Read up to and including the next token after any comma separator(s) and whitespace. |
int |
skipCommaSeparator()
Read up to and including the next token after comma separator(s) and whitespace assuming the current token is a comma. |
Methods inherited from class java.io.StreamTokenizer |
---|
commentChar, eolIsSignificant, lineno, lowerCaseMode, nextToken, ordinaryChar, ordinaryChars, parseNumbers, pushBack, quoteChar, resetSyntax, slashSlashComments, slashStarComments, toString, whitespaceChars, wordChars |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public int nextLToken() throws HttpHeader.HttpHeaderException
nextToken()
but does not throw an IOException
and handles erroneous line breaks.
HttpHeader.HttpHeaderException
- Error detected in the fields.public final int skipCommaSeparator() throws HttpHeader.HttpHeaderException
HttpHeader.HttpHeaderException
public final int skipAnyCommaSeparator() throws HttpHeader.HttpHeaderException
This is the same as skipCommaSeparator()
but it does
nothing if we are and EOF.
HttpHeader.HttpHeaderException
public final boolean isSVal()
If this returns true then the token value is in sval
with any quotes removed.
public final String readSVal() throws HttpHeader.HttpHeaderException
HttpHeader.HttpHeaderException
- Error detected in the fields.public final String readWord() throws HttpHeader.HttpHeaderException
HttpHeader.HttpHeaderException
- Error detected in the fields.public final void readWord(String word) throws HttpHeader.HttpHeaderException
HttpHeader.HttpHeaderException
- Error detected in the fields.public final void readChar(char c) throws HttpHeader.HttpHeaderException
HttpHeader.HttpHeaderException
- Error detected in the fields.public final double readNVal() throws HttpHeader.HttpHeaderException
HttpHeader.HttpHeaderException
- Error detected in the fields.public final float readQValue() throws IllegalStateException, HttpHeader.HttpHeaderException
IllegalStateException
- Current token not semicolon.
HttpHeader.HttpHeaderException
- Error detected in the fields.protected HttpHeader.TokenAndQValue readTokenAndQValue(HttpHeader.TokenAndQValue result) throws HttpHeader.HttpHeaderException
HttpHeader.HttpHeaderException
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |