@Dataformat(value="json-gson")
@Metadata(includeProperties="unmarshalTypeName,prettyPrint,contentTypeHeader")
public class GsonDataFormat
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName, org.apache.camel.spi.DataFormatContentTypeHeader, org.apache.camel.CamelContextAware
| Constructor and Description |
|---|
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
|
GsonDataFormat(com.google.gson.Gson gson,
Type unmarshalGenericType)
Use a custom Gson mapper and and unmarshal token type
|
GsonDataFormat(Type unmarshalGenericType)
Use the default Gson
Gson and with a custom unmarshal generic type |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doInit() |
protected void |
doStart() |
protected void |
doStop() |
org.apache.camel.CamelContext |
getCamelContext() |
String |
getDataFormatName() |
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()
Deprecated.
use
isPrettyPrint() instead |
Boolean |
getSerializeNulls()
Deprecated.
use
isSerializeNulls() instead |
Type |
getUnmarshalGenericType() |
Class<?> |
getUnmarshalType() |
String |
getUnmarshalTypeName() |
boolean |
isContentTypeHeader() |
boolean |
isPrettyPrint() |
boolean |
isSerializeNulls() |
void |
marshal(org.apache.camel.Exchange exchange,
Object graph,
OutputStream stream) |
void |
setCamelContext(org.apache.camel.CamelContext camelContext) |
void |
setContentTypeHeader(boolean contentTypeHeader)
If enabled then Gson will set the Content-Type header to application/json when marshalling.
|
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 |
setPrettyPrint(boolean prettyPrint) |
void |
setPrettyPrinting(Boolean prettyPrinting)
Deprecated.
use
setPrettyPrint(boolean) instead |
void |
setSerializeNulls(boolean serializeNulls) |
void |
setSerializeNulls(Boolean serializeNulls)
Deprecated.
use
setSerializeNulls(boolean) instead |
void |
setUnmarshalGenericType(Type unmarshalGenericType) |
void |
setUnmarshalType(Class<?> unmarshalType) |
void |
setUnmarshalTypeName(String unmarshalTypeName) |
Object |
unmarshal(org.apache.camel.Exchange exchange,
InputStream stream) |
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic GsonDataFormat()
public GsonDataFormat(Class<?> unmarshalType)
Gson and with a custom unmarshal typeunmarshalType - the custom unmarshal type@Deprecated public GsonDataFormat(Class<?> unmarshalType, com.google.gson.ExclusionStrategy... exclusionStrategies)
Gson and with a custom unmarshal type and ExclusionStrategyunmarshalType - the custom unmarshal typeexclusionStrategies - one or more custom ExclusionStrategy implementationspublic GsonDataFormat(com.google.gson.Gson gson,
Class<?> unmarshalType)
gson - the custom mapperunmarshalType - the custom unmarshal typepublic GsonDataFormat(Type unmarshalGenericType)
Gson and with a custom unmarshal generic typeunmarshalGenericType - the custom unmarshal generic typepublic GsonDataFormat(com.google.gson.Gson gson,
Type unmarshalGenericType)
gson - the custom mapperunmarshalGenericType - the custom unmarshal generic typepublic org.apache.camel.CamelContext getCamelContext()
getCamelContext in interface org.apache.camel.CamelContextAwarepublic void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext in interface org.apache.camel.CamelContextAwarepublic String getDataFormatName()
getDataFormatName in interface org.apache.camel.spi.DataFormatNamepublic void marshal(org.apache.camel.Exchange exchange,
Object graph,
OutputStream stream)
throws Exception
marshal in interface org.apache.camel.spi.DataFormatExceptionpublic Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
unmarshal in interface org.apache.camel.spi.DataFormatExceptionprotected void doInit()
throws Exception
doInit in class org.apache.camel.support.service.BaseServiceExceptionprotected void doStart()
throws Exception
doStart in class org.apache.camel.support.service.BaseServiceExceptionprotected void doStop()
throws Exception
doStop in class org.apache.camel.support.service.BaseServiceExceptionpublic Class<?> getUnmarshalType()
public void setUnmarshalType(Class<?> unmarshalType)
public String getUnmarshalTypeName()
public void setUnmarshalTypeName(String unmarshalTypeName)
public Type getUnmarshalGenericType()
public void setUnmarshalGenericType(Type unmarshalGenericType)
public List<com.google.gson.ExclusionStrategy> getExclusionStrategies()
public void setExclusionStrategies(List<com.google.gson.ExclusionStrategy> exclusionStrategies)
public com.google.gson.LongSerializationPolicy getLongSerializationPolicy()
public void setLongSerializationPolicy(com.google.gson.LongSerializationPolicy longSerializationPolicy)
public com.google.gson.FieldNamingPolicy getFieldNamingPolicy()
public void setFieldNamingPolicy(com.google.gson.FieldNamingPolicy fieldNamingPolicy)
public com.google.gson.FieldNamingStrategy getFieldNamingStrategy()
public void setFieldNamingStrategy(com.google.gson.FieldNamingStrategy fieldNamingStrategy)
@Deprecated public Boolean getSerializeNulls()
isSerializeNulls() insteadpublic boolean isSerializeNulls()
@Deprecated public void setSerializeNulls(Boolean serializeNulls)
setSerializeNulls(boolean) insteadpublic void setSerializeNulls(boolean serializeNulls)
@Deprecated public Boolean getPrettyPrinting()
isPrettyPrint() insteadpublic boolean isPrettyPrint()
@Deprecated public void setPrettyPrinting(Boolean prettyPrinting)
setPrettyPrint(boolean) insteadpublic void setPrettyPrint(boolean prettyPrint)
public String getDateFormatPattern()
public void setDateFormatPattern(String dateFormatPattern)
public boolean isContentTypeHeader()
public void setContentTypeHeader(boolean contentTypeHeader)
setContentTypeHeader in interface org.apache.camel.spi.DataFormatContentTypeHeaderpublic com.google.gson.Gson getGson()
Apache Camel