Class SnakeYAMLDataFormat
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.component.snakeyaml.SnakeYAMLDataFormat
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.DataFormat
,org.apache.camel.spi.DataFormatName
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@Dataformat("yaml-snakeyaml") public final class SnakeYAMLDataFormat extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName
Marshal and unmarshal Java objects to and from YAML using SnakeYAML
-
-
Constructor Summary
Constructors Constructor Description SnakeYAMLDataFormat()
SnakeYAMLDataFormat(Class<?> type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClassTags(Class<?> type, org.yaml.snakeyaml.nodes.Tag tag)
void
addTag(Class<?> type, org.yaml.snakeyaml.nodes.Tag tag)
Convenience method to set class tag for botConstructor
andRepresenter
void
addTypeDescription(Class<?> type, org.yaml.snakeyaml.nodes.Tag tag)
void
addTypeDescriptions(Collection<org.yaml.snakeyaml.TypeDescription> typeDescriptions)
void
addTypeDescriptions(org.yaml.snakeyaml.TypeDescription... typeDescriptions)
void
addTypeFilters(Collection<TypeFilter> typeFilters)
void
addTypeFilters(TypeFilter... typeFilters)
protected void
doStart()
protected void
doStop()
ClassLoader
getClassLoader()
Map<Class<?>,org.yaml.snakeyaml.nodes.Tag>
getClassTags()
Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.constructor.BaseConstructor>
getConstructor()
String
getDataFormatName()
Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.DumperOptions>
getDumperOptions()
int
getMaxAliasesForCollections()
Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.representer.Representer>
getRepresenter()
Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.resolver.Resolver>
getResolver()
List<org.yaml.snakeyaml.TypeDescription>
getTypeDescriptions()
List<TypeFilter>
getTypeFilters()
Class<?>
getUnmarshalType()
protected org.yaml.snakeyaml.Yaml
getYaml(org.apache.camel.CamelContext context)
boolean
isAllowAnyType()
boolean
isAllowRecursiveKeys()
boolean
isPrettyFlow()
boolean
isUseApplicationContextClassLoader()
void
marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream)
void
setAllowAnyType(boolean allowAnyType)
Allow any class to be un-marshaled, same as setTypeFilters(TypeFilters.allowAll())void
setAllowRecursiveKeys(boolean allowRecursiveKeys)
Set whether recursive keys are allowed.void
setClassLoader(ClassLoader classLoader)
Set a custom classloadervoid
setClassTags(Map<Class<?>,org.yaml.snakeyaml.nodes.Tag> classTags)
Define a tag for theClass
to serialize.void
setConstructor(Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.constructor.BaseConstructor> constructor)
BaseConstructor to construct incoming documents.void
setDumperOptions(Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.DumperOptions> dumperOptions)
DumperOptions to configure outgoing objects.void
setMaxAliasesForCollections(int maxAliasesForCollections)
Set the maximum amount of aliases allowed for collections.void
setPrettyFlow(boolean prettyFlow)
Force the emitter to produce a pretty YAML document when using the flow style.void
setRepresenter(Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.representer.Representer> representer)
Representer to emit outgoing objects.void
setResolver(Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.resolver.Resolver> resolver)
Resolver to detect implicit typevoid
setTypeDescriptions(List<org.yaml.snakeyaml.TypeDescription> typeDescriptions)
Make YAML aware how to parse a custom Class.void
setTypeFilterDefinitions(List<String> typeFilterDefinitions)
void
setTypeFilters(List<TypeFilter> typeFilters)
Set the types SnakeYAML is allowed to un-marshallvoid
setUnmarshalType(Class<?> unmarshalType)
Class of the object to be createdvoid
setUseApplicationContextClassLoader(boolean useApplicationContextClassLoader)
Use ApplicationContextClassLoader as custom ClassLoaderObject
unmarshal(org.apache.camel.Exchange exchange, InputStream stream)
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, 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, suspend
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
SnakeYAMLDataFormat
public SnakeYAMLDataFormat()
-
SnakeYAMLDataFormat
public SnakeYAMLDataFormat(Class<?> type)
-
-
Method Detail
-
getDataFormatName
public String getDataFormatName()
- Specified by:
getDataFormatName
in interfaceorg.apache.camel.spi.DataFormatName
-
marshal
public void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream) throws Exception
- Specified by:
marshal
in interfaceorg.apache.camel.spi.DataFormat
- Throws:
Exception
-
unmarshal
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
- Specified by:
unmarshal
in interfaceorg.apache.camel.spi.DataFormat
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
getYaml
protected org.yaml.snakeyaml.Yaml getYaml(org.apache.camel.CamelContext context)
-
getConstructor
public Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.constructor.BaseConstructor> getConstructor()
-
setConstructor
public void setConstructor(Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.constructor.BaseConstructor> constructor)
BaseConstructor to construct incoming documents.
-
getRepresenter
public Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.representer.Representer> getRepresenter()
-
setRepresenter
public void setRepresenter(Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.representer.Representer> representer)
Representer to emit outgoing objects.
-
getDumperOptions
public Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.DumperOptions> getDumperOptions()
-
setDumperOptions
public void setDumperOptions(Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.DumperOptions> dumperOptions)
DumperOptions to configure outgoing objects.
-
getResolver
public Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.resolver.Resolver> getResolver()
-
setResolver
public void setResolver(Function<org.apache.camel.CamelContext,org.yaml.snakeyaml.resolver.Resolver> resolver)
Resolver to detect implicit type
-
getClassLoader
public ClassLoader getClassLoader()
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
Set a custom classloader
-
getUnmarshalType
public Class<?> getUnmarshalType()
-
setUnmarshalType
public void setUnmarshalType(Class<?> unmarshalType)
Class of the object to be created
-
getTypeDescriptions
public List<org.yaml.snakeyaml.TypeDescription> getTypeDescriptions()
-
setTypeDescriptions
public void setTypeDescriptions(List<org.yaml.snakeyaml.TypeDescription> typeDescriptions)
Make YAML aware how to parse a custom Class.
-
addTypeDescriptions
public void addTypeDescriptions(Collection<org.yaml.snakeyaml.TypeDescription> typeDescriptions)
-
addTypeDescriptions
public void addTypeDescriptions(org.yaml.snakeyaml.TypeDescription... typeDescriptions)
-
addTypeDescription
public void addTypeDescription(Class<?> type, org.yaml.snakeyaml.nodes.Tag tag)
-
setClassTags
public void setClassTags(Map<Class<?>,org.yaml.snakeyaml.nodes.Tag> classTags)
Define a tag for theClass
to serialize.
-
addClassTags
public void addClassTags(Class<?> type, org.yaml.snakeyaml.nodes.Tag tag)
-
isUseApplicationContextClassLoader
public boolean isUseApplicationContextClassLoader()
-
setUseApplicationContextClassLoader
public void setUseApplicationContextClassLoader(boolean useApplicationContextClassLoader)
Use ApplicationContextClassLoader as custom ClassLoader
-
isPrettyFlow
public boolean isPrettyFlow()
-
setPrettyFlow
public void setPrettyFlow(boolean prettyFlow)
Force the emitter to produce a pretty YAML document when using the flow style.
-
addTag
public void addTag(Class<?> type, org.yaml.snakeyaml.nodes.Tag tag)
Convenience method to set class tag for botConstructor
andRepresenter
-
getTypeFilters
public List<TypeFilter> getTypeFilters()
-
setTypeFilters
public void setTypeFilters(List<TypeFilter> typeFilters)
Set the types SnakeYAML is allowed to un-marshall
-
addTypeFilters
public void addTypeFilters(Collection<TypeFilter> typeFilters)
-
addTypeFilters
public void addTypeFilters(TypeFilter... typeFilters)
-
isAllowAnyType
public boolean isAllowAnyType()
-
setAllowAnyType
public void setAllowAnyType(boolean allowAnyType)
Allow any class to be un-marshaled, same as setTypeFilters(TypeFilters.allowAll())
-
getMaxAliasesForCollections
public int getMaxAliasesForCollections()
-
setMaxAliasesForCollections
public void setMaxAliasesForCollections(int maxAliasesForCollections)
Set the maximum amount of aliases allowed for collections.
-
isAllowRecursiveKeys
public boolean isAllowRecursiveKeys()
-
setAllowRecursiveKeys
public void setAllowRecursiveKeys(boolean allowRecursiveKeys)
Set whether recursive keys are allowed.
-
-