|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.util.xml.xpath.xalan2.XPathXalan2Impl
Field Summary | |
private static org.apache.xalan210.xalan.extensions.ExtensionsTable |
xalanExtensionsTable
|
private org.apache.xalan210.xpath.XPath |
xpath
XPath expression string |
Constructor Summary | |
XPathXalan2Impl(String xpathExprStr)
|
Method Summary | |
Object |
evaluate(Node node)
Evaluates the xpath relative to the specified node and returns the result as the most appropriate object. |
void |
evaluate(Node node,
XPathCallback callback)
Evaluates the xpath relative to the specified node and invokes the callback method most appropriate for the located object. |
Object |
evaluateAllowingIterResult(Node node)
Same as XPath.evaluate(Node) except that org.w3c.dom.traversal.NodeIterator objects will be returned in place of NodeLists when the result is a node set. |
private org.apache.xalan210.xpath.objects.XObject |
getXObjectResult(Node node)
Internal implementation of evaluate() methods. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private org.apache.xalan210.xpath.XPath xpath
private static final org.apache.xalan210.xalan.extensions.ExtensionsTable xalanExtensionsTable
Constructor Detail |
public XPathXalan2Impl(String xpathExprStr) throws XPathException
Method Detail |
public void evaluate(Node node, XPathCallback callback) throws XPathException
XPath
You must supply an XPathCallback object to use this method to evaluate an XPath against a document. The XPath implementation is responsble for switching to the appropriate callback handler based on the XML nodes referenced by the XPath. This necessitates a style of programming that uses inner or anonymous class to handle the results of the XPath.
The motivation to implement XPath support this was largely to discourage
styles of programming that use switches or cascading if-else-ifs where
the type of the result is checked via the instanceof
operator.
To see how to effectively use this means of evaluation, look at the
following example code.
public class SomeUtilityClass { private XPathFactory factory_ = ...; public static boolean doesXPathPointToSomething( Document doc_to_search, String x_path_expression) throws XPathException { // this inner class is the callback for the evaluated xpath class WasExpressionFoundCallback extends AbstractXPathCallback { private boolean wasFound = true; public void processNotFound() { wasFound = false; } }; XPath x_path = factory_.newXPath(x_path_expression); WasExpressionFoundCallback callback = new WasExpressionFoundCallback(); x_path.evaluate(doc_to_search, callback); return callback.wasFound; } }
evaluate
in interface XPath
node
- node to search relative tocallback
- interface bearing methods for each type of located object
XPathException
- implementations should rethrow all failures
as XPathExceptionsXPathCallback
public Object evaluateAllowingIterResult(Node node) throws XPathException
XPathNI
evaluateAllowingIterResult
in interface XPathNI
XPathException
public Object evaluate(Node node) throws XPathException
XPath
One should not use this method as an excuse to implement poor
code consisting of switches or cascading if-else-ifs where the type
of the result is checked via the instanceof
operator.
This method should only be used when a single result type is demanded.
Supported API: true
evaluate
in interface XPath
node
-
XPathException
private org.apache.xalan210.xpath.objects.XObject getXObjectResult(Node node) throws XPathException
XPathException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |