Class Length

  • All Implemented Interfaces:
    PathFunction

    public class Length
    extends java.lang.Object
    implements PathFunction
    Provides the length of a JSONArray Object Created by mattg on 6/26/15.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String TOKEN_NAME  
    • Constructor Summary

      Constructors 
      Constructor Description
      Length()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object invoke​(java.lang.String currentPath, PathRef parent, java.lang.Object model, EvaluationContext ctx, java.util.List<Parameter> parameters)
      When we calculate the length of a path, what we're asking is given the node we land on how many children does it have.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Length

        public Length()
    • Method Detail

      • invoke

        public java.lang.Object invoke​(java.lang.String currentPath,
                                       PathRef parent,
                                       java.lang.Object model,
                                       EvaluationContext ctx,
                                       java.util.List<Parameter> parameters)
        When we calculate the length of a path, what we're asking is given the node we land on how many children does it have. Thus when we wrote the original query what we really wanted was $..book.length() or $.length($..book.*)
        Specified by:
        invoke in interface PathFunction
        Parameters:
        currentPath - The current path location inclusive of the function name
        parent - The path location above the current function
        model - The JSON model as input to this particular function
        ctx - Eval context, state bag used as the path is traversed, maintains the result of executing
        parameters -
        Returns: