net.sf.swan.xpath
Class Selector
java.lang.Object
|
+--net.sf.swan.xpath.XPathSupport
|
+--net.sf.swan.xpath.Selector
- public class Selector
- extends XPathSupport
Utility for evaluating XPath expressions.
NOTE: Objects of this type are not thread-safe.
To facilitate sharing state between Selectors
, you can setup one
Selector as a prototype and use the XPathSupport.createSelector()
method to create other thread-specific Selectors.
Method Summary |
void |
clearExpressions()
|
java.lang.Object |
first(java.lang.String expr,
java.lang.Object contextNode)
Evaluate an XPath expression relative to the specified context node
and return the first matching result. |
protected org.jaxen.Context |
getContext(java.lang.Object node)
|
protected org.jaxen.expr.Expr |
getXPath(java.lang.String expr)
|
void |
putNamespace(java.lang.String prefix,
java.lang.String uri)
Define a namespace mapping to be used in parsing XPath expressions. |
java.util.List |
select(java.lang.String expr,
java.lang.Object contextNode)
Evaluate an XPath expression relative to the specified context node. |
java.lang.String |
string(java.lang.String expr,
java.lang.Object contextNode)
Evaluate an XPath expression relative to the specified context node
as a String. |
boolean |
test(java.lang.String expr,
java.lang.Object contextNode)
Evaluate an XPath expression relative to the specified context node
as a boolean. |
Methods inherited from class net.sf.swan.xpath.XPathSupport |
createContextSupport, createFunctionContext, createMatchContext, createMatcher, createNamespaceContext, createSelector, createVariableContext, getContextSupport, getDocument, getFunctionContext, getNavigator, getReader, getVariableValue, getVariableValue, getVariableValue, keyMap, parseAVT, parseAVT, parsePattern, parsePattern, parseXPath, parseXPath, putVariableValue, putVariableValue, resolveNamespacePrefix, setFunctionContext, setNavigator, toBoolean, toList, toSingle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Selector
public Selector()
Selector
public Selector(org.jaxen.Navigator navigator)
throws org.saxpath.SAXPathException
Selector
protected Selector(Selector prototype)
Selector
protected Selector(XPathSupport prototype)
putNamespace
public void putNamespace(java.lang.String prefix,
java.lang.String uri)
- Define a namespace mapping to be used in parsing XPath expressions.
- Overrides:
putNamespace
in class XPathSupport
select
public java.util.List select(java.lang.String expr,
java.lang.Object contextNode)
throws org.saxpath.SAXPathException
- Evaluate an XPath expression relative to the specified context node.
first
public java.lang.Object first(java.lang.String expr,
java.lang.Object contextNode)
throws org.saxpath.SAXPathException
- Evaluate an XPath expression relative to the specified context node
and return the first matching result.
string
public java.lang.String string(java.lang.String expr,
java.lang.Object contextNode)
throws org.saxpath.SAXPathException
- Evaluate an XPath expression relative to the specified context node
as a String.
test
public boolean test(java.lang.String expr,
java.lang.Object contextNode)
throws org.saxpath.SAXPathException
- Evaluate an XPath expression relative to the specified context node
as a boolean.
clearExpressions
public void clearExpressions()
getContext
protected org.jaxen.Context getContext(java.lang.Object node)
throws org.jaxen.JaxenException
getXPath
protected org.jaxen.expr.Expr getXPath(java.lang.String expr)
throws org.saxpath.SAXPathException