org.compass.core.xml.dom4j
Class Dom4jXmlObject

java.lang.Object
  extended by org.compass.core.xml.dom4j.Dom4jXmlObject
All Implemented Interfaces:
XmlObject
Direct Known Subclasses:
Dom4jAliasedXmlObject

public class Dom4jXmlObject
extends Object
implements XmlObject

A dom4j (http://www.dom4j.org) implementation of XmlObject.

Author:
kimchy

Constructor Summary
Dom4jXmlObject(Node node)
          Constructs a new xml object based on a dom4j Node.
Dom4jXmlObject(Node node, Map<String,String> namespaces)
          Constructs a new xml object based on a dom4j Node.
 
Method Summary
 boolean canCompileXpath()
          Return true since dom4j supports xml compilation.
 XmlXPathExpression compile(String path)
          Compiles the given xpath expression using dom4j DefaultXPath.
 String getName()
          Returns the dom4j node name.
 Map<String,String> getNamespaces()
          Returns a lookup map for namespaces (prefix to uri).
 Node getNode()
          Returns the dom4j Node that this xml object wraps.
 String getValue()
          Returns the dom4j node text.
 XmlObject[] selectPath(String path)
          Returns a list of xml objects matching 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

Dom4jXmlObject

public Dom4jXmlObject(Node node)
Constructs a new xml object based on a dom4j Node.

Parameters:
node - The node to construct the dom4j xml object with

Dom4jXmlObject

public Dom4jXmlObject(Node node,
                      Map<String,String> namespaces)
Constructs a new xml object based on a dom4j Node.

Parameters:
node - The node to construct the dom4j xml object with
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 dom4j node name.

Specified by:
getName in interface XmlObject

getValue

public String getValue()
Returns the dom4j node text.

Specified by:
getValue in interface XmlObject

selectPath

public XmlObject[] selectPath(String path)
                       throws Exception
Description copied from interface: XmlObject
Returns a list of xml objects matching the given xpath expression. Note, that the actual xml implementation might support only xpath expression compliation, so it is ok not to implement this method.

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()
Return true since dom4j supports xml compilation.

Specified by:
canCompileXpath in interface XmlObject

compile

public XmlXPathExpression compile(String path)
Compiles the given xpath expression using dom4j DefaultXPath.

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

getNode

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



Copyright (c) 2004-2008 The Compass Project.