-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new dynamic context with a default static context.DynamicContext(StaticContext staticContext) Construct a new Metapath dynamic context using the provided static context. -
Method Summary
Modifier and TypeMethodDescriptionbindVariableValue(IEnhancedQName name, ISequence<?> boundValue) Bind the variablenameto the sequencevalue.voidcacheResult(CalledContext callingContext, ISequence<?> result) Cache a function call result for a that has the propertyIFunction.FunctionProperty.DETERMINISTIC.Used to disable the evaluation of predicate expressions during Metapath evaluation.Used to enable the evaluation of predicate expressions during Metapath evaluation.Provides a formatted stack trace.Get the mapping of loaded documents from the document URI to the document node.ISequence<?>getCachedResult(CalledContext callingContext) Get the cached function call result for evaluating a function that has the propertyIFunction.FunctionProperty.DETERMINISTIC.Get the Metapath evaluation configuration.Get the current date and time.Get the document loader assigned to this dynamic context.Return a copy of the current execution stack.Get the focus context for this dynamic context.Get the default time zone used for evaluation.Get the default time zone used for evaluation.Get the static context associated with this dynamic context.ISequence<?>Get the sequence value assigned to a let variable with the provided qualified name.lookupFunction(IEnhancedQName name, int arity) Get the function with the provided name and arity.voidpopExecutionStack(IExpression expression) Pop the expression that was under evaluation from the execution queue.voidpushExecutionStack(IExpression expression) Push the current expression under evaluation to the execution queue.voidsetDocumentLoader(IDocumentLoader documentLoader) Assign a document loader to this dynamic context.voidSet the implicit timezone to the provided value.voidsetImplicitTimeZone(ZoneId timezone) Set the implicit timezone to the provided value.Generate a new dynamic context that is a copy of this dynamic context.subContext(FocusContext focusContext) Generate a new dynamic context with the specified focus context.
-
Constructor Details
-
DynamicContext
public DynamicContext()Construct a new dynamic context with a default static context. -
DynamicContext
Construct a new Metapath dynamic context using the provided static context.- Parameters:
staticContext- the Metapath static context
-
-
Method Details
-
subContext
Generate a new dynamic context that is a copy of this dynamic context.This method can be used to create a new sub-context where changes can be made without affecting this context. This is useful for setting information that is only used in a limited evaluation sub-scope, such as for handling variable assignment.
The focus context from this context is preserved in the new sub-context, allowing nested expressions to access the enclosing focus (e.g., for
position()andlast()calls within variable binding scopes).- Returns:
- a new dynamic context
-
subContext
Generate a new dynamic context with the specified focus context.This method is used by predicate expressions to establish a new focus for evaluating predicates. The focus context provides the information needed by
fn:position()andfn:last().- Parameters:
focusContext- the focus context for the new sub-context- Returns:
- a new dynamic context with the specified focus context
-
getFocusContext
Get the focus context for this dynamic context.The focus context contains the context item, position, and size as defined in the XPath 3.1 evaluation context.
- Returns:
- the focus context, or
nullif no focus context is established
-
getStaticContext
Get the static context associated with this dynamic context.- Returns:
- the associated static context
-
getImplicitTimeZone
Get the default time zone used for evaluation.- Returns:
- the time zone identifier object
-
getImplicitTimeZoneAsDayTimeDuration
Get the default time zone used for evaluation.- Returns:
- the time zone identifier object
-
setImplicitTimeZone
Set the implicit timezone to the provided value.Note: This value should only be adjusted when the context is first created. Once the context is used, this value is expected to be stable.
- Parameters:
timezone- the timezone to use
-
setImplicitTimeZone
Set the implicit timezone to the provided value.Note: This value should only be adjusted when the context is first created. Once the context is used, this value is expected to be stable.
- Parameters:
offset- the offset which must be >= -PT14H and <= PT13H- Throws:
DateTimeFunctionException- with the codeDateTimeFunctionException.INVALID_TIME_ZONE_VALUE_ERRORif the offset is < -PT14H or > PT14H
-
getCurrentDateTime
Get the current date and time.- Returns:
- the current date and time
-
getAvailableDocuments
Get the mapping of loaded documents from the document URI to the document node.- Returns:
- the map of document URIs to document nodes
-
getDocumentLoader
Get the document loader assigned to this dynamic context.- Returns:
- the loader
- Throws:
ContextAbsentDynamicMetapathException- if a document loader is not configured for this dynamic context
-
setDocumentLoader
Assign a document loader to this dynamic context.- Parameters:
documentLoader- the document loader to assign
-
getCachedResult
Get the cached function call result for evaluating a function that has the propertyIFunction.FunctionProperty.DETERMINISTIC.- Parameters:
callingContext- the function calling context information that distinguishes the call from any other call- Returns:
- the cached result sequence for the function call
-
cacheResult
Cache a function call result for a that has the propertyIFunction.FunctionProperty.DETERMINISTIC.- Parameters:
callingContext- the calling context information that distinguishes the call from any other callresult- the function call result
-
disablePredicateEvaluation
Used to disable the evaluation of predicate expressions during Metapath evaluation.This can be useful for determining the potential targets identified by a Metapath expression as a partial evaluation, without evaluating that these targets match the predicate.
- Returns:
- this dynamic context
-
enablePredicateEvaluation
Used to enable the evaluation of predicate expressions during Metapath evaluation.This is the default behavior if unchanged.
- Returns:
- this dynamic context
-
getConfiguration
Get the Metapath evaluation configuration.- Returns:
- the configuration
-
getVariableValue
Get the sequence value assigned to a let variable with the provided qualified name.- Parameters:
name- the variable qualified name- Returns:
- the non-null variable value
- Throws:
DynamicMetapathException- of the variable has not been assigned or if the variable value isnull
-
lookupFunction
Get the function with the provided name and arity.- Parameters:
name- the requested function's qualified namearity- the number of arguments in the requested function- Returns:
- the function
- Throws:
StaticMetapathException- with the codeStaticMetapathException.NO_FUNCTION_MATCHif a matching function was not found
-
bindVariableValue
@NonNull public DynamicContext bindVariableValue(@NonNull IEnhancedQName name, @NonNull ISequence<?> boundValue) Bind the variablenameto the sequencevalue.- Parameters:
name- the name of the variable to bindboundValue- the value to bind to the variable- Returns:
- this dynamic context
-
pushExecutionStack
Push the current expression under evaluation to the execution queue.- Parameters:
expression- the expression to push
-
popExecutionStack
Pop the expression that was under evaluation from the execution queue.- Parameters:
expression- the expected expression to be popped
-
getExecutionStack
Return a copy of the current execution stack.- Returns:
- the execution stack
-
formatExecutionStackTrace
Provides a formatted stack trace.- Returns:
- the formatted stack trace
-