Class CsvMapper

java.lang.Object
com.fasterxml.jackson.core.TreeCodec
com.fasterxml.jackson.core.ObjectCodec
com.fasterxml.jackson.databind.ObjectMapper
com.fasterxml.jackson.dataformat.csv.CsvMapper
All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned, Serializable

public class CsvMapper extends com.fasterxml.jackson.databind.ObjectMapper
Specialized ObjectMapper, with extended functionality to produce CsvSchema instances out of POJOs.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Base implementation for "Vanilla" ObjectMapper, used with CSV backend.
    static final class 
    Simple class in order to create a map key based on JavaType and a given view.

    Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.ObjectMapper

    com.fasterxml.jackson.databind.ObjectMapper.DefaultTypeResolverBuilder, com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Simple caching for schema instances, given that they are relatively expensive to construct; this one is for typed schemas
    Simple caching for schema instances, given that they are relatively expensive to construct; this one is for "loose" (non-typed) schemas
    private static final long
     

    Fields inherited from class com.fasterxml.jackson.databind.ObjectMapper

    _coercionConfigs, _configOverrides, _deserializationConfig, _deserializationContext, _injectableValues, _jsonFactory, _mixIns, _registeredModuleTypes, _rootDeserializers, _serializationConfig, _serializerFactory, _serializerProvider, _subtypeResolver, _typeFactory, DEFAULT_ANNOTATION_INTROSPECTOR, DEFAULT_BASE
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
     
     
     
    protected
    Copy-constructor, mostly used to support copy().
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    _addSchemaProperties(CsvSchema.Builder builder, com.fasterxml.jackson.databind.AnnotationIntrospector intr, boolean typed, com.fasterxml.jackson.databind.JavaType pojoType, com.fasterxml.jackson.databind.util.NameTransformer unwrapper, Class<?> view)
     
    _determineType(Class<?> propType)
     
    protected boolean
    _nonPojoType(com.fasterxml.jackson.databind.JavaType t)
     
    protected CsvSchema
    _schemaFor(com.fasterxml.jackson.databind.JavaType pojoType, LRUMap<CsvMapper.ViewKey,CsvSchema> schemas, boolean typed)
    Deprecated.
    protected CsvSchema
    _schemaFor(com.fasterxml.jackson.databind.JavaType pojoType, LRUMap<CsvMapper.ViewKey,CsvSchema> schemas, boolean typed, Class<?> view)
     
     
    builder(CsvFactory streamFactory)
     
    configure(CsvGenerator.Feature f, boolean state)
     
    configure(CsvParser.Feature f, boolean state)
     
     
    Short-cut for:
     
     
     
     
    Overridden with more specific type, since factory we have is always of type CsvFactory
    com.fasterxml.jackson.databind.ObjectReader
    Convenience method which is functionally equivalent to:
    com.fasterxml.jackson.databind.ObjectReader
    Convenience method which is functionally equivalent to:
    Convenience method that is same as
    final CsvSchema
    schemaFor(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef)
     
    schemaFor(com.fasterxml.jackson.databind.JavaType pojoType)
    Method that can be used to determine a CSV schema to use for given POJO type, using default serialization settings including ordering.
    final CsvSchema
    schemaFor(Class<?> pojoType)
     
    final CsvSchema
    schemaForWithView(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef, Class<?> view)
     
    schemaForWithView(com.fasterxml.jackson.databind.JavaType pojoType, Class<?> view)
     
    final CsvSchema
    schemaForWithView(Class<?> pojoType, Class<?> view)
     
    Convenience method that is same as
    final CsvSchema
    typedSchemaFor(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef)
     
    typedSchemaFor(com.fasterxml.jackson.databind.JavaType pojoType)
    Method that can be used to determine a CSV schema to use for given POJO type, using default serialization settings including ordering.
    final CsvSchema
    typedSchemaFor(Class<?> pojoType)
     
    final CsvSchema
    typedSchemaForWithView(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef, Class<?> view)
     
    typedSchemaForWithView(com.fasterxml.jackson.databind.JavaType pojoType, Class<?> view)
     
    final CsvSchema
    typedSchemaForWithView(Class<?> pojoType, Class<?> view)
     
    com.fasterxml.jackson.databind.ObjectWriter
    Convenience method which is functionally equivalent to:
    com.fasterxml.jackson.databind.ObjectWriter
    Convenience method which is functionally equivalent to:

    Methods inherited from class com.fasterxml.jackson.databind.ObjectMapper

    _assertNotNull, _checkInvalidCopy, _configAndWriteValue, _constructDefaultTypeResolverBuilder, _convert, _findRootDeserializer, _initForReading, _newReader, _newReader, _newWriter, _newWriter, _newWriter, _readMapAndClose, _readTreeAndClose, _readValue, _serializerProvider, _verifyNoTrailingTokens, _verifySchemaType, _writeValueAndClose, acceptJsonFormatVisitor, acceptJsonFormatVisitor, activateDefaultTyping, activateDefaultTyping, activateDefaultTyping, activateDefaultTypingAsProperty, addHandler, addMixIn, addMixInAnnotations, canDeserialize, canDeserialize, canSerialize, canSerialize, clearProblemHandlers, coercionConfigDefaults, coercionConfigFor, coercionConfigFor, configOverride, configure, configure, configure, configure, configure, configure, constructType, constructType, convertValue, convertValue, convertValue, copyWith, createArrayNode, createDeserializationContext, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createNonBlockingByteArrayParser, createObjectNode, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, deactivateDefaultTyping, defaultClassIntrospector, disable, disable, disable, disable, disable, disable, disable, disableDefaultTyping, enable, enable, enable, enable, enable, enable, enable, enableDefaultTyping, enableDefaultTyping, enableDefaultTyping, enableDefaultTypingAsProperty, findAndRegisterModules, findMixInClassFor, findModules, findModules, generateJsonSchema, getDateFormat, getDeserializationConfig, getDeserializationContext, getInjectableValues, getNodeFactory, getPolymorphicTypeValidator, getPropertyNamingStrategy, getRegisteredModuleIds, getSerializationConfig, getSerializerFactory, getSerializerProvider, getSerializerProviderInstance, getSubtypeResolver, getTypeFactory, getVisibilityChecker, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, missingNode, mixInCount, nullNode, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, readerFor, readerFor, readerFor, readerForArrayOf, readerForListOf, readerForMapOf, readerForUpdating, readerWithView, readTree, readTree, readTree, readTree, readTree, readTree, readTree, readTree, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValues, readValues, readValues, readValues, registerModule, registerModules, registerModules, registerSubtypes, registerSubtypes, registerSubtypes, setAccessorNaming, setAnnotationIntrospector, setAnnotationIntrospectors, setBase64Variant, setCacheProvider, setConfig, setConfig, setConstructorDetector, setDateFormat, setDefaultAttributes, setDefaultLeniency, setDefaultMergeable, setDefaultPrettyPrinter, setDefaultPropertyInclusion, setDefaultPropertyInclusion, setDefaultSetterInfo, setDefaultTyping, setDefaultVisibility, setFilterProvider, setFilters, setHandlerInstantiator, setInjectableValues, setLocale, setMixInAnnotations, setMixInResolver, setMixIns, setNodeFactory, setPolymorphicTypeValidator, setPropertyInclusion, setPropertyNamingStrategy, setSerializationInclusion, setSerializerFactory, setSerializerProvider, setSubtypeResolver, setTimeZone, setTypeFactory, setVisibility, setVisibility, setVisibilityChecker, tokenStreamFactory, treeAsTokens, treeToValue, treeToValue, treeToValue, updateValue, valueToTree, version, writer, writer, writer, writer, writer, writer, writer, writer, writer, writer, writerFor, writerFor, writerFor, writerWithDefaultPrettyPrinter, writerWithType, writerWithType, writerWithType, writerWithView, writeTree, writeTree, writeValue, writeValue, writeValue, writeValue, writeValue, writeValueAsBytes, writeValueAsString

    Methods inherited from class com.fasterxml.jackson.core.ObjectCodec

    getJsonFactory

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • _untypedSchemas

      protected final LRUMap<CsvMapper.ViewKey,CsvSchema> _untypedSchemas
      Simple caching for schema instances, given that they are relatively expensive to construct; this one is for "loose" (non-typed) schemas
    • _typedSchemas

      protected final LRUMap<CsvMapper.ViewKey,CsvSchema> _typedSchemas
      Simple caching for schema instances, given that they are relatively expensive to construct; this one is for typed schemas
  • Constructor Details

    • CsvMapper

      public CsvMapper()
    • CsvMapper

      public CsvMapper(CsvFactory f)
    • CsvMapper

      protected CsvMapper(CsvMapper src)
      Copy-constructor, mostly used to support copy().

      NOTE: ObjectMapper had this method since 2.1.

      Since:
      2.5
  • Method Details

    • csvBuilder

      public static CsvMapper.Builder csvBuilder()
      Short-cut for:
         return builder(new CsvFactory());
      
      Since:
      2.10
    • builder

      public static CsvMapper.Builder builder()
      Since:
      2.10
    • builder

      public static CsvMapper.Builder builder(CsvFactory streamFactory)
      Since:
      2.10
    • copy

      public CsvMapper copy()
      Overrides:
      copy in class com.fasterxml.jackson.databind.ObjectMapper
      Since:
      2.5
    • configure

      public CsvMapper configure(CsvGenerator.Feature f, boolean state)
    • configure

      public CsvMapper configure(CsvParser.Feature f, boolean state)
    • enable

      public CsvMapper enable(CsvGenerator.Feature f)
    • enable

      public CsvMapper enable(CsvParser.Feature f)
    • disable

      public CsvMapper disable(CsvGenerator.Feature f)
    • disable

      public CsvMapper disable(CsvParser.Feature f)
    • getFactory

      public CsvFactory getFactory()
      Overridden with more specific type, since factory we have is always of type CsvFactory
      Overrides:
      getFactory in class com.fasterxml.jackson.databind.ObjectMapper
    • readerWithSchemaFor

      public com.fasterxml.jackson.databind.ObjectReader readerWithSchemaFor(Class<?> pojoType)
      Convenience method which is functionally equivalent to:
        reader(pojoType).withSchema(schemaFor(pojoType));
      
      that is, constructs a ObjectReader which both binds to specified type and uses "loose" CsvSchema introspected from specified type (one without strict inferred typing).

      Parameters:
      pojoType - Type used both for data-binding (result type) and for schema introspection. NOTE: must NOT be an array or Collection type, since these only make sense for data-binding (like arrays of objects to bind), but not for schema construction (no CSV types can be mapped to arrays or Collections)
    • readerWithTypedSchemaFor

      public com.fasterxml.jackson.databind.ObjectReader readerWithTypedSchemaFor(Class<?> pojoType)
      Convenience method which is functionally equivalent to:
        reader(pojoType).withSchema(typedSchemaFor(pojoType));
      
      that is, constructs a ObjectReader which both binds to specified type and uses "strict" CsvSchema introspected from specified type (one where typing is inferred).
    • writerWithSchemaFor

      public com.fasterxml.jackson.databind.ObjectWriter writerWithSchemaFor(Class<?> pojoType)
      Convenience method which is functionally equivalent to:
        writer(pojoType).with(schemaFor(pojoType));
      
      that is, constructs a ObjectWriter which both binds to specified type and uses "loose" CsvSchema introspected from specified type (one without strict inferred typing).

      Parameters:
      pojoType - Type used both for data-binding (result type) and for schema introspection. NOTE: must NOT be an array or Collection type, since these only make sense for data-binding (like arrays of objects to bind), but not for schema construction (no root-level CSV types can be mapped to arrays or Collections)
    • writerWithTypedSchemaFor

      public com.fasterxml.jackson.databind.ObjectWriter writerWithTypedSchemaFor(Class<?> pojoType)
      Convenience method which is functionally equivalent to:
        writer(pojoType).with(typedSchemaFor(pojoType));
      
      that is, constructs a ObjectWriter which both binds to specified type and uses "strict" CsvSchema introspected from specified type (one where typing is inferred).
    • schemaWithHeader

      public CsvSchema schemaWithHeader()
      Convenience method that is same as
         CsvSchema.emptySchema().withHeader();
      
      and returns a CsvSchema instance that uses default configuration with additional setting that the first content line contains intended column names.
      Since:
      2.5
    • schema

      public CsvSchema schema()
      Convenience method that is same as
         CsvSchema.emptySchema()
      
      that is, returns an "empty" Schema; one with default values and no column definitions.
      Since:
      2.5
    • schemaFor

      public CsvSchema schemaFor(com.fasterxml.jackson.databind.JavaType pojoType)
      Method that can be used to determine a CSV schema to use for given POJO type, using default serialization settings including ordering. Definition will not be strictly typed (that is, all columns are just defined to be exposed as String tokens).
    • schemaForWithView

      public CsvSchema schemaForWithView(com.fasterxml.jackson.databind.JavaType pojoType, Class<?> view)
    • schemaFor

      public final CsvSchema schemaFor(Class<?> pojoType)
    • schemaForWithView

      public final CsvSchema schemaForWithView(Class<?> pojoType, Class<?> view)
    • schemaFor

      public final CsvSchema schemaFor(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef)
    • schemaForWithView

      public final CsvSchema schemaForWithView(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef, Class<?> view)
    • typedSchemaFor

      public CsvSchema typedSchemaFor(com.fasterxml.jackson.databind.JavaType pojoType)
      Method that can be used to determine a CSV schema to use for given POJO type, using default serialization settings including ordering. Definition WILL be strictly typed: that is, code will try to determine type limitations which may make parsing more efficient (especially for numeric types like java.lang.Integer).
    • typedSchemaForWithView

      public CsvSchema typedSchemaForWithView(com.fasterxml.jackson.databind.JavaType pojoType, Class<?> view)
    • typedSchemaFor

      public final CsvSchema typedSchemaFor(Class<?> pojoType)
    • typedSchemaForWithView

      public final CsvSchema typedSchemaForWithView(Class<?> pojoType, Class<?> view)
    • typedSchemaFor

      public final CsvSchema typedSchemaFor(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef)
    • typedSchemaForWithView

      public final CsvSchema typedSchemaForWithView(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef, Class<?> view)
    • _schemaFor

      protected CsvSchema _schemaFor(com.fasterxml.jackson.databind.JavaType pojoType, LRUMap<CsvMapper.ViewKey,CsvSchema> schemas, boolean typed, Class<?> view)
    • _schemaFor

      @Deprecated protected CsvSchema _schemaFor(com.fasterxml.jackson.databind.JavaType pojoType, LRUMap<CsvMapper.ViewKey,CsvSchema> schemas, boolean typed)
      Deprecated.
    • _nonPojoType

      protected boolean _nonPojoType(com.fasterxml.jackson.databind.JavaType t)
    • _addSchemaProperties

      protected void _addSchemaProperties(CsvSchema.Builder builder, com.fasterxml.jackson.databind.AnnotationIntrospector intr, boolean typed, com.fasterxml.jackson.databind.JavaType pojoType, com.fasterxml.jackson.databind.util.NameTransformer unwrapper, Class<?> view)
    • _determineType

      protected CsvSchema.ColumnType _determineType(Class<?> propType)