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 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(String prefix, String uri)
          Add a namespace.
 Object select(String expr, Element context, QName returnType)
          Evaluates an XPath expression on context element.
 boolean selectBoolean(String expr, Element context)
          Evaluates an XPath expression on context element.
 double selectDouble(String expr, Element context)
          Evaluates an XPath expression on context element.
 Element selectElement(String expr, Element context)
          Evaluates an XPath expression on context element.
 int selectInt(String expr, Element context)
          Evaluates an XPath expression on context element.
 List<Element> selectList(String expr, Element context)
          Evaluates an XPath expression on context element.
 NodeList selectNodeList(String expr, Element context)
          Evaluates an XPath expression on context element.
 String selectString(String expr, 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(String prefix,
                         String uri)
Add a namespace.


select

public Object select(String expr,
                     Element context,
                     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 List<Element> selectList(String expr,
                                Element context)
Evaluates an XPath expression on context element. This assumes that the XPath expression is valid and raises an AssertionError otherwise.


selectNodeList

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


selectElement

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


selectString

public String selectString(String expr,
                           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(String expr,
                           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(String expr,
                     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(String expr,
                             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