org.compass.core.xml.javax
Class NodeXmlObject

java.lang.Object
  extended by org.compass.core.xml.javax.NodeXmlObject
All Implemented Interfaces:
XmlObject
Direct Known Subclasses:
NodeAliasedXmlObject

public class NodeXmlObject
extends Object
implements XmlObject

A java 5 implementation of XmlObject wrapping a Node.

Author:
kimchy

Constructor Summary
NodeXmlObject(Node node)
          Constructs a new xml object using the given Node.
NodeXmlObject(Node node, Map<String,String> namespaces)
           
 
Method Summary
 boolean canCompileXpath()
          Returns true since xpath expression compilation is supported.
 XmlXPathExpression compile(String path)
          Compiles the given xpath expression.
 String getName()
          Returns the node name, if the Node.getLocalName() is not null will return it, otherwise will return Node.getNodeName().
 Map<String,String> getNamespaces()
          Returns a lookup map for namespaces (prefix to uri).
 Node getNode()
          Returns the Node this xml object wraps.
 String getValue()
          Returns the node value, using Node.getNodeValue() with the exception of element, which has special handling using DomUtils.getTextValue(org.w3c.dom.Element).
 XmlObject[] selectPath(String path)
          Compiles and selects the given xpath expression.
 void setNamespaces(Map<String,String> namespaces)
          Sets a lookup map for given namespaces (prefix to uri).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeXmlObject

public NodeXmlObject(Node node)
Constructs a new xml object using the given Node.


NodeXmlObject

public NodeXmlObject(Node node,
                     Map<String,String> namespaces)
Method Detail

setNamespaces

public void setNamespaces(Map<String,String> namespaces)
Description copied from interface: XmlObject
Sets a lookup map for given namespaces (prefix to uri).

Specified by:
setNamespaces in interface XmlObject

getNamespaces

public Map<String,String> getNamespaces()
Description copied from interface: XmlObject
Returns a lookup map for namespaces (prefix to uri).

Specified by:
getNamespaces in interface XmlObject

getName

public String getName()
Returns the node name, if the Node.getLocalName() is not null will return it, otherwise will return Node.getNodeName().

Specified by:
getName in interface XmlObject

getValue

public String getValue()
Returns the node value, using Node.getNodeValue() with the exception of element, which has special handling using DomUtils.getTextValue(org.w3c.dom.Element).

Specified by:
getValue in interface XmlObject

selectPath

public XmlObject[] selectPath(String path)
                       throws Exception
Compiles and selects the given xpath expression.

Specified by:
selectPath in interface XmlObject
Parameters:
path - The xpath expression
Returns:
A list of xml objects matching the given xpath expression
Throws:
Exception

canCompileXpath

public boolean canCompileXpath()
Returns true since xpath expression compilation is supported.

Specified by:
canCompileXpath in interface XmlObject

compile

public XmlXPathExpression compile(String path)
                           throws Exception
Compiles the given xpath expression.

Specified by:
compile in interface XmlObject
Parameters:
path - The xpath expression
Returns:
The compiled xpath expression
Throws:
Exception

getNode

public Node getNode()
Returns the Node this xml object wraps.



Copyright (c) 2004-2009 The Compass Project.