|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectfi.hut.tml.xsmiles.mlfc.xforms.xpath.jaxen.BaseXPathEx
Base functionality for all concrete, implementation-specific XPaths.
This class provides generic functionalty for further-defined implementation-specific XPaths.
If you want to adapt the Jaxen engine so that it can traverse your own
object model then this is a good base class to derive from.
Typically you only really need to provide your own
Navigator implementation.
XPath for dom4j,
XPath for JDOM,
XPath for W3C DOM,
XPath for Electric XML,
Serialized Form| Field Summary | |
protected DefaultXPathFactoryEx |
fact
|
protected LookupCallback |
referredNodes
|
| Constructor Summary | |
BaseXPathEx(java.lang.String xpathExpr,
LookupCallback c)
Construct given an XPath expression string. |
|
BaseXPathEx(java.lang.String xpathExpr,
org.jaxen.Navigator navigator)
Construct given an XPath expression string. |
|
| Method Summary | |
void |
addNamespace(java.lang.String prefix,
java.lang.String uri)
Add a namespace prefix-to-URI mapping for this XPath expression. |
boolean |
booleanValueOf(java.lang.Object node)
Retrieve a boolean-value interpretation of this XPath expression when evaluated against a given context. |
protected org.jaxen.FunctionContext |
createFunctionContext()
Create a default FunctionContext. |
protected org.jaxen.NamespaceContext |
createNamespaceContext()
Create a default NamespaceContext. |
protected org.jaxen.VariableContext |
createVariableContext()
Create a default VariableContext. |
java.lang.String |
debug()
Returns the string version of this xpath. |
java.lang.Object |
evaluate(java.lang.Object node)
Evaluate this XPath against a given context. |
protected org.jaxen.Context |
getContext(java.lang.Object node)
Create a Context wrapper for the provided
implementation-specific object. |
protected org.jaxen.ContextSupport |
getContextSupport()
Retrieve the ContextSupport aggregation of
NamespaceContext, FunctionContext,
VariableContext, and Navigator. |
org.jaxen.FunctionContext |
getFunctionContext()
Retrieve the FunctionContext used by this XPath
expression. |
org.jaxen.NamespaceContext |
getNamespaceContext()
Retrieve the NamespaceContext used by this XPath
expression. |
org.jaxen.Navigator |
getNavigator()
Retrieve the XML object-model-specific Navigator
for us in evaluating this XPath expression. |
org.jaxen.expr.Expr |
getRootExpr()
Retrieve the root expression of the internal compiled form of this XPath expression. |
org.jaxen.VariableContext |
getVariableContext()
Retrieve the VariableContext used by this XPath
expression. |
java.lang.Number |
numberValueOf(java.lang.Object node)
Retrieve a number-value interpretation of this XPath expression when evaluated against a given context. |
java.util.List |
selectNodes(java.lang.Object node)
Select all nodes that are selectable by this XPath expression. |
protected java.util.List |
selectNodesForContext(org.jaxen.Context context)
Select all nodes that are selectable by this XPath expression on the given Context object. |
java.lang.Object |
selectSingleNode(java.lang.Object node)
Select only the first node that is selectable by this XPath expression. |
protected java.lang.Object |
selectSingleNodeForContext(org.jaxen.Context context)
Select only the first node that is selectable by this XPath expression. |
void |
setFunctionContext(org.jaxen.FunctionContext functionContext)
Set a FunctionContext for use with this XPath
expression. |
void |
setNamespaceContext(org.jaxen.NamespaceContext namespaceContext)
Set a NamespaceContext for use with this
XPath expression. |
void |
setReferredNodes(LookupCallback v)
|
void |
setVariableContext(org.jaxen.VariableContext variableContext)
Set a VariableContext for use with this XPath
expression. |
java.lang.String |
stringValueOf(java.lang.Object node)
|
java.lang.String |
toString()
Return the original expression text. |
java.lang.String |
valueOf(java.lang.Object node)
Deprecated. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected LookupCallback referredNodes
protected DefaultXPathFactoryEx fact
| Constructor Detail |
public BaseXPathEx(java.lang.String xpathExpr,
LookupCallback c)
throws org.jaxen.JaxenException
xpathExpr - The XPath expression.
org.jaxen.JaxenException - if there is a syntax error while
parsing the expression.
public BaseXPathEx(java.lang.String xpathExpr,
org.jaxen.Navigator navigator)
throws org.jaxen.JaxenException
xpathExpr - The XPath expression.navigator - the XML navigator to use
org.jaxen.JaxenException - if there is a syntax error while
parsing the expression.| Method Detail |
public void setReferredNodes(LookupCallback v)
public java.lang.Object evaluate(java.lang.Object node)
throws org.jaxen.JaxenException
The context of evaluation my be a document, an element, or a set of elements.
If the expression evaluates to a single primitive
(String, Number or Boolean) type, it is returned
directly. Otherwise, the returned value is a
List (a node-set, in the terms of the
specification) of values.
When using this method, one must be careful to
test the class of the returned objects, and of
each of the composite members if a List
is returned. If the returned members are XML entities,
they will be the actual Document,
Element or Attribute objects
as defined by the concrete XML object-model implementation,
directly from the context document. This does not
return copies of anything, but merely returns
references to entities within the source document.
evaluate in interface org.jaxen.XPathnode - The node, nodeset or Context object for evaluation. This value can be null.
org.jaxen.JaxenException
public java.util.List selectNodes(java.lang.Object node)
throws org.jaxen.JaxenException
NOTE: In most cases, nodes will be returned
in document-order, as defined by the XML Canonicalization
specification. The exception occurs when using XPath
expressions involving the union operator
(denoted with the pipe '|' character).
selectNodes in interface org.jaxen.XPathnode - The node, nodeset or Context object for evaluation. This value can be null.
node-set of all items selected
by this XPath expression.
org.jaxen.JaxenExceptionselectSingleNode(java.lang.Object)
public java.lang.Object selectSingleNode(java.lang.Object node)
throws org.jaxen.JaxenException
union operator
(denoted with the pipe '|' character).
selectSingleNode in interface org.jaxen.XPathnode - The node, nodeset or Context object for evaluation. This value can be null.
node-set of all items selected
by this XPath expression.
org.jaxen.JaxenExceptionselectNodes(java.lang.Object)
public java.lang.String valueOf(java.lang.Object node)
throws org.jaxen.JaxenException
valueOf in interface org.jaxen.XPathorg.jaxen.JaxenException
public java.lang.String stringValueOf(java.lang.Object node)
throws org.jaxen.JaxenException
stringValueOf in interface org.jaxen.XPathorg.jaxen.JaxenException
public boolean booleanValueOf(java.lang.Object node)
throws org.jaxen.JaxenException
The boolean-value of the expression is determined per
the boolean(..) core function as defined
in the XPath specification. This means that an expression
that selects zero nodes will return false,
while an expression that selects one-or-more nodes will
return true.
booleanValueOf in interface org.jaxen.XPathnode - The node, nodeset or Context object for evaluation. This value can be null.
org.jaxen.JaxenException
public java.lang.Number numberValueOf(java.lang.Object node)
throws org.jaxen.JaxenException
The number-value of the expression is determined per
the number(..) core function as defined
in the XPath specification. This means that if this
expression selects multiple nodes, the number-value
of the first node is returned.
numberValueOf in interface org.jaxen.XPathnode - The node, nodeset or Context object for evaluation. This value can be null.
org.jaxen.JaxenException
public void addNamespace(java.lang.String prefix,
java.lang.String uri)
throws org.jaxen.JaxenException
Namespace prefix-to-URI mappings in an XPath are independant of those used within any document. Only the mapping explicitly added to this XPath will be available for resolving the XPath expression.
This is a convenience method for adding mappings to the
default NamespaceContext in place for this XPath.
If you have installed a specific custom NamespaceContext,
then this method will throw a JaxenException.
addNamespace in interface org.jaxen.XPathprefix - The namespace prefix.uri - The namespace URI.
org.jaxen.JaxenException - If a NamespaceContext
used by this XPath has been explicitly installed.public void setNamespaceContext(org.jaxen.NamespaceContext namespaceContext)
NamespaceContext for use with this
XPath expression.
A NamespaceContext is responsible for translating
namespace prefixes within the expression into namespace URIs.
setNamespaceContext in interface org.jaxen.XPathnamespaceContext - The NamespaceContext to
install for this expression.NamespaceContext,
NamespaceContext.translateNamespacePrefixToUri(java.lang.String)public void setFunctionContext(org.jaxen.FunctionContext functionContext)
FunctionContext for use with this XPath
expression.
A FunctionContext is responsible for resolving
all function calls used within the expression.
setFunctionContext in interface org.jaxen.XPathfunctionContext - The FunctionContext to
install for this expression.FunctionContext,
FunctionContext.getFunction(java.lang.String, java.lang.String, java.lang.String)public void setVariableContext(org.jaxen.VariableContext variableContext)
VariableContext for use with this XPath
expression.
A VariableContext is responsible for resolving
all variables referenced within the expression.
setVariableContext in interface org.jaxen.XPathvariableContext - The VariableContext to
install for this expression.VariableContext,
VariableContext.getVariableValue(java.lang.String, java.lang.String, java.lang.String)public org.jaxen.NamespaceContext getNamespaceContext()
NamespaceContext used by this XPath
expression.
A FunctionContext is responsible for resolving
all function calls used within the expression.
If this XPath expression has not previously had a NamespaceContext
installed, a new default NamespaceContext will be created,
installed and returned.
getNamespaceContext in interface org.jaxen.XPathNamespaceContext used by this expression.NamespaceContextpublic org.jaxen.FunctionContext getFunctionContext()
FunctionContext used by this XPath
expression.
A FunctionContext is responsible for resolving
all function calls used within the expression.
If this XPath expression has not previously had a FunctionContext
installed, a new default FunctionContext will be created,
installed and returned.
getFunctionContext in interface org.jaxen.XPathFunctionContext used by this expression.FunctionContextpublic org.jaxen.VariableContext getVariableContext()
VariableContext used by this XPath
expression.
A VariableContext is responsible for resolving
all variables referenced within the expression.
If this XPath expression has not previously had a VariableContext
installed, a new default VariableContext will be created,
installed and returned.
getVariableContext in interface org.jaxen.XPathVariableContext used by this expression.VariableContextpublic org.jaxen.expr.Expr getRootExpr()
Internally, Jaxen maintains a form of Abstract Syntax Tree (AST) to represent the structure of the XPath expression. This is normally not required during normal consumer-grade usage of Jaxen. This method is provided for hard-core users who wish to manipulate or inspect a tree-based version of the expression.
public java.lang.String toString()
public java.lang.String debug()
toString()protected org.jaxen.Context getContext(java.lang.Object node)
Context wrapper for the provided
implementation-specific object.
node - The implementation-specific object
to be used as the context.
Context wrapper around the object.protected org.jaxen.ContextSupport getContextSupport()
ContextSupport aggregation of
NamespaceContext, FunctionContext,
VariableContext, and Navigator.
ContextSupport for this
XPath expression.public org.jaxen.Navigator getNavigator()
Navigator
for us in evaluating this XPath expression.
getNavigator in interface org.jaxen.XPathNavigator.protected org.jaxen.FunctionContext createFunctionContext()
FunctionContext.
FunctionContext.protected org.jaxen.NamespaceContext createNamespaceContext()
NamespaceContext.
NamespaceContext instance.protected org.jaxen.VariableContext createVariableContext()
VariableContext.
VariableContext instance.
protected java.util.List selectNodesForContext(org.jaxen.Context context)
throws org.jaxen.JaxenException
NOTE: In most cases, nodes will be returned
in document-order, as defined by the XML Canonicalization
specification. The exception occurs when using XPath
expressions involving the union operator
(denoted with the pipe '|' character).
context - is the Context which gets evaluated.
node-set of all items selected
by this XPath expression.
org.jaxen.JaxenException
protected java.lang.Object selectSingleNodeForContext(org.jaxen.Context context)
throws org.jaxen.JaxenException
union operator
(denoted with the pipe '|' character).
context - is the Context which gets evaluated.
node-set of all items selected
by this XPath expression.
org.jaxen.JaxenExceptionselectNodesForContext(org.jaxen.Context)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||