org.apache.camel.dataformat.protobuf
Class ProtobufDataFormat

java.lang.Object
  extended by org.apache.camel.dataformat.protobuf.ProtobufDataFormat
All Implemented Interfaces:
DataFormat

public class ProtobufDataFormat
extends Object
implements DataFormat


Constructor Summary
ProtobufDataFormat()
           
ProtobufDataFormat(com.google.protobuf.Message defaultInstance)
           
 
Method Summary
 com.google.protobuf.Message getInstance(Exchange exchange)
           
protected  com.google.protobuf.Message loadDefaultInstance(String className, CamelContext context)
           
 void marshal(Exchange exchange, Object graph, OutputStream outputStream)
          Marshals the object to the given Stream.
 void setDefaultInstace(com.google.protobuf.Message instance)
           
 void setDefaultInstance(Object instance)
           
 void setInstanceClass(String className)
           
 Object unmarshal(Exchange exchange, InputStream inputStream)
          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

ProtobufDataFormat

public ProtobufDataFormat(com.google.protobuf.Message defaultInstance)
Parameters:
defaultInstance -

ProtobufDataFormat

public ProtobufDataFormat()
Method Detail

setDefaultInstace

public void setDefaultInstace(com.google.protobuf.Message instance)

setDefaultInstance

public void setDefaultInstance(Object instance)

getInstance

public com.google.protobuf.Message getInstance(Exchange exchange)
                                        throws Exception
Throws:
Exception

setInstanceClass

public void setInstanceClass(String className)
                      throws Exception
Throws:
Exception

loadDefaultInstance

protected com.google.protobuf.Message loadDefaultInstance(String className,
                                                          CamelContext context)
                                                   throws CamelException,
                                                          ClassNotFoundException
Throws:
CamelException
ClassNotFoundException

marshal

public void marshal(Exchange exchange,
                    Object graph,
                    OutputStream outputStream)
             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
graph - the object to be marshalled
outputStream - the output stream to write the marshalled result to
Throws:
Exception - can be thrown

unmarshal

public Object unmarshal(Exchange exchange,
                        InputStream inputStream)
                 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
inputStream - the input stream with the object to be unmarshalled
Returns:
the unmarshalled object
Throws:
Exception - can be thrown


Apache CAMEL