org.compass.core.xml.javax.converter
Class NodeXmlContentConverter

java.lang.Object
  extended by org.compass.core.xml.javax.converter.NodeXmlContentConverter
All Implemented Interfaces:
CompassConfigurable, SupportsXmlContentWrapper, XmlContentConverter

public class NodeXmlContentConverter
extends Object
implements XmlContentConverter, CompassConfigurable, SupportsXmlContentWrapper

Uses JSE to convert an xml content to and from NodeAliasedXmlObject.

Author:
kimchy

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.compass.core.converter.xsem.SupportsXmlContentWrapper
SupportsXmlContentWrapper.NotSupportedXmlContentWrapperException
 
Constructor Summary
NodeXmlContentConverter()
           
 
Method Summary
 void configure(CompassSettings settings)
          Configure using the given settings.
protected  DocumentBuilder doCreateDocumentBuilder(CompassSettings settings)
          An extension point allowing to control how a DocumentBuilder is created.
protected  Transformer doCreateTransformer(CompassSettings settings)
          An extension point allowing to control how a Transformer is created.
 AliasedXmlObject fromXml(String alias, Reader xml)
          Uses the already created DocumentBuilder and parse the given xml into a NodeAliasedXmlObject.
 boolean supports(String wrapper)
          This converter does not support a singleton wrapper strategy.
 String toXml(XmlObject xmlObject)
          Converts a NodeXmlObject into an xml string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeXmlContentConverter

public NodeXmlContentConverter()
Method Detail

configure

public void configure(CompassSettings settings)
               throws CompassException
Description copied from interface: CompassConfigurable
Configure using the given settings.

Specified by:
configure in interface CompassConfigurable
Parameters:
settings - The settings for the configured object
Throws:
CompassException

doCreateDocumentBuilder

protected DocumentBuilder doCreateDocumentBuilder(CompassSettings settings)
                                           throws ParserConfigurationException
An extension point allowing to control how a DocumentBuilder is created. By default uses DocumentBuilderFactory.newInstance().newDocumentBuilder().

Throws:
ParserConfigurationException

doCreateTransformer

protected Transformer doCreateTransformer(CompassSettings settings)
                                   throws TransformerConfigurationException
An extension point allowing to control how a Transformer is created. By default uses TransformerFactory.newInstance().newTransformer().

Throws:
TransformerConfigurationException

supports

public boolean supports(String wrapper)
This converter does not support a singleton wrapper strategy.

Specified by:
supports in interface SupportsXmlContentWrapper

fromXml

public AliasedXmlObject fromXml(String alias,
                                Reader xml)
                         throws ConversionException
Uses the already created DocumentBuilder and parse the given xml into a NodeAliasedXmlObject.

Specified by:
fromXml in interface XmlContentConverter
Parameters:
alias - The alias that will be associated with the NodeAliasedXmlObject
xml - The xml string to parse into NodeAliasedXmlObject
Returns:
A NodeAliasedXmlObject parsed from the given xml string and associated with the given alias
Throws:
ConversionException - In case the xml parsing failed

toXml

public String toXml(XmlObject xmlObject)
             throws ConversionException
Converts a NodeXmlObject into an xml string. Uses the created Transformer to do it.

Specified by:
toXml in interface XmlContentConverter
Parameters:
xmlObject - The NodeXmlObject to convert into an xml string
Returns:
The xml string representation of the given NodeXmlObject
Throws:
ConversionException - Should not really happen...


Copyright (c) 2004-2008 The Compass Project.