Class JacksonJsonDataFormat

java.lang.Object
org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat
All Implemented Interfaces:
DataFormat<SpinJsonNode>

public class JacksonJsonDataFormat extends Object implements DataFormat<SpinJsonNode>
Spin data format that can wrap Json content and uses Jackson as its implementation. Caches an instance of ObjectMapper according to the advice given in the Jackson documentation.
Author:
Thorben Lindhauer, Stefan Hentschel
  • Field Details

    • DATA_FORMAT_NAME

      public static final String DATA_FORMAT_NAME
    • objectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
      The Jackson Object Mapper used by this dataformat
    • jsonPathConfiguration

      protected com.jayway.jsonpath.Configuration jsonPathConfiguration
      The JsonPath configuration
    • typeDetectors

      protected List<TypeDetector> typeDetectors
    • dataFormatReader

      protected JacksonJsonDataFormatReader dataFormatReader
    • dataFormatWriter

      protected JacksonJsonDataFormatWriter dataFormatWriter
    • dataFormatMapper

      protected JacksonJsonDataFormatMapper dataFormatMapper
    • name

      protected final String name
  • Constructor Details

    • JacksonJsonDataFormat

      public JacksonJsonDataFormat(String name)
    • JacksonJsonDataFormat

      public JacksonJsonDataFormat(String name, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    • JacksonJsonDataFormat

      public JacksonJsonDataFormat(String name, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.jayway.jsonpath.Configuration jsonPathConfiguration)
  • Method Details

    • init

      protected void init()
    • initMapper

      protected void initMapper()
    • initWriter

      protected void initWriter()
    • initReader

      protected void initReader()
    • initTypeDetectors

      protected void initTypeDetectors()
    • getName

      public String getName()
      Specified by:
      getName in interface DataFormat<SpinJsonNode>
    • getWrapperType

      public Class<? extends SpinJsonNode> getWrapperType()
      Specified by:
      getWrapperType in interface DataFormat<SpinJsonNode>
    • createWrapperInstance

      public SpinJsonNode createWrapperInstance(Object parameter)
      Specified by:
      createWrapperInstance in interface DataFormat<SpinJsonNode>
    • getCanonicalTypeName

      public String getCanonicalTypeName(Object object)
      Identifies the canonical type of an object heuristically.
      Returns:
      the canonical type identifier of the object's class according to Jackson's type format (see TypeFactory.constructFromCanonical(String))
    • constructJavaTypeFromCanonicalString

      public com.fasterxml.jackson.databind.JavaType constructJavaTypeFromCanonicalString(String canonicalString)
      Constructs a JavaType object based on the parameter, which has to follow Jackson's canonical type string format.
      Parameters:
      canonicalString - canonical string representation of the type
      Returns:
      the constructed java type
      Throws:
      SpinJsonDataFormatException - if no type can be constructed from the given parameter
    • addTypeDetector

      public void addTypeDetector(TypeDetector typeDetector)
    • getMapper

      public JacksonJsonDataFormatMapper getMapper()
      Specified by:
      getMapper in interface DataFormat<SpinJsonNode>
      Returns:
      the DataFormatMapper used by this data format
    • getReader

      public JacksonJsonDataFormatReader getReader()
      Specified by:
      getReader in interface DataFormat<SpinJsonNode>
    • getWriter

      public JacksonJsonDataFormatWriter getWriter()
      Specified by:
      getWriter in interface DataFormat<SpinJsonNode>
    • getJsonPathConfiguration

      public com.jayway.jsonpath.Configuration getJsonPathConfiguration()
      Returns a Configuration object for jayway json path which uses this dataformat's object mapper as JsonProvider.
      Returns:
      the Configuration for jsonpath
    • setJsonPathConfiguration

      public void setJsonPathConfiguration(com.jayway.jsonpath.Configuration jsonPathConfiguration)
    • getObjectMapper

      public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Returns the configured Jackson ObjectMapper instance.
      Returns:
      the configured object mapper.
    • setObjectMapper

      public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    • createJsonNode

      public com.fasterxml.jackson.databind.JsonNode createJsonNode(Object parameter)
    • createJsonNode

      public com.fasterxml.jackson.databind.JsonNode createJsonNode(String parameter)
    • createJsonNode

      public com.fasterxml.jackson.databind.JsonNode createJsonNode(Integer parameter)
    • createJsonNode

      public com.fasterxml.jackson.databind.JsonNode createJsonNode(Float parameter)
    • createJsonNode

      public com.fasterxml.jackson.databind.JsonNode createJsonNode(Long parameter)
    • createJsonNode

      public com.fasterxml.jackson.databind.JsonNode createJsonNode(Boolean parameter)
    • createJsonNode

      public com.fasterxml.jackson.databind.JsonNode createJsonNode(List<Object> parameter)
    • createJsonNode

      public com.fasterxml.jackson.databind.JsonNode createJsonNode(Map<String,Object> parameter)
    • createNullJsonNode

      public com.fasterxml.jackson.databind.JsonNode createNullJsonNode()