org.apache.camel.spi
Interface DataFormat

All Known Implementing Classes:
AbstractCastorDataFormat, AbstractXStreamWrapper, BindyCsvDataFormat, BindyFixedLengthDataFormat, BindyKeyValuePairDataFormat, CastorDataFormat, CryptoDataFormat, CsvDataFormat, FlatpackDataFormat, GzipDataFormat, HL7DataFormat, JacksonDataFormat, JaxbDataFormat, JsonDataFormat, ProtobufDataFormat, Rfc3164SyslogDataFormat, RssDataFormat, SerializationDataFormat, SoapJaxbDataFormat, StringDataFormat, TidyMarkupDataFormat, XmlBeansDataFormat, XMLSecurityDataFormat, XStreamDataFormat, ZipDataFormat

public interface DataFormat

Represents a data format used to marshal objects to and from streams such as Java Serialization or using JAXB2 to encode/decode objects using XML or using SOAP encoding.

Version:
$Revision: 16040 $

Method Summary
 void marshal(Exchange exchange, Object graph, OutputStream stream)
          Marshals the object to the given Stream.
 Object unmarshal(Exchange exchange, InputStream stream)
          Unmarshals the given stream into an object.
 

Method Detail

marshal

void marshal(Exchange exchange,
             Object graph,
             OutputStream stream)
             throws Exception
Marshals the object to the given Stream.

Parameters:
exchange - the current exchange
graph - the object to be marshalled
stream - the output stream to write the marshalled result to
Throws:
Exception - can be thrown

unmarshal

Object unmarshal(Exchange exchange,
                 InputStream stream)
                 throws Exception
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.

Parameters:
exchange - the current exchange
stream - the input stream with the object to be unmarshalled
Returns:
the unmarshalled object
Throws:
Exception - can be thrown


Apache CAMEL