- All Superinterfaces:
IExpression
Supports compiling and executing Metapath expressions.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumIdentifies the expected type for a Metapath evaluation result. -
Method Summary
Modifier and TypeMethodDescriptionstatic IMetapathExpressionCompile a Metapath expression string.static IMetapathExpressioncompile(String path, StaticContext staticContext) Compiles a Metapath expression string using the provided static context.static IMetapathExpressionGet the Metapath expression identifying the current context node.evaluate()Evaluate this Metapath expression without a specific focus.Evaluate this Metapath expression using the providedfocusas the initial evaluation context.evaluate(IItem focus, DynamicContext dynamicContext) Evaluate this Metapath expression using the providedfocusas the initial evaluation context.default <T> TevaluateAs(IMetapathExpression.ResultType resultType) Evaluate this Metapath expression without a specific focus.default <T> TevaluateAs(IItem focus, IMetapathExpression.ResultType resultType) Evaluate this Metapath expression using the providedfocusas the initial evaluation context.default <T> TevaluateAs(IItem focus, IMetapathExpression.ResultType resultType, DynamicContext dynamicContext) Evaluate this Metapath expression using the providedfocusas the initial evaluation context.getPath()Get the original Metapath expression as a string.Get the static context used to compile this Metapath.static IMetapathExpressionlazyCompile(String path, StaticContext staticContext) Gets a new Metapath expression that is compiled on use.Methods inherited from interface dev.metaschema.core.metapath.IExpression
accept, accept, getBaseResultType, getChildren, getStaticResultType, toCSTString
-
Method Details
-
contextNode
Get the Metapath expression identifying the current context node.- Returns:
- the context expression
-
compile
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 expressionstaticContext- 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
MetapathExceptionerrors at evaluation time, since compilation errors are not raised until evaluation.- Parameters:
path- the metapath expressionstaticContext- the static evaluation context- Returns:
- the expression object
-
getPath
Get the original Metapath expression as a string.- Specified by:
getPathin interfaceIExpression- Returns:
- the expression
-
getStaticContext
Get the static context used to compile this Metapath.- Returns:
- the static context
-
evaluateAs
Evaluate this Metapath expression without a specific focus. The required result type will be determined by theresultTypeargument.- 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 typeMetapathException- 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 providedfocusas the initial evaluation context. The required result type will be determined by theresultTypeargument.- Type Parameters:
T- the expected result type- Parameters:
focus- the focus of the expressionresultType- the type of result to produce- Returns:
- the converted result
- Throws:
TypeMetapathException- if the provided sequence is incompatible with the requested result typeMetapathException- 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 providedfocusas the initial evaluation context. The specific result type will be determined by theresultTypeargument.This variant allow for reuse of a provided
dynamicContext.- Type Parameters:
T- the expected result type- Parameters:
focus- the outer focus of the expressionresultType- the type of result to producedynamicContext- the dynamic context to use for evaluation- Returns:
- the converted result
- Throws:
TypeMetapathException- if the provided sequence is incompatible with the requested result typeMetapathException- if an error occurred during evaluation- See Also:
-
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
Evaluate this Metapath expression using the providedfocusas 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 providedfocusas 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 expressiondynamicContext- 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
-