Package com.ibm.fhir.path.evaluator
Class FHIRPathEvaluator.EvaluationContext
- java.lang.Object
-
- com.ibm.fhir.path.evaluator.FHIRPathEvaluator.EvaluationContext
-
- Enclosing class:
- FHIRPathEvaluator
public static class FHIRPathEvaluator.EvaluationContext extends java.lang.Object
A context object used to pass information to/from the FHIRPath evaluation engine
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_RESOLVE_RELATIVE_REFERENCES
-
Constructor Summary
Constructors Constructor Description EvaluationContext()
Create an empty evaluation context, evaluating stand-alone expressionsEvaluationContext(Resource resource)
Create an evaluation context where the passed resource is the context root.EvaluationContext(Element element)
Create an evaluation context where the passed element is the context root.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEvaluationListener(FHIRPathEvaluator.EvaluationListener listener)
Add an evaluation listener to this context.void
cacheFunctionResult(java.lang.String functionName, java.util.Collection<FHIRPathNode> context, java.util.List<java.util.Collection<FHIRPathNode>> arguments, java.util.Collection<FHIRPathNode> result)
Cache the function result for the given function name, context, and argumentsvoid
clearIssues()
Clear the list of supplemental issues that were generated during evaluationjava.util.Collection<FHIRPathNode>
getCachedFunctionResult(java.lang.String functionName, java.util.Collection<FHIRPathNode> context, java.util.List<java.util.Collection<FHIRPathNode>> arguments)
Get the cached function result for the given function name, context, and arguments.Constraint
getConstraint()
Get the constraint currently under evaluationjava.util.List<FHIRPathEvaluator.EvaluationListener>
getEvaluationListeners()
Get the list of evaluation listeners for this context.java.util.Collection<FHIRPathNode>
getExternalConstant(java.lang.String name)
Get an external constant with the given namejava.util.List<OperationOutcome.Issue>
getIssues()
Get the list of supplemental issues that were generated during evaluationFHIRPathTree
getTree()
Get the FHIRPath tree associated with this EvaluationContextboolean
hasCachedFunctionResult(java.lang.String functionName, java.util.Collection<FHIRPathNode> context, java.util.List<java.util.Collection<FHIRPathNode>> arguments)
Indicates whether a function result has been cached for the given function name, context, and arguments.boolean
hasConstraint()
Indicates whether this evaluation context has an associated constraintboolean
hasExternalConstant(java.lang.String name)
Indicates whether this EvaluationContext has an external constant with the given nameboolean
hasIssues()
Indicates whether this evaluation context has supplemental issues that were generated during evaluationboolean
removeEvaluationListener(FHIRPathEvaluator.EvaluationListener listener)
Remove an evaluation listener from this context.boolean
resolveRelativeReferences()
Indicates whether the evaluator using this evaluation context should resolve relative references (if possible)void
setConstraint(Constraint constraint)
Set the constraint currently under evaluationvoid
setExternalConstant(java.lang.String name, FHIRPathNode node)
Set an external constant using a name and FHIRPath nodevoid
setExternalConstant(java.lang.String name, java.util.Collection<FHIRPathNode> nodes)
Set an external constant using a name and a collection of FHIRPath nodevoid
setResolveRelativeReferences(boolean resolveRelativeReferences)
Set the resolve relative references indicatorvoid
unsetConstraint()
Unset the constraint currently under evaluationvoid
unsetExternalConstant(java.lang.String name)
Unset an external constant with the given name
-
-
-
Field Detail
-
DEFAULT_RESOLVE_RELATIVE_REFERENCES
public static final boolean DEFAULT_RESOLVE_RELATIVE_REFERENCES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EvaluationContext
public EvaluationContext()
Create an empty evaluation context, evaluating stand-alone expressions
-
EvaluationContext
public EvaluationContext(Resource resource)
Create an evaluation context where the passed resource is the context root. Sets %resource and %rootResource external constants to the passed resource, but these can be overridden.- Parameters:
resource
- the resource
-
EvaluationContext
public EvaluationContext(Element element)
Create an evaluation context where the passed element is the context root.- Parameters:
element
- the element
-
-
Method Detail
-
getTree
public FHIRPathTree getTree()
Get the FHIRPath tree associated with this EvaluationContext- Returns:
- the FHIRPath tree associated with this EvaluationContext
-
setExternalConstant
public void setExternalConstant(java.lang.String name, FHIRPathNode node)
Set an external constant using a name and FHIRPath node- Parameters:
name
- the namenode
- the FHIRPath node
-
setExternalConstant
public void setExternalConstant(java.lang.String name, java.util.Collection<FHIRPathNode> nodes)
Set an external constant using a name and a collection of FHIRPath node- Parameters:
name
- the namenodes
- the collection of FHIRPath nodes
-
unsetExternalConstant
public void unsetExternalConstant(java.lang.String name)
Unset an external constant with the given name- Parameters:
name
- the name
-
getExternalConstant
public java.util.Collection<FHIRPathNode> getExternalConstant(java.lang.String name)
Get an external constant with the given name- Parameters:
name
- the name- Returns:
- the external constant as a collection of FHIRPath nodes or an empty collection
-
hasExternalConstant
public boolean hasExternalConstant(java.lang.String name)
Indicates whether this EvaluationContext has an external constant with the given name- Parameters:
name
- the name- Returns:
- true if this EvaluationContext has an external constant with the given name, otherwise false
-
getIssues
public java.util.List<OperationOutcome.Issue> getIssues()
Get the list of supplemental issues that were generated during evaluationSupplemental issues are used to convey additional information about the evaluation to the client
- Returns:
- the list of supplemental issues that were generated during evaluation
-
clearIssues
public void clearIssues()
Clear the list of supplemental issues that were generated during evaluation
-
hasIssues
public boolean hasIssues()
Indicates whether this evaluation context has supplemental issues that were generated during evaluation- Returns:
- true if this evaluation context has supplemental issues that were generated during evaluation, otherwise false
-
setConstraint
public void setConstraint(Constraint constraint)
Set the constraint currently under evaluationIf a
Constraint
is the source of the expression under evaluation, then this method allows the client to make it available to the evaluation engine to access additional information about the constraint (e.g. id, level, location, description, etc.)- Parameters:
constraint
- the constraint currently under evaluation
-
unsetConstraint
public void unsetConstraint()
Unset the constraint currently under evaluation
-
getConstraint
public Constraint getConstraint()
Get the constraint currently under evaluation- Returns:
- the constraint currently under evaluation if exists, otherwise null
-
hasConstraint
public boolean hasConstraint()
Indicates whether this evaluation context has an associated constraint- Returns:
- true if this evaluation context has an associated constraint, otherwise false
-
setResolveRelativeReferences
public void setResolveRelativeReferences(boolean resolveRelativeReferences)
Set the resolve relative references indicator- Parameters:
resolveRelativeReferences
- the resolve relative references indicator
-
resolveRelativeReferences
public boolean resolveRelativeReferences()
Indicates whether the evaluator using this evaluation context should resolve relative references (if possible)- Returns:
- true if the evaluator using this evaluation context should resolve relative references (if possible), otherwise false
-
getCachedFunctionResult
public java.util.Collection<FHIRPathNode> getCachedFunctionResult(java.lang.String functionName, java.util.Collection<FHIRPathNode> context, java.util.List<java.util.Collection<FHIRPathNode>> arguments)
Get the cached function result for the given function name, context, and arguments.- Parameters:
functionName
- the function namecontext
- the contextarguments
- the arguments- Returns:
- the cached function result as a collection of FHIRPath nodes or an empty collection
-
cacheFunctionResult
public void cacheFunctionResult(java.lang.String functionName, java.util.Collection<FHIRPathNode> context, java.util.List<java.util.Collection<FHIRPathNode>> arguments, java.util.Collection<FHIRPathNode> result)
Cache the function result for the given function name, context, and arguments- Parameters:
functionName
- the function namecontext
- the contextarguments
- the argumentsresult
- the function result
-
hasCachedFunctionResult
public boolean hasCachedFunctionResult(java.lang.String functionName, java.util.Collection<FHIRPathNode> context, java.util.List<java.util.Collection<FHIRPathNode>> arguments)
Indicates whether a function result has been cached for the given function name, context, and arguments.- Parameters:
functionName
- the function namecontext
- the contextarguments
- the arguments- Returns:
- true if the function result has been cached, otherwise false
-
addEvaluationListener
public void addEvaluationListener(FHIRPathEvaluator.EvaluationListener listener)
Add an evaluation listener to this context.- Parameters:
listener
- the evaluation listener
-
removeEvaluationListener
public boolean removeEvaluationListener(FHIRPathEvaluator.EvaluationListener listener)
Remove an evaluation listener from this context.- Parameters:
listener
- the evaluation listener- Returns:
- true if the evaluation listener being removed was present in the list of evaluation listeners for this context, otherwise false
-
getEvaluationListeners
public java.util.List<FHIRPathEvaluator.EvaluationListener> getEvaluationListeners()
Get the list of evaluation listeners for this context.- Returns:
- the list of evaluation listeners
-
-