|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.inria.ns.reflex.xml.xpath.Expression
public abstract class Expression
An expression is a string that is interpreted as an attribute value template (AVT) in XSLT.
Each expression surrounded by curly braces ({}
) stands for
an XPath expression. Properties from the data set can be used as XPath variables
references , like $varName
The static method
parseValueTemplate
will compile such a string in an Expression
, that will be one
of the following sub-types :
StringExpression
, that only
wraps a String
when the expression doesn't contain
curly braces,XPathExpression
, when the
expression is surrounded by curly braces (
{expression}
),MixedExpression
, when the
expression is a mixed-string of alternatively simple strings and
XPath expression surrounded by curly braces.
At runtime, the expression is computed with the dataset, thanks to
the compute
method. The result may be :
String
,Object
.
To escape curly braces when parsing an expression, simply use "
{{
" and "}}
" to get respectively "
{
" and "}
".
Notice that the same result can be obtained without using escaping sequence
thanks to XPath expression "{'{'}
" and "{'}'}
".
StringExpression
,
XPathExpression
,
MixedExpression
,
DataSet
Constructor Summary | |
---|---|
Expression(String expression,
XFactory factory)
Wraps a string in an Expression object. |
Method Summary | |
---|---|
abstract Object |
compute(XPathContext context)
Provides a runtime computation of the compiled expression using the given dataset. |
Object |
compute(XPathVariableResolver variableResolver)
Provides a runtime computation of the compiled expression using the given dataset. |
Object |
compute(XPathVariableResolver variableResolver,
Object contextNode)
Provides a runtime computation of the compiled expression using the given dataset. |
boolean |
equals(Object expression)
Indicates whether some other Expression is "equal to" this
one. |
String |
getExpression()
Returns the expression string used to compile the Expression . |
int |
hashCode()
Returns a hash code value for the Expression . |
static Expression |
parseValueTemplate(Element element,
String attributeName)
Parses an expression string from an element's attribute, as an attribute value template to a compiled Expression . |
static Expression |
parseValueTemplate(Element element,
String namespaceURI,
String localAttributeName)
Parses an expression string from an element's attribute, as an attribute value template to a compiled Expression . |
static Expression |
parseValueTemplate(Element element,
String namespaceURI,
String localAttributeName,
XFactory factory)
Parses an expression string from an element's attribute, as an attribute value template to a compiled Expression . |
static Expression |
parseValueTemplate(String expression,
Node node)
Parses an expression string as an attribute value template to a compiled Expression . |
static Expression |
parseValueTemplate(String expression,
Node node,
Map namespaceURIs)
Parses an expression string as an attribute value template to a compiled Expression . |
static Expression |
parseValueTemplate(String expression,
Node node,
Map namespaceURIs,
XFactory factory)
Parses an expression string as an attribute value template to a compiled Expression . |
String |
toString()
Returns the expression string used to compile the Expression . |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Expression(String expression, XFactory factory)
Expression
object.
expression
- The string to wrap.factory
- The factory that parses XPath expressions.Method Detail |
---|
public Object compute(XPathVariableResolver variableResolver) throws XPathException
variableResolver
- The resolver used to retrieve the variables used for the
computation.
XPathException
- When the expression rises an XPath error at runtime.public Object compute(XPathVariableResolver variableResolver, Object contextNode) throws XPathException
variableResolver
- The resolver used to retrieve the variables used for the
computation.
XPathException
- When the expression rises an XPath error at runtime.public abstract Object compute(XPathContext context) throws XPathException
variableResolver
- The resolver used to retrieve the variables used for the
computation.
XPathException
- When the expression rises an XPath error at runtime.public String getExpression()
Expression
.
Expression
.public int hashCode()
Expression
.
hashCode
in class Object
Expression
.public boolean equals(Object expression)
Expression
is "equal to" this
one.
equals
in class Object
expression
- The expression to compare.
true
if this Expression
is the same
as the expression argument; false otherwise.public String toString()
Expression
.
toString
in class Object
Expression
.public static Expression parseValueTemplate(Element element, String attributeName) throws XPathException
Expression
.
element
- The element to which belongs the attribute. Used for namespace
prefix resolution when performing XPath expressions.attributeName
- The name of the attribute that contains the expression
to parse.
XPathException
- If the given expression is not a valid XPath expression.public static Expression parseValueTemplate(Element element, String namespaceURI, String localAttributeName) throws XPathException
Expression
.
element
- The element to which belongs the attribute. Used for namespace
prefix resolution when performing XPath expressions.namespaceURI
- The namespace URI of the attribute that contains the
expression to parse.localAttributeName
- The local name of the attribute that contains the
expression to parse.
XPathException
- If the given expression is not a valid XPath expression.public static Expression parseValueTemplate(Element element, String namespaceURI, String localAttributeName, XFactory factory) throws XPathException
Expression
.
element
- The element to which belongs the attribute. Used for namespace
prefix resolution when performing XPath expressions.namespaceURI
- The namespace URI of the attribute that contains the
expression to parse.localAttributeName
- The local name of the attribute that contains the
expression to parse.
XPathException
- If the given expression is not a valid XPath expression.public static Expression parseValueTemplate(String expression, Node node) throws XPathException
Expression
.
expression
- The expression to parse.node
- The node used for namespace prefix resolution when performing
XPath expressions.
XPathException
- If the given expression is not a valid XPath expression.public static Expression parseValueTemplate(String expression, Node node, Map namespaceURIs) throws XPathException
Expression
.
expression
- The expression to parse.node
- The node used for namespace prefix resolution when performing
XPath expressions.namespaceURIs
- A set of couple of { prefix , namespace URI } used for prefix
resolution.
XPathException
- If the given expression is not a valid XPath expression.public static Expression parseValueTemplate(String expression, Node node, Map namespaceURIs, XFactory factory) throws XPathException
Expression
. XPath expressions are parsed with
the default engine.
expression
- The expression to parse.node
- The node used for namespace prefix resolution when performing
XPath expressions.namespaceURIs
- A set of couple of { prefix , namespace URI } used for prefix
resolution.factory
- The factory to use for parsing XPath expressions.
XPathException
- If the given expression is not a valid XPath expression.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |