Class StructuredFieldParser
java.lang.Object
org.apache.hc.core5.http.structured.StructuredFieldParser
Strict parser for Structured Field Structured Field Values.
- Since:
- 5.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Tokenizer.Cursorprivate final CharSequenceprivate static final Tokenizer.Delimiterprivate static final Tokenizer.Delimiterprivate static final Tokenizer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateStructuredFieldParser(CharSequence input, Tokenizer.Cursor cursor) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadvance()private booleanatEnd()private static Stringcombine(Iterable<? extends CharSequence> fieldValues) private charcurrent()private ParseExceptionprivate static intlowerHex(char ch) private Stringprivate StructuredFieldBareItemprivate booleanprivate byte[](package private) static StructuredFieldDictionaryparseDictionary(CharSequence input) Parses a complete Structured Field Dictionary field value.(package private) static StructuredFieldDictionaryparseDictionary(CharSequence input, Tokenizer.Cursor cursor) Parses a Dictionary from the current cursor position through its upper bound.(package private) static voidparseDictionaryElement(CharSequence input, Tokenizer.Cursor cursor, Map<String, StructuredFieldMember> accumulator) Parses a single Dictionary entry at the current cursor position intoaccumulator, consuming the surrounding optional whitespace so that the cursor stops at the following comma or the upper bound; a repeated key keeps its last value.(package private) static StructuredFieldDictionaryparseDictionaryLines(Iterable<? extends CharSequence> fieldValues) Combines field lines with a comma and parses an Structured Field Dictionary.private StructuredFieldDictionaryprivate Stringprivate StructuredFieldInnerList(package private) static StructuredFieldItemparseItem(CharSequence input) Parses a complete Structured Field Item field value.(package private) static StructuredFieldItemparseItem(CharSequence input, Tokenizer.Cursor cursor) Parses an Item from the current cursor position through its upper bound.(package private) static StructuredFieldItemparseItemLines(Iterable<? extends CharSequence> fieldValues) Combines field lines with a comma and parses an Structured Field Item.private StructuredFieldItemprivate StringparseKey()(package private) static StructuredFieldListparseList(CharSequence input) Parses a complete Structured Field List field value.(package private) static StructuredFieldListparseList(CharSequence input, Tokenizer.Cursor cursor) Parses a List from the current cursor position through its upper bound.(package private) static StructuredFieldMemberparseListElement(CharSequence input, Tokenizer.Cursor cursor) Parses a single List member at the current cursor position, consuming the surrounding optional whitespace so that the cursor stops at the following comma or the upper bound.(package private) static StructuredFieldListparseListLines(Iterable<? extends CharSequence> fieldValues) Combines field lines with a comma and parses an Structured Field List.private StructuredFieldListprivate StructuredFieldMemberprivate StructuredFieldBareItemprivate StructuredFieldParametersprivate Stringprivate Stringprivate booleanpeek(char ch) private intposition()private voidrequire(char ch) private voidprivate voidprivate voidprivate voidprivate Stringsubsequence(int start, int end)
-
Field Details
-
TOKENIZER
-
KEY_TERMINATOR
-
TOKEN_TERMINATOR
-
input
-
cursor
-
-
Constructor Details
-
StructuredFieldParser
- Throws:
ParseException
-
-
Method Details
-
parseItem
Parses a complete Structured Field Item field value.- Parameters:
input- the field value.- Returns:
- the parsed Item.
- Throws:
ParseException- if the complete value is invalid.
-
parseItem
static StructuredFieldItem parseItem(CharSequence input, Tokenizer.Cursor cursor) throws ParseException Parses an Item from the current cursor position through its upper bound.- Parameters:
input- the character sequence containing the field value.cursor- the bounds and current parse position.- Returns:
- the parsed Item.
- Throws:
ParseException- if the complete bounded value is invalid.
-
parseList
Parses a complete Structured Field List field value.- Parameters:
input- the field value.- Returns:
- the parsed List.
- Throws:
ParseException- if the complete value is invalid.
-
parseList
static StructuredFieldList parseList(CharSequence input, Tokenizer.Cursor cursor) throws ParseException Parses a List from the current cursor position through its upper bound.- Parameters:
input- the character sequence containing the field value.cursor- the bounds and current parse position.- Returns:
- the parsed List.
- Throws:
ParseException- if the complete bounded value is invalid.
-
parseDictionary
Parses a complete Structured Field Dictionary field value.- Parameters:
input- the field value.- Returns:
- the parsed Dictionary.
- Throws:
ParseException- if the complete value is invalid.
-
parseDictionary
static StructuredFieldDictionary parseDictionary(CharSequence input, Tokenizer.Cursor cursor) throws ParseException Parses a Dictionary from the current cursor position through its upper bound.- Parameters:
input- the character sequence containing the field value.cursor- the bounds and current parse position.- Returns:
- the parsed Dictionary.
- Throws:
ParseException- if the complete bounded value is invalid.
-
parseListElement
static StructuredFieldMember parseListElement(CharSequence input, Tokenizer.Cursor cursor) throws ParseException Parses a single List member at the current cursor position, consuming the surrounding optional whitespace so that the cursor stops at the following comma or the upper bound. One field line element is parsed in place, without copying the underlying data.- Parameters:
input- the character sequence containing the field line value.cursor- the bounds and current parse position.- Returns:
- the parsed member.
- Throws:
ParseException- if the member is invalid or is not comma-separated.
-
parseDictionaryElement
static void parseDictionaryElement(CharSequence input, Tokenizer.Cursor cursor, Map<String, StructuredFieldMember> accumulator) throws ParseException Parses a single Dictionary entry at the current cursor position intoaccumulator, consuming the surrounding optional whitespace so that the cursor stops at the following comma or the upper bound; a repeated key keeps its last value. One field line element is parsed in place, without copying the underlying data.- Parameters:
input- the character sequence containing the field line value.cursor- the bounds and current parse position.accumulator- the map into which the parsed entry is merged.- Throws:
ParseException- if the entry is invalid or is not comma-separated.
-
parseItemLines
static StructuredFieldItem parseItemLines(Iterable<? extends CharSequence> fieldValues) throws ParseException Combines field lines with a comma and parses an Structured Field Item.- Parameters:
fieldValues- the field line values.- Returns:
- the parsed Item.
- Throws:
ParseException- if the combined field value is invalid.
-
parseListLines
static StructuredFieldList parseListLines(Iterable<? extends CharSequence> fieldValues) throws ParseException Combines field lines with a comma and parses an Structured Field List.- Parameters:
fieldValues- the field line values.- Returns:
- the parsed List.
- Throws:
ParseException- if the combined field value is invalid.
-
parseDictionaryLines
static StructuredFieldDictionary parseDictionaryLines(Iterable<? extends CharSequence> fieldValues) throws ParseException Combines field lines with a comma and parses an Structured Field Dictionary.- Parameters:
fieldValues- the field line values.- Returns:
- the parsed Dictionary.
- Throws:
ParseException- if the combined field value is invalid.
-
combine
-
parseListValue
- Throws:
ParseException
-
parseDictionaryValue
- Throws:
ParseException
-
requireElementSeparator
- Throws:
ParseException
-
parseMember
- Throws:
ParseException
-
parseInnerList
- Throws:
ParseException
-
parseItemValue
- Throws:
ParseException
-
parseParameters
- Throws:
ParseException
-
parseKey
- Throws:
ParseException
-
parseBareItem
- Throws:
ParseException
-
parseNumber
- Throws:
ParseException
-
parseString
- Throws:
ParseException
-
parseToken
-
parseByteSequence
- Throws:
ParseException
-
padBase64
- Throws:
ParseException
-
parseBoolean
- Throws:
ParseException
-
parseDisplayString
- Throws:
ParseException
-
lowerHex
private static int lowerHex(char ch) -
skipSpaces
private void skipSpaces() -
skipOptionalWhitespace
private void skipOptionalWhitespace() -
peek
private boolean peek(char ch) -
require
- Throws:
ParseException
-
requireEnd
- Throws:
ParseException
-
current
private char current() -
position
private int position() -
advance
private void advance() -
subsequence
-
atEnd
private boolean atEnd() -
error
-