org.compass.core.xml
Class RawXmlObject

java.lang.Object
  extended by org.compass.core.xml.RawXmlObject
All Implemented Interfaces:
XmlObject
Direct Known Subclasses:
RawAliasedXmlObject

public class RawXmlObject
extends Object
implements XmlObject

An XmlObject that has an xml string representation. Mainly used for simpliciy, where Compass will use the configured XmlContentConverter in order to convert to xml string into the actual XmlObject implementation.

This object will only be used when saving xml object into Compass. When Compass returns xml objects as a restult of a query or get/load operations, the actual XmlObject will be returned.

Naturally, since the xml string will only be parsed when Compass will convert this object, all the XmlObject methods are not implemented. The XmlObject is just used as a marker interface to use the correct xsem supported converters.

Author:
kimchy

Constructor Summary
RawXmlObject(Reader xml)
          Creates a new String based xml object using a Reader holding the actual xml content.
RawXmlObject(String xml)
          Creates a new String based xml object using a String holding the actual xml content.
 
Method Summary
 boolean canCompileXpath()
          Returns true of the xml object supports xpath expression compilation.
 XmlXPathExpression compile(String path)
          Compiles the given xpath expression.
 String getName()
          Returns the name of the xml object.
 Map<String,String> getNamespaces()
          Returns a lookup map for namespaces (prefix to uri).
 String getValue()
          Returns the value of the xml object.
 Reader getXml()
           
 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

RawXmlObject

public RawXmlObject(String xml)
Creates a new String based xml object using a String holding the actual xml content.


RawXmlObject

public RawXmlObject(Reader xml)
Creates a new String based xml object using a Reader holding the actual xml content.

Method Detail

getXml

public Reader getXml()

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()
Description copied from interface: XmlObject
Returns the name of the xml object. Should be the element/attribute name.

Specified by:
getName in interface XmlObject

getValue

public String getValue()
Description copied from interface: XmlObject
Returns the value of the xml object.

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()
Description copied from interface: XmlObject
Returns true of the xml object supports xpath expression compilation.

Specified by:
canCompileXpath in interface XmlObject

compile

public XmlXPathExpression compile(String path)
                           throws Exception
Description copied from interface: XmlObject
Compiles the given xpath expression.

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


Copyright (c) 2004-2009 The Compass Project.