Class CsvMapper

java.lang.Object
tools.jackson.databind.ObjectMapper
tools.jackson.dataformat.csv.CsvMapper
All Implemented Interfaces:
Serializable, tools.jackson.core.TreeCodec<tools.jackson.databind.JsonNode>, tools.jackson.core.Versioned

public class CsvMapper extends tools.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.
    private static final class 
    Helper class to contain dynamically constructed "shared" instance of mapper, should one be needed via shared().
    static final class 
    Simple class in order to create a map key based on JavaType and a given view.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final tools.jackson.databind.util.SimpleLookupCache<CsvMapper.ViewKey, CsvSchema>
    Simple caching for schema instances, given that they are relatively expensive to construct; this one is for typed schemas
    protected final tools.jackson.databind.util.SimpleLookupCache<CsvMapper.ViewKey, CsvSchema>
    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 tools.jackson.databind.ObjectMapper

    _deserializationConfig, _deserializationContexts, _injectableValues, _rootDeserializers, _savedBuilderState, _serializationConfig, _serializationContexts, _streamFactory, _typeFactory
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    _addSchemaProperties(tools.jackson.databind.SerializationContext ctxt, CsvSchema.Builder builder, boolean typed, tools.jackson.databind.JavaType pojoType, tools.jackson.databind.util.NameTransformer unwrapper, Class<?> view)
     
    _determineType(Class<?> propType)
     
    protected boolean
    _nonPojoType(tools.jackson.databind.JavaType t)
     
    protected CsvSchema
    _schemaFor(tools.jackson.databind.JavaType pojoType, tools.jackson.databind.util.SimpleLookupCache<CsvMapper.ViewKey, CsvSchema> schemas, boolean typed, Class<?> view)
     
     
    builder(CsvFactory streamFactory)
     
    boolean
     
    boolean
     
    tools.jackson.databind.ObjectReader
    Convenience method which is functionally equivalent to:
    tools.jackson.databind.ObjectReader
    Convenience method which is functionally equivalent to:
    protected Object
     
     
    Convenience method that is same as
    final CsvSchema
    schemaFor(Class<?> pojoType)
     
    final CsvSchema
    schemaFor(tools.jackson.core.type.TypeReference<?> pojoTypeRef)
     
    schemaFor(tools.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
    schemaForWithView(Class<?> pojoType, Class<?> view)
     
    final CsvSchema
    schemaForWithView(tools.jackson.core.type.TypeReference<?> pojoTypeRef, Class<?> view)
     
    schemaForWithView(tools.jackson.databind.JavaType pojoType, Class<?> view)
     
    Convenience method that is same as
    static CsvMapper
    Accessor method for getting globally shared "default" CsvMapper instance: one that has default configuration, no modules registered, no config overrides.
    Overridden with more specific type, since factory we have is always of type CsvFactory
    final CsvSchema
    typedSchemaFor(Class<?> pojoType)
     
    final CsvSchema
    typedSchemaFor(tools.jackson.core.type.TypeReference<?> pojoTypeRef)
     
    typedSchemaFor(tools.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
    typedSchemaForWithView(Class<?> pojoType, Class<?> view)
     
    final CsvSchema
    typedSchemaForWithView(tools.jackson.core.type.TypeReference<?> pojoTypeRef, Class<?> view)
     
    typedSchemaForWithView(tools.jackson.databind.JavaType pojoType, Class<?> view)
     
    protected Object
     
    tools.jackson.databind.ObjectWriter
    Convenience method which is functionally equivalent to:
    tools.jackson.databind.ObjectWriter
    Convenience method which is functionally equivalent to:

    Methods inherited from class tools.jackson.databind.ObjectMapper

    _assertNotNull, _configAndWriteValue, _convert, _deserializationContext, _deserializationContext, _deserializationContext, _findRootDeserializer, _initForReading, _newReader, _newReader, _newWriter, _newWriter, _newWriter, _readMapAndClose, _readTreeAndClose, _readValue, _serializationContext, _serializationContext, _verifyNoTrailingTokens, _verifySchemaType, _writeCloseableValue, acceptJsonFormatVisitor, acceptJsonFormatVisitor, acceptJsonFormatVisitor, booleanNode, clearCaches, constructType, constructType, convertValue, convertValue, convertValue, createArrayNode, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createNonBlockingByteArrayParser, createNonBlockingByteBufferParser, createObjectNode, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, deserializationConfig, getInjectableValues, getNodeFactory, getTypeFactory, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, missingNode, nullNode, 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, 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, readValue, readValue, readValue, readValue, readValues, readValues, readValues, registeredModules, serializationConfig, stringNode, treeAsTokens, treeToValue, treeToValue, treeToValue, treeToValue, treeToValue, treeToValue, updateValue, valueToTree, version, writer, writer, writer, writer, writer, writer, writer, writer, writer, writer, writerFor, writerFor, writerFor, writerWithDefaultPrettyPrinter, writerWithView, writeTree, writeValue, writeValue, writeValue, writeValue, writeValue, writeValue, writeValueAsBytes, writeValueAsString, writeValueIntoBuffer

    Methods inherited from class 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 tools.jackson.databind.util.SimpleLookupCache<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 tools.jackson.databind.util.SimpleLookupCache<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

      public CsvMapper(CsvMapper.Builder b)
      Since:
      3.0
  • Method Details

    • builder

      public static CsvMapper.Builder builder()
    • builder

      public static CsvMapper.Builder builder(CsvFactory streamFactory)
    • rebuild

      public CsvMapper.Builder rebuild()
      Overrides:
      rebuild in class tools.jackson.databind.ObjectMapper
    • shared

      public static CsvMapper shared()
      Accessor method for getting globally shared "default" CsvMapper instance: one that has default configuration, no modules registered, no config overrides. Usable mostly when dealing "untyped" or Tree-style content reading and writing.
    • writeReplace

      protected Object writeReplace()
      Overrides:
      writeReplace in class tools.jackson.databind.ObjectMapper
    • readResolve

      protected Object readResolve()
      Overrides:
      readResolve in class tools.jackson.databind.ObjectMapper
    • tokenStreamFactory

      public CsvFactory tokenStreamFactory()
      Overridden with more specific type, since factory we have is always of type CsvFactory
      Overrides:
      tokenStreamFactory in class tools.jackson.databind.ObjectMapper
    • isEnabled

      public boolean isEnabled(CsvReadFeature f)
    • isEnabled

      public boolean isEnabled(CsvWriteFeature f)
    • readerWithSchemaFor

      public tools.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 tools.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 tools.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 tools.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.
    • 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.
    • schemaFor

      public CsvSchema schemaFor(tools.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(tools.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(tools.jackson.core.type.TypeReference<?> pojoTypeRef)
    • schemaForWithView

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

      public CsvSchema typedSchemaFor(tools.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(tools.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(tools.jackson.core.type.TypeReference<?> pojoTypeRef)
    • typedSchemaForWithView

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

      protected CsvSchema _schemaFor(tools.jackson.databind.JavaType pojoType, tools.jackson.databind.util.SimpleLookupCache<CsvMapper.ViewKey, CsvSchema> schemas, boolean typed, Class<?> view)
    • _nonPojoType

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

      protected void _addSchemaProperties(tools.jackson.databind.SerializationContext ctxt, CsvSchema.Builder builder, boolean typed, tools.jackson.databind.JavaType pojoType, tools.jackson.databind.util.NameTransformer unwrapper, Class<?> view)
    • _determineType

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