Package org.hl7.fhir.dstu2.utils
Class FHIRPathEngine
- java.lang.Object
-
- org.hl7.fhir.dstu2.utils.FHIRPathEngine
-
public class FHIRPathEngine extends Object
- Author:
- Grahame Grieve
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classFHIRPathEngine.ElementDefinitionMatchstatic interfaceFHIRPathEngine.IEvaluationContext
-
Constructor Summary
Constructors Constructor Description FHIRPathEngine(IWorkerContext worker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpressionNode.TypeDetailscheck(Object appContext, String resourceType, String context, String expr)ExpressionNode.TypeDetailscheck(Object appContext, String resourceType, String context, ExpressionNode expr)check that paths referred to in the ExpressionNode are valid xPathStartsWithValueRef is a hack work around for the fact that FHIR Path sometimes needs a different starting point than the xpath returns a list of the possible types that might be returned by executing the ExpressionNode against a particular contextbooleanconvertToBoolean(List<Base> items)worker routine for converting a set of objects to a boolean representation (for invariants)StringconvertToString(List<Base> items)worker routine for converting a set of objects to a string representationList<Base>evaluate(Object appContext, Base resource, Base base, ExpressionNode ExpressionNode)evaluate a path and return the matching elementsList<Base>evaluate(Object appContext, Resource resource, Base base, String path)evaluate a path and return the matching elementsList<Base>evaluate(Object appContext, Resource resource, Base base, ExpressionNode ExpressionNode)evaluate a path and return the matching elementsList<Base>evaluate(Base base, String path)evaluate a path and return the matching elementsList<Base>evaluate(Base base, ExpressionNode ExpressionNode)evaluate a path and return the matching elementsbooleanevaluateToBoolean(Base resource, Base base, ExpressionNode node)evaluate a path and return true or false (e.g.booleanevaluateToBoolean(Resource resource, Base base, String path)evaluate a path and return true or false (e.g.booleanevaluateToBoolean(Resource resource, Base base, ExpressionNode node)evaluate a path and return true or false (e.g.StringevaluateToString(Base base, String path)evaluate a path and a string containing the outcome (for display)StringforLog()protected voidgetChildrenByName(Base item, String name, List<Base> result)Given an item, return all the children that conform to the pattern described in name Possible patterns: - a simple name (which may be the base of a name with [] e.g.FHIRPathEngine.IEvaluationContextgetConstantResolver()booleanhasLog()ExpressionNodeparse(String path)Parse a path for later use using executeExpressionNodeparse(FHIRLexer lexer)Parse a path that is part of some other syntaxvoidsetConstantResolver(FHIRPathEngine.IEvaluationContext constantResolver)StringtakeLog()
-
-
-
Constructor Detail
-
FHIRPathEngine
public FHIRPathEngine(IWorkerContext worker)
- Parameters:
worker- - used when validating paths (@check), and used doing value set membership when executing tests (once that's defined)
-
-
Method Detail
-
getConstantResolver
public FHIRPathEngine.IEvaluationContext getConstantResolver()
-
setConstantResolver
public void setConstantResolver(FHIRPathEngine.IEvaluationContext constantResolver)
-
getChildrenByName
protected void getChildrenByName(Base item, String name, List<Base> result)
Given an item, return all the children that conform to the pattern described in name Possible patterns: - a simple name (which may be the base of a name with [] e.g. value[x]) - a name with a type replacement e.g. valueCodeableConcept - * which means all children - ** which means all descendants- Parameters:
item-name-result-
-
parse
public ExpressionNode parse(String path) throws FHIRLexer.FHIRLexerException
Parse a path for later use using execute- Parameters:
path-- Returns:
- Throws:
org.hl7.fhir.exceptions.PathEngineExceptionExceptionFHIRLexer.FHIRLexerException
-
parse
public ExpressionNode parse(FHIRLexer lexer) throws FHIRLexer.FHIRLexerException
Parse a path that is part of some other syntax- Returns:
- Throws:
org.hl7.fhir.exceptions.PathEngineExceptionExceptionFHIRLexer.FHIRLexerException
-
check
public ExpressionNode.TypeDetails check(Object appContext, String resourceType, String context, ExpressionNode expr) throws FHIRLexer.FHIRLexerException, org.hl7.fhir.exceptions.PathEngineException, org.hl7.fhir.exceptions.DefinitionException
check that paths referred to in the ExpressionNode are valid xPathStartsWithValueRef is a hack work around for the fact that FHIR Path sometimes needs a different starting point than the xpath returns a list of the possible types that might be returned by executing the ExpressionNode against a particular context- Parameters:
context- - the logical type against which this path is applied- Throws:
org.hl7.fhir.exceptions.DefinitionExceptionorg.hl7.fhir.exceptions.PathEngineExceptionFHIRLexer.FHIRLexerException
-
check
public ExpressionNode.TypeDetails check(Object appContext, String resourceType, String context, String expr) throws FHIRLexer.FHIRLexerException, org.hl7.fhir.exceptions.PathEngineException, org.hl7.fhir.exceptions.DefinitionException
- Throws:
FHIRLexer.FHIRLexerExceptionorg.hl7.fhir.exceptions.PathEngineExceptionorg.hl7.fhir.exceptions.DefinitionException
-
evaluate
public List<Base> evaluate(Base base, ExpressionNode ExpressionNode) throws org.hl7.fhir.exceptions.PathEngineException
evaluate a path and return the matching elements- Parameters:
base- - the object against which the path is being evaluatedExpressionNode- - the parsed ExpressionNode statement to use- Returns:
- Throws:
org.hl7.fhir.exceptions.PathEngineException
-
evaluate
public List<Base> evaluate(Base base, String path) throws FHIRLexer.FHIRLexerException, org.hl7.fhir.exceptions.PathEngineException
evaluate a path and return the matching elements- Parameters:
base- - the object against which the path is being evaluatedpath- - the FHIR Path statement to use- Returns:
- Throws:
FHIRLexer.FHIRLexerExceptionorg.hl7.fhir.exceptions.PathEngineException
-
evaluate
public List<Base> evaluate(Object appContext, Resource resource, Base base, ExpressionNode ExpressionNode) throws org.hl7.fhir.exceptions.PathEngineException
evaluate a path and return the matching elements- Parameters:
base- - the object against which the path is being evaluatedExpressionNode- - the parsed ExpressionNode statement to use- Returns:
- Throws:
org.hl7.fhir.exceptions.PathEngineException
-
evaluate
public List<Base> evaluate(Object appContext, Base resource, Base base, ExpressionNode ExpressionNode) throws org.hl7.fhir.exceptions.PathEngineException
evaluate a path and return the matching elements- Parameters:
base- - the object against which the path is being evaluatedExpressionNode- - the parsed ExpressionNode statement to use- Returns:
- Throws:
org.hl7.fhir.exceptions.PathEngineException
-
evaluate
public List<Base> evaluate(Object appContext, Resource resource, Base base, String path) throws org.hl7.fhir.exceptions.PathEngineException, FHIRLexer.FHIRLexerException
evaluate a path and return the matching elements- Parameters:
base- - the object against which the path is being evaluatedpath- - the FHIR Path statement to use- Returns:
- Throws:
org.hl7.fhir.exceptions.PathEngineExceptionFHIRLexer.FHIRLexerException
-
evaluateToBoolean
public boolean evaluateToBoolean(Resource resource, Base base, String path) throws org.hl7.fhir.exceptions.PathEngineException, FHIRLexer.FHIRLexerException
evaluate a path and return true or false (e.g. for an invariant)- Parameters:
base- - the object against which the path is being evaluatedpath- - the FHIR Path statement to use- Returns:
- Throws:
FHIRLexer.FHIRLexerExceptionorg.hl7.fhir.exceptions.PathEngineException
-
evaluateToBoolean
public boolean evaluateToBoolean(Resource resource, Base base, ExpressionNode node) throws org.hl7.fhir.exceptions.PathEngineException
evaluate a path and return true or false (e.g. for an invariant)- Parameters:
base- - the object against which the path is being evaluated- Returns:
- Throws:
org.hl7.fhir.exceptions.PathEngineException
-
evaluateToBoolean
public boolean evaluateToBoolean(Base resource, Base base, ExpressionNode node) throws org.hl7.fhir.exceptions.PathEngineException
evaluate a path and return true or false (e.g. for an invariant)- Parameters:
base- - the object against which the path is being evaluated- Returns:
- Throws:
org.hl7.fhir.exceptions.PathEngineException
-
evaluateToString
public String evaluateToString(Base base, String path) throws FHIRLexer.FHIRLexerException, org.hl7.fhir.exceptions.PathEngineException
evaluate a path and a string containing the outcome (for display)- Parameters:
base- - the object against which the path is being evaluatedpath- - the FHIR Path statement to use- Returns:
- Throws:
FHIRLexer.FHIRLexerExceptionorg.hl7.fhir.exceptions.PathEngineException
-
convertToString
public String convertToString(List<Base> items)
worker routine for converting a set of objects to a string representation- Parameters:
items- - result from @evaluate- Returns:
-
convertToBoolean
public boolean convertToBoolean(List<Base> items)
worker routine for converting a set of objects to a boolean representation (for invariants)- Parameters:
items- - result from @evaluate- Returns:
-
hasLog
public boolean hasLog()
-
-