org.n52.security.common.xml
Class XMLPath

java.lang.Object
  extended by org.n52.security.common.xml.XMLPath
Direct Known Subclasses:
XMLPath.BooleanXMLPath, XMLPath.NodeSetXMLPath, XMLPath.NodeXMLPath, XMLPath.NumberXMLPath, XMLPath.SourceXMLPath, XMLPath.StringXMLPath

public abstract class XMLPath
extends java.lang.Object

Class XMLPath represents an XPath and it's evaluation.

You create a "source" XMLPath by using the XMLPathCtx.findIn(org.w3c.dom.Document) methods. From there you can use the

methods to build a whole xpath. After creation of an whole xpath you can call the get() method of each concrete XMLPath instance, to get the result of the query.

Sample (finds a root node of a document):


 XMLPathCtx ctx = XMLPathCtx.createNew()
                     .addNamespace("t", "http://tempuri.org/test");
 Node result = ctx.findIn(document).node("/*").get();
 

Version:
$Revision: $
Author:
Marko Reiprecht Created on 10.07.2008

Nested Class Summary
static class XMLPath.BooleanXMLPath
          Class BooleanXMLPath, represents xpath queries resulting in boolean values.
static class XMLPath.NodeSetXMLPath
          Class NodeSetXMLPath, represents xpaths resulting in NodeLists.
static class XMLPath.NodeXMLPath
          Class NodeXMLPath, represents xpaths resulting in nodes.
static class XMLPath.NumberXMLPath
          Class NumberXMLPath, represents xpath queries resulting in number values.
static class XMLPath.SourceXMLPath
          Class SourceXMLPath, represents the xpath root/or source of evaluation.
static class XMLPath.StringXMLPath
          Class StringXMLPath, represents xpaths queries resulting in string values.
 
Field Summary
protected  XMLPathCtx m_ctx
           
protected  XMLPath m_previous
           
protected  javax.xml.xpath.XPathExpression m_xPath
           
 
Constructor Summary
protected XMLPath(XMLPath previous)
          Constructor creates a new instance.
protected XMLPath(XMLPathCtx ctx)
          Constructor creates a new instance.
 
Method Summary
 XMLPath.NodeSetXMLPath all(java.lang.String xpath)
          Method all, expects a xpath query resulting in a NodeList.
 XMLPath.BooleanXMLPath bool(java.lang.String xpath)
          Method bool, expects a xpath query resulting in a Boolean.
protected  XMLPath compile(java.lang.String xpath)
          Method compiles an xpath.
protected  java.lang.Object eval()
          Method evals the xpath.
protected abstract  javax.xml.namespace.QName getReturnType()
          Method gets the returnType of an evaluation.
 XMLPath.NodeXMLPath node(java.lang.String xpath)
          Method node, expects a xpath query resulting in a node.
 XMLPath.NumberXMLPath number(java.lang.String xpath)
          Method number, expects a xpath query resulting in a number.
 XMLPath.StringXMLPath text(java.lang.String xpath)
          Method text, expects a xpath query resulting in a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_ctx

protected XMLPathCtx m_ctx

m_previous

protected XMLPath m_previous

m_xPath

protected javax.xml.xpath.XPathExpression m_xPath
Constructor Detail

XMLPath

protected XMLPath(XMLPathCtx ctx)
Constructor creates a new instance.

Parameters:
ctx - the ctx.

XMLPath

protected XMLPath(XMLPath previous)
Constructor creates a new instance.

Parameters:
previous - the previous.
Method Detail

eval

protected java.lang.Object eval()
Method evals the xpath.

Returns:
Object.

getReturnType

protected abstract javax.xml.namespace.QName getReturnType()
Method gets the returnType of an evaluation.

Returns:
QName.

compile

protected XMLPath compile(java.lang.String xpath)
Method compiles an xpath.

Parameters:
xpath - the xpath.
Returns:
XMLPath.

node

public XMLPath.NodeXMLPath node(java.lang.String xpath)
Method node, expects a xpath query resulting in a node.

Parameters:
xpath - the xpath.
Returns:
NodeXMLPath.

all

public XMLPath.NodeSetXMLPath all(java.lang.String xpath)
Method all, expects a xpath query resulting in a NodeList.

Parameters:
xpath - the xpath.
Returns:
NodeSetXMLPath.

number

public XMLPath.NumberXMLPath number(java.lang.String xpath)
Method number, expects a xpath query resulting in a number.

Parameters:
xpath - the xpath.
Returns:
NumberXMLPath.

text

public XMLPath.StringXMLPath text(java.lang.String xpath)
Method text, expects a xpath query resulting in a string.

Parameters:
xpath - the xpath.
Returns:
StringXMLPath.

bool

public XMLPath.BooleanXMLPath bool(java.lang.String xpath)
Method bool, expects a xpath query resulting in a Boolean.

Parameters:
xpath - the xpath.
Returns:
BooleanXMLPath.


Copyright © 2004-2009 52north.org. All Rights Reserved.