public class XPathEvaluator extends Object implements Evaluator, Serializable
An Evaluator
implementation for XPath environments.
Does not support the <script> module, throws
UnsupportedOperationException
if attempted.
Modifier and Type | Class and Description |
---|---|
static class |
XPathEvaluator.XPathEvaluatorProvider |
Evaluator.AssignType
Modifier and Type | Field and Description |
---|---|
static String |
SUPPORTED_DATA_MODEL |
DEFAULT_DATA_MODEL, ECMASCRIPT_DATA_MODEL, NULL_DATA_MODEL, XPATH_DATA_MODEL
Constructor and Description |
---|
XPathEvaluator()
No argument constructor.
|
XPathEvaluator(org.apache.commons.jxpath.Functions functions)
Constructor supporting user-defined JXPath
Functions . |
Modifier and Type | Method and Description |
---|---|
protected void |
assign(Context ctx,
Node node,
String nodePath,
Object data,
Evaluator.AssignType type,
String attr) |
void |
assign(Context ctx,
Object location,
Object data,
Evaluator.AssignType type,
String attr)
Assigns data to a location
|
Object |
eval(Context ctx,
String expr)
Evaluate an expression returning a data value
|
void |
evalAssign(Context ctx,
String location,
Object data,
Evaluator.AssignType type,
String attr)
Assigns data to a location
|
Boolean |
evalCond(Context ctx,
String expr)
Evaluate a condition.
|
Object |
evalLocation(Context ctx,
String expr)
Evaluate a location that returns a data assignable reference or list of references.
|
Object |
evalScript(Context ctx,
String script)
Evaluate a script.
|
protected org.apache.commons.jxpath.JXPathContext |
getContext(Context ctx) |
String |
getSupportedDatamodel()
Get the datamodel type supported by this Evaluator
|
boolean |
isXPathLocation(Context ctx,
Object data)
Determine if an
Evaluator.evalLocation(Context, String) returned result represents an XPath location |
Context |
newContext(Context parent)
Create a new child context.
|
public static final String SUPPORTED_DATA_MODEL
public XPathEvaluator()
public XPathEvaluator(org.apache.commons.jxpath.Functions functions)
Functions
.functions
- The user-defined JXPath functions to use.public String getSupportedDatamodel()
Evaluator
getSupportedDatamodel
in interface Evaluator
public Object eval(Context ctx, String expr) throws SCXMLExpressionException
Evaluator
eval
in interface Evaluator
ctx
- variable contextexpr
- expressionSCXMLExpressionException
- A malformed expression exceptionEvaluator.eval(Context, String)
public Boolean evalCond(Context ctx, String expr) throws SCXMLExpressionException
Evaluator
evalCond
in interface Evaluator
ctx
- variable contextexpr
- expressionSCXMLExpressionException
- A malformed expression exceptionEvaluator.evalCond(Context, String)
public Object evalLocation(Context ctx, String expr) throws SCXMLExpressionException
Evaluator
evalLocation
in interface Evaluator
ctx
- variable contextexpr
- expressionSCXMLExpressionException
- A malformed expression exceptionEvaluator.evalLocation(Context, String)
public void evalAssign(Context ctx, String location, Object data, Evaluator.AssignType type, String attr) throws SCXMLExpressionException
Evaluator
evalAssign
in interface Evaluator
ctx
- variable contextlocation
- location expressiondata
- the data to assign.type
- the type of assignment to perform, null assumes Evaluator.AssignType.REPLACE_CHILDREN
attr
- the name of the attribute to add when using type Evaluator.AssignType.ADD_ATTRIBUTE
SCXMLExpressionException
- A malformed expression exceptionEvaluator.evalAssign(Context, String, Object, AssignType, String)
public Object evalScript(Context ctx, String script) throws SCXMLExpressionException
Evaluator
evalScript
in interface Evaluator
ctx
- variable contextscript
- The scriptSCXMLExpressionException
- A malformed scriptEvaluator.evalScript(Context, String)
public Context newContext(Context parent)
Evaluator
newContext
in interface Evaluator
parent
- parent contextEvaluator.newContext(Context)
public boolean isXPathLocation(Context ctx, Object data)
Evaluator.evalLocation(Context, String)
returned result represents an XPath locationctx
- variable contextdata
- result data from Evaluator.evalLocation(Context, String)
public void assign(Context ctx, Object location, Object data, Evaluator.AssignType type, String attr) throws SCXMLExpressionException
ctx
- variable contextlocation
- location expressiondata
- the data to assign.type
- the type of assignment to perform, null assumes Evaluator.AssignType#REPLACE_CHILDREN
attr
- the name of the attribute to add when using type Evaluator.AssignType#ADD_ATTRIBUTE
SCXMLExpressionException
- A malformed expression exceptionEvaluator.evalAssign(Context, String, Object, Evaluator.AssignType, String)
protected void assign(Context ctx, Node node, String nodePath, Object data, Evaluator.AssignType type, String attr) throws SCXMLExpressionException
SCXMLExpressionException
protected org.apache.commons.jxpath.JXPathContext getContext(Context ctx) throws SCXMLExpressionException
SCXMLExpressionException
Copyright © 2005–2015 The Apache Software Foundation. All rights reserved.