Class 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 Detail

      • SnakeYAMLDataFormat

        public SnakeYAMLDataFormat()
      • SnakeYAMLDataFormat

        public SnakeYAMLDataFormat​(Class<?> type)
    • Method Detail

      • getDataFormatName

        public String getDataFormatName()
        Specified by:
        getDataFormatName in interface org.apache.camel.spi.DataFormatName
      • 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
        Overrides:
        doStart in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.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
      • 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)
      • getClassTags

        public Map<Class<?>,​org.yaml.snakeyaml.nodes.Tag> getClassTags()
      • setClassTags

        public void setClassTags​(Map<Class<?>,​org.yaml.snakeyaml.nodes.Tag> classTags)
        Define a tag for the Class 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 bot Constructor and Representer
      • setTypeFilters

        public void setTypeFilters​(List<TypeFilter> typeFilters)
        Set the types SnakeYAML is allowed to un-marshall
      • setTypeFilterDefinitions

        public void setTypeFilterDefinitions​(List<String> typeFilterDefinitions)
      • 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.