Interface IMetapathExpression

All Superinterfaces:
IExpression

public interface IMetapathExpression extends IExpression
Supports compiling and executing Metapath expressions.
  • Method Details

    • contextNode

      @NonNull static IMetapathExpression contextNode()
      Get the Metapath expression identifying the current context node.
      Returns:
      the context expression
    • compile

      @NonNull static IMetapathExpression compile(@NonNull String path)
      Compile a Metapath expression string.
      Parameters:
      path - the metapath expression
      Returns:
      the compiled expression object
      Throws:
      InvalidMetapathGrammarException - if an error occurred while compiling the Metapath expression
    • compile

      @NonNull static IMetapathExpression compile(@NonNull String path, @NonNull StaticContext staticContext)
      Compiles a Metapath expression string using the provided static context.
      Parameters:
      path - the metapath expression
      staticContext - the static evaluation context
      Returns:
      the compiled expression object
      Throws:
      InvalidMetapathGrammarException - if an error occurred while compiling the Metapath expression
    • lazyCompile

      @NonNull static IMetapathExpression lazyCompile(@NonNull String path, @NonNull StaticContext staticContext)
      Gets a new Metapath expression that is compiled on use.

      Lazy compilation may cause additional MetapathException errors at evaluation time, since compilation errors are not raised until evaluation.

      Parameters:
      path - the metapath expression
      staticContext - the static evaluation context
      Returns:
      the expression object
    • getPath

      @NonNull String getPath()
      Get the original Metapath expression as a string.
      Specified by:
      getPath in interface IExpression
      Returns:
      the expression
    • getStaticContext

      @NonNull StaticContext getStaticContext()
      Get the static context used to compile this Metapath.
      Returns:
      the static context
    • evaluateAs

      @Nullable default <T> T evaluateAs(@NonNull IMetapathExpression.ResultType resultType)
      Evaluate this Metapath expression without a specific focus. The required result type will be determined by the resultType argument.
      Type Parameters:
      T - the expected result type
      Parameters:
      resultType - the type of result to produce
      Returns:
      the converted result
      Throws:
      TypeMetapathException - if the provided sequence is incompatible with the requested result type
      MetapathException - if an error occurred during evaluation
      See Also:
    • evaluateAs

      @Nullable default <T> T evaluateAs(@Nullable IItem focus, @NonNull IMetapathExpression.ResultType resultType)
      Evaluate this Metapath expression using the provided focus as the initial evaluation context. The required result type will be determined by the resultType argument.
      Type Parameters:
      T - the expected result type
      Parameters:
      focus - the focus of the expression
      resultType - the type of result to produce
      Returns:
      the converted result
      Throws:
      TypeMetapathException - if the provided sequence is incompatible with the requested result type
      MetapathException - if an error occurred during evaluation
      See Also:
    • evaluateAs

      @Nullable default <T> T evaluateAs(@Nullable IItem focus, @NonNull IMetapathExpression.ResultType resultType, @NonNull DynamicContext dynamicContext)
      Evaluate this Metapath expression using the provided focus as the initial evaluation context. The specific result type will be determined by the resultType argument.

      This variant allow for reuse of a provided dynamicContext.

      Type Parameters:
      T - the expected result type
      Parameters:
      focus - the outer focus of the expression
      resultType - the type of result to produce
      dynamicContext - the dynamic context to use for evaluation
      Returns:
      the converted result
      Throws:
      TypeMetapathException - if the provided sequence is incompatible with the requested result type
      MetapathException - if an error occurred during evaluation
      See Also:
    • evaluate

      @NonNull default <T extends IItem> ISequence<T> evaluate()
      Evaluate this Metapath expression without a specific focus.
      Type Parameters:
      T - the type of items contained in the resulting sequence
      Returns:
      a sequence of Metapath items representing the result of the evaluation
      Throws:
      MetapathException - if an error occurred during evaluation
    • evaluate

      @NonNull default <T extends IItem> ISequence<T> evaluate(@Nullable IItem focus)
      Evaluate this Metapath expression using the provided focus as the initial evaluation context.
      Type Parameters:
      T - the type of items contained in the resulting sequence
      Parameters:
      focus - the outer focus of the expression
      Returns:
      a sequence of Metapath items representing the result of the evaluation
      Throws:
      MetapathException - if an error occurred during evaluation
    • evaluate

      @NonNull <T extends IItem> ISequence<T> evaluate(@Nullable IItem focus, @NonNull DynamicContext dynamicContext)
      Evaluate this Metapath expression using the provided focus as the initial evaluation context.

      This variant allow for reuse of a provided dynamicContext.

      Type Parameters:
      T - the type of items contained in the resulting sequence
      Parameters:
      focus - the outer focus of the expression
      dynamicContext - the dynamic context to use for evaluation
      Returns:
      a sequence of Metapath items representing the result of the evaluation
      Throws:
      MetapathException - if an error occurred during evaluation