public abstract class HeaderParser extends Object
Modifier and Type | Field and Description |
---|---|
protected static char[] |
TOKEN_CHARS
Eligible token characters.
|
Constructor and Description |
---|
HeaderParser() |
Modifier and Type | Method and Description |
---|---|
static char |
expectSeparator(String s,
ParsePosition pos,
char separator,
boolean force)
Check for a separator or end of string.
|
static char |
expectSeparator(String s,
ParsePosition pos,
String separators,
boolean force)
Check for one of the given separator characters or end of string.
|
static boolean |
isTokenChar(char c) |
static String |
parseQuotedString(String s,
ParsePosition pos)
Parse a quoted string as specified by
quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
qdtext = HTAB / SP /%x21 / %x23-5B / %x5D-7E / obs-text
obs-text = %x80-FF
quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
static String |
parseToken(String s,
ParsePosition pos)
Parse a token as specified by
token = 1*tchar
tchar = "!"
|
static String |
parseTokenOrQuotedString(String s,
ParsePosition pos)
Parse a token or a quoted string depending on whether the current character
is a double quote or not.
|
static void |
skipWhite(String s,
ParsePosition pos)
Skip whit space in a string.
|
protected static char[] TOKEN_CHARS
public static void skipWhite(String s, ParsePosition pos)
s
- The string to parse from.pos
- A parse position to advance past the last whitespace or to the end
of the string.public static char expectSeparator(String s, ParsePosition pos, char separator, boolean force) throws ParseException
s
- The string to parse from.pos
- The position to check for the separator.separator
- The separator to expect.force
- If true
, end-of-string will throw an exception instead of
returning a null character.ParseException
- If the first non-whitespace character is not the expected separator.public static char expectSeparator(String s, ParsePosition pos, String separators, boolean force) throws ParseException
s
- The string to parse from.pos
- The position to check for the separator.separators
- A string containing separator characters to expect.force
- If true
, end-of-string will throw an exception instead of
returning a null character.ParseException
- If the first non-whitespace character is not the expected separator.public static boolean isTokenChar(char c)
c
- The character to check.public static String parseToken(String s, ParsePosition pos) throws ParseException
token = 1*tchar tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA ; any VCHAR, except delimiters
s
- The string to parse from.pos
- A parse position to start from, where a token is expected. The position
is advanced past the last token character found.ParseException
- When there is not at lest one token character.public static String parseQuotedString(String s, ParsePosition pos) throws ParseException
quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE qdtext = HTAB / SP /%x21 / %x23-5B / %x5D-7E / obs-text obs-text = %x80-FF quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
s
- The string to parse from.pos
- A parse position to start from, where a quoted string is expected. The position
is advanced past the last token character found.ParseException
- When there is not at lest one token character.public static String parseTokenOrQuotedString(String s, ParsePosition pos) throws ParseException
s
- The string to parse from.pos
- A parse position to start from, where a token or quoted string is expected.
The position is advanced past the last token character found or past
the terminating double quote of the quoted string.ParseException
- When there is not at lest one token character.Copyright © 2018 Clazzes.org. All rights reserved.