org.compass.core.xml.jdom
Class JDomXmlObject

java.lang.Object
  extended by org.compass.core.xml.jdom.JDomXmlObject
All Implemented Interfaces:
XmlObject
Direct Known Subclasses:
JDomAliasedXmlObject

public class JDomXmlObject
extends Object
implements XmlObject

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

Author:
kimchy

Constructor Summary
JDomXmlObject(org.jdom.Attribute attribute)
          Constructs a new xml object based on a JDMO Attribute.
JDomXmlObject(org.jdom.Attribute attribute, Map<String,String> namespaces)
           
JDomXmlObject(org.jdom.Document document)
           
JDomXmlObject(org.jdom.Document document, Map<String,String> namespaces)
           
JDomXmlObject(org.jdom.Element element)
          Constructs a new xml object based on a JDMO Element.
JDomXmlObject(org.jdom.Element element, Map<String,String> namespaces)
           
 
Method Summary
 boolean canCompileXpath()
          Return true since JDOM supports xml compilation.
 XmlXPathExpression compile(String path)
          Compiles the given xpath expression using JDMO XPath.newInstance().
 org.jdom.Attribute getAttribute()
          Returns the JDMO Attribute.
 org.jdom.Element getElement()
          Returns the JDMO Element.
 String getName()
          Returns the JDOM node name.
 Map<String,String> getNamespaces()
          Returns a lookup map for namespaces (prefix to uri).
 String getValue()
          Returns the JDOM 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

JDomXmlObject

public JDomXmlObject(org.jdom.Document document)

JDomXmlObject

public JDomXmlObject(org.jdom.Document document,
                     Map<String,String> namespaces)

JDomXmlObject

public JDomXmlObject(org.jdom.Element element)
Constructs a new xml object based on a JDMO Element.


JDomXmlObject

public JDomXmlObject(org.jdom.Element element,
                     Map<String,String> namespaces)

JDomXmlObject

public JDomXmlObject(org.jdom.Attribute attribute)
Constructs a new xml object based on a JDMO Attribute.


JDomXmlObject

public JDomXmlObject(org.jdom.Attribute attribute,
                     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 JDOM node name.

Specified by:
getName in interface XmlObject

getValue

public String getValue()
Returns the JDOM 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 JDOM supports xml compilation.

Specified by:
canCompileXpath in interface XmlObject

compile

public XmlXPathExpression compile(String path)
                           throws org.jdom.JDOMException
Compiles the given xpath expression using JDMO XPath.newInstance().

Specified by:
compile in interface XmlObject
Parameters:
path - The xpath expression
Returns:
The compiled xpath expression
Throws:
org.jdom.JDOMException

getElement

public org.jdom.Element getElement()
Returns the JDMO Element.


getAttribute

public org.jdom.Attribute getAttribute()
Returns the JDMO Attribute.



Copyright (c) 2004-2008 The Compass Project.