org.apache.camel.component.gson
Class GsonDataFormat

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.component.gson.GsonDataFormat
All Implemented Interfaces:
org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.DataFormat, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

public class GsonDataFormat
extends org.apache.camel.support.ServiceSupport
implements org.apache.camel.spi.DataFormat

A data format (DataFormat) using Gson to marshal to and from JSON.


Field Summary
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
GsonDataFormat()
           
GsonDataFormat(Class<?> unmarshalType)
          Use the default Gson Gson and with a custom unmarshal type
GsonDataFormat(Class<?> unmarshalType, com.google.gson.ExclusionStrategy... exclusionStrategies)
          Deprecated. use the setter instead
GsonDataFormat(com.google.gson.Gson gson, Class<?> unmarshalType)
          Use a custom Gson mapper and and unmarshal type
 
Method Summary
protected  void doStart()
           
protected  void doStop()
           
 String getDateFormatPattern()
           
 List<com.google.gson.ExclusionStrategy> getExclusionStrategies()
           
 com.google.gson.FieldNamingPolicy getFieldNamingPolicy()
           
 com.google.gson.FieldNamingStrategy getFieldNamingStrategy()
           
 com.google.gson.Gson getGson()
           
 com.google.gson.LongSerializationPolicy getLongSerializationPolicy()
           
 Boolean getPrettyPrinting()
           
 Boolean getSerializeNulls()
           
 Class<?> getUnmarshalType()
           
 void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream)
           
 void setDateFormatPattern(String dateFormatPattern)
           
 void setExclusionStrategies(List<com.google.gson.ExclusionStrategy> exclusionStrategies)
           
 void setFieldNamingPolicy(com.google.gson.FieldNamingPolicy fieldNamingPolicy)
           
 void setFieldNamingStrategy(com.google.gson.FieldNamingStrategy fieldNamingStrategy)
           
 void setLongSerializationPolicy(com.google.gson.LongSerializationPolicy longSerializationPolicy)
           
 void setPrettyPrinting(Boolean prettyPrinting)
           
 void setSerializeNulls(Boolean serializeNulls)
           
 void setUnmarshalType(Class<?> unmarshalType)
           
 Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream)
           
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GsonDataFormat

public GsonDataFormat()

GsonDataFormat

public GsonDataFormat(Class<?> unmarshalType)
Use the default Gson Gson and with a custom unmarshal type

Parameters:
unmarshalType - the custom unmarshal type

GsonDataFormat

@Deprecated
public GsonDataFormat(Class<?> unmarshalType,
                                 com.google.gson.ExclusionStrategy... exclusionStrategies)
Deprecated. use the setter instead

Use the default Gson Gson and with a custom unmarshal type and ExclusionStrategy

Parameters:
unmarshalType - the custom unmarshal type
exclusionStrategies - one or more custom ExclusionStrategy implementations

GsonDataFormat

public GsonDataFormat(com.google.gson.Gson gson,
                      Class<?> unmarshalType)
Use a custom Gson mapper and and unmarshal type

Parameters:
gson - the custom mapper
unmarshalType - the custom unmarshal type
Method Detail

marshal

public void marshal(org.apache.camel.Exchange exchange,
                    Object graph,
                    OutputStream stream)
             throws Exception
Specified by:
marshal in interface org.apache.camel.spi.DataFormat
Throws:
Exception

unmarshal

public Object unmarshal(org.apache.camel.Exchange exchange,
                        InputStream stream)
                 throws Exception
Specified by:
unmarshal in interface org.apache.camel.spi.DataFormat
Throws:
Exception

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class org.apache.camel.support.ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class org.apache.camel.support.ServiceSupport
Throws:
Exception

getUnmarshalType

public Class<?> getUnmarshalType()

setUnmarshalType

public void setUnmarshalType(Class<?> unmarshalType)

getExclusionStrategies

public List<com.google.gson.ExclusionStrategy> getExclusionStrategies()

setExclusionStrategies

public void setExclusionStrategies(List<com.google.gson.ExclusionStrategy> exclusionStrategies)

getLongSerializationPolicy

public com.google.gson.LongSerializationPolicy getLongSerializationPolicy()

setLongSerializationPolicy

public void setLongSerializationPolicy(com.google.gson.LongSerializationPolicy longSerializationPolicy)

getFieldNamingPolicy

public com.google.gson.FieldNamingPolicy getFieldNamingPolicy()

setFieldNamingPolicy

public void setFieldNamingPolicy(com.google.gson.FieldNamingPolicy fieldNamingPolicy)

getFieldNamingStrategy

public com.google.gson.FieldNamingStrategy getFieldNamingStrategy()

setFieldNamingStrategy

public void setFieldNamingStrategy(com.google.gson.FieldNamingStrategy fieldNamingStrategy)

getSerializeNulls

public Boolean getSerializeNulls()

setSerializeNulls

public void setSerializeNulls(Boolean serializeNulls)

getPrettyPrinting

public Boolean getPrettyPrinting()

setPrettyPrinting

public void setPrettyPrinting(Boolean prettyPrinting)

getDateFormatPattern

public String getDateFormatPattern()

setDateFormatPattern

public void setDateFormatPattern(String dateFormatPattern)

getGson

public com.google.gson.Gson getGson()


Apache Camel