TUM CCSM Commons

edu.tum.cs.commons.xml
Class XPathEvaluator

java.lang.Object
  extended by edu.tum.cs.commons.xml.XPathEvaluator

public class XPathEvaluator
extends java.lang.Object

Evaluator for XPath expression. This is preferable to using the normal XPath class as it has built-in support for namespace-handling and the evaluation-method does not define exceptions.

Version:
$Rev: 26700 $
Author:
deissenb, $Author:deissenb $
Rating:
GREEN Hash: F642A48694AB2CF2F48DB533F005C740

Constructor Summary
XPathEvaluator()
          Create new evaluator.
 
Method Summary
 void addNamespace(java.lang.String prefix, java.lang.String uri)
          Add a namespace.
 java.lang.Object select(java.lang.String expr, org.w3c.dom.Element context, javax.xml.namespace.QName returnType)
          Evaluates an XPath expression on context element.
 boolean selectBoolean(java.lang.String expr, org.w3c.dom.Element context)
          Evaluates an XPath expression on context element.
 double selectDouble(java.lang.String expr, org.w3c.dom.Element context)
          Evaluates an XPath expression on context element.
 org.w3c.dom.Element selectElement(java.lang.String expr, org.w3c.dom.Element context)
          Evaluates an XPath expression on context element.
 int selectInt(java.lang.String expr, org.w3c.dom.Element context)
          Evaluates an XPath expression on context element.
 java.util.List<org.w3c.dom.Element> selectList(java.lang.String expr, org.w3c.dom.Element context)
          Evaluates an XPath expression on context element.
 org.w3c.dom.NodeList selectNodeList(java.lang.String expr, org.w3c.dom.Element context)
          Evaluates an XPath expression on context element.
 java.lang.String selectString(java.lang.String expr, org.w3c.dom.Element context)
          Evaluates an XPath expression on context element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathEvaluator

public XPathEvaluator()
Create new evaluator.

Method Detail

addNamespace

public void addNamespace(java.lang.String prefix,
                         java.lang.String uri)
Add a namespace.


select

public java.lang.Object select(java.lang.String expr,
                               org.w3c.dom.Element context,
                               javax.xml.namespace.QName returnType)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise.

Parameters:
returnType - use XPathConstants to define return type.

selectList

public java.util.List<org.w3c.dom.Element> selectList(java.lang.String expr,
                                                      org.w3c.dom.Element context)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise.


selectNodeList

public org.w3c.dom.NodeList selectNodeList(java.lang.String expr,
                                           org.w3c.dom.Element context)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise.


selectElement

public org.w3c.dom.Element selectElement(java.lang.String expr,
                                         org.w3c.dom.Element context)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise.


selectString

public java.lang.String selectString(java.lang.String expr,
                                     org.w3c.dom.Element context)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise.


selectDouble

public double selectDouble(java.lang.String expr,
                           org.w3c.dom.Element context)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise. Due to the implementation of XPath this returns 0.0 if the element was not found.


selectInt

public int selectInt(java.lang.String expr,
                     org.w3c.dom.Element context)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise. Due to the implementation of XPath this returns 0 if the element was not found.


selectBoolean

public boolean selectBoolean(java.lang.String expr,
                             org.w3c.dom.Element context)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise. Due to the implementation of XPath this returns false if the element was not found.


TUM CCSM Commons

TUM CCSM Commons - 2.7