Class PathCompiler

java.lang.Object
com.jayway.jsonpath.internal.path.PathCompiler

public class PathCompiler extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • compile

      private Path compile()
    • compile

      public static Path compile(String path, Predicate... filters)
    • readWhitespace

      private void readWhitespace()
    • isPathContext

      private Boolean isPathContext(char c)
    • readContextToken

      private RootPathToken readContextToken()
    • readNextToken

      private boolean readNextToken(PathTokenAppender appender)
    • readDotToken

      private boolean readDotToken(PathTokenAppender appender)
    • readPropertyOrFunctionToken

      private boolean readPropertyOrFunctionToken(PathTokenAppender appender)
    • parseFunctionParameters

      private List<Parameter> 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. 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

      private boolean readPlaceholderToken(PathTokenAppender appender)
    • readFilterToken

      private boolean readFilterToken(PathTokenAppender appender)
    • readWildCardToken

      private boolean readWildCardToken(PathTokenAppender appender)
    • readArrayToken

      private boolean readArrayToken(PathTokenAppender appender)
    • readBracketPropertyToken

      private boolean readBracketPropertyToken(PathTokenAppender appender)
    • fail

      public static boolean fail(String message)