org.apache.camel.dataformat.xstream
Class AbstractXStreamWrapper

java.lang.Object
  extended by org.apache.camel.dataformat.xstream.AbstractXStreamWrapper
All Implemented Interfaces:
DataFormat
Direct Known Subclasses:
JsonDataFormat, XStreamDataFormat

public abstract class AbstractXStreamWrapper
extends Object
implements DataFormat

An abstract class which implement data format (DataFormat) interface which leverage the XStream library for XML or JSON's marshaling and unmarshaling

Version:

Constructor Summary
AbstractXStreamWrapper()
           
AbstractXStreamWrapper(com.thoughtworks.xstream.XStream xstream)
           
 
Method Summary
protected abstract  com.thoughtworks.xstream.io.HierarchicalStreamReader createHierarchicalStreamReader(Exchange exchange, InputStream stream)
           
protected abstract  com.thoughtworks.xstream.io.HierarchicalStreamWriter createHierarchicalStreamWriter(Exchange exchange, Object body, OutputStream stream)
           
protected  com.thoughtworks.xstream.XStream createXStream(ClassResolver resolver)
           
 Map<String,String> getAliases()
           
 List<String> getConverters()
           
 Map<String,String[]> getImplicitCollections()
           
 Map<String,String[]> getOmitFields()
           
 StaxConverter getStaxConverter()
           
 com.thoughtworks.xstream.XStream getXstream()
           
 com.thoughtworks.xstream.XStream getXStream(ClassResolver resolver)
           
 com.thoughtworks.xstream.io.HierarchicalStreamDriver getXstreamDriver()
           
 void marshal(Exchange exchange, Object body, OutputStream stream)
          Marshals the object to the given Stream.
 void setAliases(Map<String,String> aliases)
           
 void setConverters(List<String> converters)
           
 void setImplicitCollections(Map<String,String[]> implicitCollections)
           
 void setOmitFields(Map<String,String[]> omitFields)
           
 void setStaxConverter(StaxConverter staxConverter)
           
 void setXstream(com.thoughtworks.xstream.XStream xstream)
           
 void setXStream(com.thoughtworks.xstream.XStream xstream)
           
 void setXstreamDriver(com.thoughtworks.xstream.io.HierarchicalStreamDriver xstreamDriver)
           
 Object unmarshal(Exchange exchange, InputStream stream)
          Unmarshals the given stream into an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractXStreamWrapper

public AbstractXStreamWrapper()

AbstractXStreamWrapper

public AbstractXStreamWrapper(com.thoughtworks.xstream.XStream xstream)
Method Detail

getXStream

public com.thoughtworks.xstream.XStream getXStream(ClassResolver resolver)

setXStream

public void setXStream(com.thoughtworks.xstream.XStream xstream)

createXStream

protected com.thoughtworks.xstream.XStream createXStream(ClassResolver resolver)

getStaxConverter

public StaxConverter getStaxConverter()

setStaxConverter

public void setStaxConverter(StaxConverter staxConverter)

getConverters

public List<String> getConverters()

setConverters

public void setConverters(List<String> converters)

getAliases

public Map<String,String> getAliases()

setAliases

public void setAliases(Map<String,String> aliases)

getImplicitCollections

public Map<String,String[]> getImplicitCollections()

setImplicitCollections

public void setImplicitCollections(Map<String,String[]> implicitCollections)

getOmitFields

public Map<String,String[]> getOmitFields()

setOmitFields

public void setOmitFields(Map<String,String[]> omitFields)

getXstreamDriver

public com.thoughtworks.xstream.io.HierarchicalStreamDriver getXstreamDriver()

setXstreamDriver

public void setXstreamDriver(com.thoughtworks.xstream.io.HierarchicalStreamDriver xstreamDriver)

getXstream

public com.thoughtworks.xstream.XStream getXstream()

setXstream

public void setXstream(com.thoughtworks.xstream.XStream xstream)

marshal

public void marshal(Exchange exchange,
                    Object body,
                    OutputStream stream)
             throws Exception
Description copied from interface: DataFormat
Marshals the object to the given Stream.

Specified by:
marshal in interface DataFormat
Parameters:
exchange - the current exchange
body - the object to be marshalled
stream - the output stream to write the marshalled result to
Throws:
Exception - can be thrown

unmarshal

public Object unmarshal(Exchange exchange,
                        InputStream stream)
                 throws Exception
Description copied from interface: DataFormat
Unmarshals the given stream into an object.

Notice: The result is set as body on the exchange OUT message. It is possible to mutate the OUT message provided in the given exchange parameter. For instance adding headers to the OUT message will be preserved.

Specified by:
unmarshal in interface DataFormat
Parameters:
exchange - the current exchange
stream - the input stream with the object to be unmarshalled
Returns:
the unmarshalled object
Throws:
Exception - can be thrown

createHierarchicalStreamWriter

protected abstract com.thoughtworks.xstream.io.HierarchicalStreamWriter createHierarchicalStreamWriter(Exchange exchange,
                                                                                                       Object body,
                                                                                                       OutputStream stream)
                                                                                                throws XMLStreamException
Throws:
XMLStreamException

createHierarchicalStreamReader

protected abstract com.thoughtworks.xstream.io.HierarchicalStreamReader createHierarchicalStreamReader(Exchange exchange,
                                                                                                       InputStream stream)
                                                                                                throws XMLStreamException
Throws:
XMLStreamException


Apache CAMEL