Class PathCompiler
java.lang.Object
com.jayway.jsonpath.internal.path.PathCompiler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final charprivate static final charprivate static final charprivate static final charprivate static final charprivate static final charprivate static final charprivate static final charprivate static final charprivate final LinkedList<Predicate> private static final charprivate static final charprivate static final charprivate static final charprivate static final charprivate final CharacterIndexprivate static final charprivate static final charprivate static final charprivate static final charprivate static final charprivate static final char -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePathCompiler(CharacterIndex path, LinkedList<Predicate> filterStack) privatePathCompiler(String path, LinkedList<Predicate> filterStack) -
Method Summary
Modifier and TypeMethodDescriptionprivate Pathcompile()static Pathstatic booleanprivate BooleanisPathContext(char c) private booleanisWhitespace(char c) parseFunctionParameters(String funcName) Parse the parameters of a function call, either the caller has supplied JSON data, or the caller has supplied another path expression which must be evaluated and in turn invoked against the root document.private booleanreadArrayToken(PathTokenAppender appender) private booleanreadBracketPropertyToken(PathTokenAppender appender) private RootPathTokenprivate booleanreadDotToken(PathTokenAppender appender) private booleanreadFilterToken(PathTokenAppender appender) private booleanreadNextToken(PathTokenAppender appender) private booleanreadPlaceholderToken(PathTokenAppender appender) private booleanreadPropertyOrFunctionToken(PathTokenAppender appender) private voidprivate booleanreadWildCardToken(PathTokenAppender appender)
-
Field Details
-
DOC_CONTEXT
private static final char DOC_CONTEXT- See Also:
-
EVAL_CONTEXT
private static final char EVAL_CONTEXT- See Also:
-
OPEN_SQUARE_BRACKET
private static final char OPEN_SQUARE_BRACKET- See Also:
-
CLOSE_SQUARE_BRACKET
private static final char CLOSE_SQUARE_BRACKET- See Also:
-
OPEN_PARENTHESIS
private static final char OPEN_PARENTHESIS- See Also:
-
CLOSE_PARENTHESIS
private static final char CLOSE_PARENTHESIS- See Also:
-
OPEN_BRACE
private static final char OPEN_BRACE- See Also:
-
CLOSE_BRACE
private static final char CLOSE_BRACE- See Also:
-
WILDCARD
private static final char WILDCARD- See Also:
-
PERIOD
private static final char PERIOD- See Also:
-
SPACE
private static final char SPACE- See Also:
-
TAB
private static final char TAB- See Also:
-
CR
private static final char CR- See Also:
-
LF
private static final char LF- See Also:
-
BEGIN_FILTER
private static final char BEGIN_FILTER- See Also:
-
COMMA
private static final char COMMA- See Also:
-
SPLIT
private static final char SPLIT- See Also:
-
MINUS
private static final char MINUS- See Also:
-
SINGLE_QUOTE
private static final char SINGLE_QUOTE- See Also:
-
DOUBLE_QUOTE
private static final char DOUBLE_QUOTE- See Also:
-
filterStack
-
path
-
-
Constructor Details
-
PathCompiler
-
PathCompiler
-
-
Method Details
-
compile
-
compile
-
readWhitespace
private void readWhitespace() -
isPathContext
-
readContextToken
-
readNextToken
-
readDotToken
-
readPropertyOrFunctionToken
-
parseFunctionParameters
Parse the parameters of a function call, either the caller has supplied JSON data, or the caller has supplied another path expression which must be evaluated and in turn invoked against the root document. In this tokenizer we're only concerned with parsing the path thus the output of this function is a list of parameters with the Path set if the parameter is an expression. If the parameter is a JSON document then the value of the cachedValue is set on the object. Sequence for parsing out the parameters: This code has its own tokenizer - it does some rudimentary level of lexing in that it can distinguish between JSON block parameters and sub-JSON blocks - it effectively regex's out the parameters into string blocks that can then be passed along to the appropriate parser. Since sub-jsonpath expressions can themselves contain other function calls this routine needs to be sensitive to token counting to determine the boundaries. Since the Path parser isn't aware of JSON processing this uber routine is needed. Parameters are separated by COMMAs ','doc = {"numbers": [1,2,3,4,5,6,7,8,9,10]} $.sum({10}, $.numbers.avg())The above is a valid function call, we're first summing 10 + avg of 1...10 (5.5) so the total should be 15.5- Returns:
- An ordered list of parameters that are to processed via the function. Typically functions either process an array of values and/or can consume parameters in addition to the values provided from the consumption of an array.
-
isWhitespace
private boolean isWhitespace(char c) -
readPlaceholderToken
-
readFilterToken
-
readWildCardToken
-
readArrayToken
-
readBracketPropertyToken
-
fail
-