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,java.io.Serializable
public class CsvMapper extends com.fasterxml.jackson.databind.ObjectMapperSpecializedObjectMapper, with extended functionality to produceCsvSchemainstances out of POJOs.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCsvMapper.BuilderBase implementation for "Vanilla"ObjectMapper, used with CSV backend.
-
Field Summary
Fields Modifier and Type Field Description protected LRUMap<com.fasterxml.jackson.databind.JavaType,CsvSchema>_typedSchemasSimple caching for schema instances, given that they are relatively expensive to construct; this one is for typed schemasprotected LRUMap<com.fasterxml.jackson.databind.JavaType,CsvSchema>_untypedSchemasSimple caching for schema instances, given that they are relatively expensive to construct; this one is for "loose" (non-typed) schemas-
Fields inherited from class com.fasterxml.jackson.databind.ObjectMapper
_configOverrides, _deserializationConfig, _deserializationContext, _injectableValues, _jsonFactory, _mixIns, _registeredModuleTypes, _rootDeserializers, _serializationConfig, _serializerFactory, _serializerProvider, _subtypeResolver, _typeFactory, DEFAULT_ANNOTATION_INTROSPECTOR, DEFAULT_BASE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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)protected CsvSchema.ColumnType_determineType(java.lang.Class<?> propType)protected boolean_nonPojoType(com.fasterxml.jackson.databind.JavaType t)protected CsvSchema_schemaFor(com.fasterxml.jackson.databind.JavaType pojoType, LRUMap<com.fasterxml.jackson.databind.JavaType,CsvSchema> schemas, boolean typed)static CsvMapper.Builderbuilder()static CsvMapper.Builderbuilder(CsvFactory streamFactory)CsvMapperconfigure(CsvGenerator.Feature f, boolean state)CsvMapperconfigure(CsvParser.Feature f, boolean state)CsvMappercopy()static CsvMapper.BuildercsvBuilder()Short-cut for:CsvMapperdisable(CsvGenerator.Feature f)CsvMapperdisable(CsvParser.Feature f)CsvMapperenable(CsvGenerator.Feature f)CsvMapperenable(CsvParser.Feature f)CsvFactorygetFactory()Overridden with more specific type, since factory we have is always of typeCsvFactorycom.fasterxml.jackson.databind.ObjectReaderreaderWithSchemaFor(java.lang.Class<?> pojoType)Convenience method which is functionally equivalent to:com.fasterxml.jackson.databind.ObjectReaderreaderWithTypedSchemaFor(java.lang.Class<?> pojoType)Convenience method which is functionally equivalent to:CsvSchemaschema()Convenience method that is same asCsvSchemaschemaFor(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef)CsvSchemaschemaFor(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.CsvSchemaschemaFor(java.lang.Class<?> pojoType)CsvSchemaschemaWithHeader()Convenience method that is same asCsvSchematypedSchemaFor(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef)CsvSchematypedSchemaFor(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.CsvSchematypedSchemaFor(java.lang.Class<?> pojoType)com.fasterxml.jackson.databind.ObjectWriterwriterWithSchemaFor(java.lang.Class<?> pojoType)Convenience method which is functionally equivalent to:com.fasterxml.jackson.databind.ObjectWriterwriterWithTypedSchemaFor(java.lang.Class<?> pojoType)Convenience method which is functionally equivalent to:-
Methods inherited from class com.fasterxml.jackson.databind.ObjectMapper
_checkInvalidCopy, _configAndWriteValue, _constructDefaultTypeResolverBuilder, _convert, _findRootDeserializer, _initForReading, _initForReading, _newReader, _newReader, _newWriter, _newWriter, _newWriter, _readMapAndClose, _readTreeAndClose, _readValue, _serializerProvider, _unwrapAndDeserialize, _verifyNoTrailingTokens, _verifySchemaType, acceptJsonFormatVisitor, acceptJsonFormatVisitor, addHandler, addMixIn, addMixInAnnotations, canDeserialize, canDeserialize, canSerialize, canSerialize, clearProblemHandlers, configOverride, configure, configure, configure, configure, configure, constructType, convertValue, convertValue, convertValue, createArrayNode, createDeserializationContext, createObjectNode, defaultClassIntrospector, disable, disable, disable, disable, disable, disable, disable, disableDefaultTyping, enable, enable, enable, enable, enable, enable, enable, enableDefaultTyping, enableDefaultTyping, enableDefaultTyping, enableDefaultTyping, enableDefaultTyping, enableDefaultTyping, enableDefaultTypingAsProperty, enableDefaultTypingAsProperty, findAndRegisterModules, findMixInClassFor, findModules, findModules, generateJsonSchema, getDateFormat, getDeserializationConfig, getDeserializationContext, getInjectableValues, getJsonFactory, getNodeFactory, getPolymorphicTypeValidator, getPropertyNamingStrategy, getRegisteredModuleIds, getSerializationConfig, getSerializerFactory, getSerializerProvider, getSerializerProviderInstance, getSubtypeResolver, getTypeFactory, getVisibilityChecker, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, mixInCount, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, readerFor, readerFor, readerFor, 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, setAnnotationIntrospector, setAnnotationIntrospectors, setBase64Variant, setConfig, setConfig, setDateFormat, 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, 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
-
-
-
-
Constructor Detail
-
CsvMapper
public CsvMapper()
-
CsvMapper
public CsvMapper(CsvFactory f)
-
-
Method Detail
-
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:
copyin classcom.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 typeCsvFactory- Overrides:
getFactoryin classcom.fasterxml.jackson.databind.ObjectMapper
-
readerWithSchemaFor
public com.fasterxml.jackson.databind.ObjectReader readerWithSchemaFor(java.lang.Class<?> pojoType)
Convenience method which is functionally equivalent to:reader(pojoType).withSchema(schemaFor(pojoType));
that is, constructs aObjectReaderwhich both binds to specified type and uses "loose"CsvSchemaintrospected 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(java.lang.Class<?> pojoType)
Convenience method which is functionally equivalent to:reader(pojoType).withSchema(typedSchemaFor(pojoType));
that is, constructs aObjectReaderwhich both binds to specified type and uses "strict"CsvSchemaintrospected from specified type (one where typing is inferred).
-
writerWithSchemaFor
public com.fasterxml.jackson.databind.ObjectWriter writerWithSchemaFor(java.lang.Class<?> pojoType)
Convenience method which is functionally equivalent to:writer(pojoType).with(schemaFor(pojoType));
that is, constructs aObjectWriterwhich both binds to specified type and uses "loose"CsvSchemaintrospected 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(java.lang.Class<?> pojoType)
Convenience method which is functionally equivalent to:writer(pojoType).with(typedSchemaFor(pojoType));
that is, constructs aObjectWriterwhich both binds to specified type and uses "strict"CsvSchemaintrospected from specified type (one where typing is inferred).
-
schemaWithHeader
public CsvSchema schemaWithHeader()
Convenience method that is same asCsvSchema.emptySchema().withHeader();
and returns aCsvSchemainstance 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 asCsvSchema.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).
-
schemaFor
public final CsvSchema schemaFor(java.lang.Class<?> pojoType)
-
schemaFor
public final CsvSchema schemaFor(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef)
-
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).
-
typedSchemaFor
public final CsvSchema typedSchemaFor(java.lang.Class<?> pojoType)
-
typedSchemaFor
public final CsvSchema typedSchemaFor(com.fasterxml.jackson.core.type.TypeReference<?> pojoTypeRef)
-
_schemaFor
protected CsvSchema _schemaFor(com.fasterxml.jackson.databind.JavaType pojoType, LRUMap<com.fasterxml.jackson.databind.JavaType,CsvSchema> schemas, boolean typed)
-
_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)
-
_determineType
protected CsvSchema.ColumnType _determineType(java.lang.Class<?> propType)
-
-