Top Description Fields Constructors Methods
com.univocity.parsers.common.fields

pack-priv abstract Class AbstractColumnMapping<K>

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
com.univocity.parsers.common.fields.ColumnMapping.NameMapping, com.univocity.parsers.common.fields.ColumnMapping.MethodMapping
Type Parameters
<K>
the type of key (attribute/method names or specific method definition with parameter and return types)
Imports
com.univocity.parsers.annotations.helpers.*, java.util.*

Basic support operations for mapping attributes/methods to columns in a ColumnMapper

Field Summary

Modifier and TypeField and Description
pack-priv Map<K, Object>
pack-priv final String

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractColumnMapping(String
a dot separated sequence of names that represents the nesting of complex attributes inside a class (e.g customer.contact.phone).
prefix
,
AbstractColumnMapping<K>
the parent mapping of columns, relevant only when nested objects' attributes or methods are being mapped.
parent
)

Creates a mapping with a prefix.

Method Summary

Modifier and TypeMethod and Description
public AbstractColumnMapping<K>

Returns:

the duplicate of this object.
clone
()

Overrides java.lang.Object.clone.

Creates a deep copy of this mapping that is independent from the original.
pack-priv void
extractPrefixes(Set<String>
the set of prefixes to populate.
out
)

Returns all prefixes used by the keys in this mapping.

pack-priv abstract K

Returns:

the key formed with the given attribute name or method definition
findKey
(String
name of the attribute or method, prefixed with nested object names that identify the path to the target class member.
nameWithPrefix
)

Locates a given key based on an attribute or method name.

pack-priv abstract String

Returns:

the name of the next nested object relative to the current prefix.
getKeyPrefix
(String
the current prefix - a dot separated string with nested attribute names
prefix
,
K
the attribute name or method definition. If its own prefix starts with the given prefix, the next element after the dot will be returned (if any)
key
)

Returns the prefix of a given key, i.e. the current nested object that is being targeted.

private Object
pack-priv boolean

Returns:

true if the key is mapped.
isMapped
(K
the attribute or method name/descriptor
key
)

Tests whether a given attribute or method is mapped to a column

pack-priv void
mapToColumn(K
attribute/method name or specific method definition with parameter and return type
key
,
Enum<?>
enumeration representing the column associated with the given key
column
)

Maps a attribute or method to a column name

pack-priv void
mapToColumnIndex(K
attribute/method name or specific method definition with parameter and return type
key
,
int
number representing the position of the column associated with the given key
columnIndex
)

Maps a attribute or method to a column name

pack-priv void
mapToColumnIndexes(Map<K, Integer>
the mappings to be added
mappings
)

Maps multiple attributes or methods to multiple column names

pack-priv void
mapToColumnName(K
attribute/method name or specific method definition with parameter and return type
key
,
String
name of column associated with the given key
columnName
)

Maps a attribute or method to a column name

pack-priv void
mapToColumnNames(Map<K, String>
the mappings to be added
mappings
)

Maps multiple attributes or methods to multiple column names

pack-priv void
mapToColumns(Map<K, Enum<?>>
the mappings to be added
mappings
)

Maps multiple attributes or methods to multiple column names

pack-priv abstract K

Returns:

the transformed key or null if the key can't be used with the given prefix
prefixKey
(String
the current object nesting level, denoted by a dot-separated string of nested attribute names.
prefix
,
K
the key to transform.
key
)

Transforms the key so it can work with the given prefix.

pack-priv void
remove(String
name of the attribute or method, prefixed with nested object names that identify the path to the target class member.
nameWithPrefix
)

Removes any mappings containing keys that have a given attribute or method name.

pack-priv boolean

Returns:

true if the mapping has been successfully updated.
updateFieldMapping
(FieldMapping
a class member that has should be mapped to a column
fieldMapping
,
K
the attribute name or method specification that matches with the given field.
key
)

Updates the mapping of a attribute/method so a mapped class member can target a user provided column.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mappingback to summary
pack-priv Map<K, Object> mapping
prefixback to summary
pack-priv final String prefix

Constructor Detail

AbstractColumnMappingback to summary
pack-priv AbstractColumnMapping(String prefix, AbstractColumnMapping<K> parent)

Creates a mapping with a prefix.

Parameters
prefix:String

a dot separated sequence of names that represents the nesting of complex attributes inside a class (e.g customer.contact.phone).

parent:AbstractColumnMapping<K>

the parent mapping of columns, relevant only when nested objects' attributes or methods are being mapped.

Method Detail

cloneback to summary
public AbstractColumnMapping<K> clone()

Overrides java.lang.Object.clone.

Creates a deep copy of this mapping that is independent from the original.

Returns:AbstractColumnMapping<K>

the duplicate of this object.

extractPrefixesback to summary
pack-priv void extractPrefixes(Set<String> out)

Returns all prefixes used by the keys in this mapping. These represent names of nested objects that will be navigated through to access their attributes/methods.

Parameters
out:Set<String>

the set of prefixes to populate.

findKeyback to summary
pack-priv abstract K findKey(String nameWithPrefix)

Locates a given key based on an attribute or method name.

Parameters
nameWithPrefix:String

name of the attribute or method, prefixed with nested object names that identify the path to the target class member.

Returns:K

the key formed with the given attribute name or method definition

getKeyPrefixback to summary
pack-priv abstract String getKeyPrefix(String prefix, K key)

Returns the prefix of a given key, i.e. the current nested object that is being targeted.

Parameters
prefix:String

the current prefix - a dot separated string with nested attribute names

key:K

the attribute name or method definition. If its own prefix starts with the given prefix, the next element after the dot will be returned (if any)

Returns:String

the name of the next nested object relative to the current prefix.

getMappedColumnback to summary
private Object getMappedColumn(K key)
isMappedback to summary
pack-priv boolean isMapped(K key)

Tests whether a given attribute or method is mapped to a column

Parameters
key:K

the attribute or method name/descriptor

Returns:boolean

true if the key is mapped.

mapToColumnback to summary
pack-priv void mapToColumn(K key, Enum<?> column)

Maps a attribute or method to a column name

Parameters
key:K

attribute/method name or specific method definition with parameter and return type

column:Enum<?>

enumeration representing the column associated with the given key

mapToColumnIndexback to summary
pack-priv void mapToColumnIndex(K key, int columnIndex)

Maps a attribute or method to a column name

Parameters
key:K

attribute/method name or specific method definition with parameter and return type

columnIndex:int

number representing the position of the column associated with the given key

mapToColumnIndexesback to summary
pack-priv void mapToColumnIndexes(Map<K, Integer> mappings)

Maps multiple attributes or methods to multiple column names

Parameters
mappings:Map<K, Integer>

the mappings to be added

mapToColumnNameback to summary
pack-priv void mapToColumnName(K key, String columnName)

Maps a attribute or method to a column name

Parameters
key:K

attribute/method name or specific method definition with parameter and return type

columnName:String

name of column associated with the given key

mapToColumnNamesback to summary
pack-priv void mapToColumnNames(Map<K, String> mappings)

Maps multiple attributes or methods to multiple column names

Parameters
mappings:Map<K, String>

the mappings to be added

mapToColumnsback to summary
pack-priv void mapToColumns(Map<K, Enum<?>> mappings)

Maps multiple attributes or methods to multiple column names

Parameters
mappings:Map<K, Enum<?>>

the mappings to be added

prefixKeyback to summary
pack-priv abstract K prefixKey(String prefix, K key)

Transforms the key so it can work with the given prefix.

Parameters
prefix:String

the current object nesting level, denoted by a dot-separated string of nested attribute names.

key:K

the key to transform.

Returns:K

the transformed key or null if the key can't be used with the given prefix

removeback to summary
pack-priv void remove(String nameWithPrefix)

Removes any mappings containing keys that have a given attribute or method name.

Parameters
nameWithPrefix:String

name of the attribute or method, prefixed with nested object names that identify the path to the target class member.

updateFieldMappingback to summary
pack-priv boolean updateFieldMapping(FieldMapping fieldMapping, K key)

Updates the mapping of a attribute/method so a mapped class member can target a user provided column.

Parameters
fieldMapping:FieldMapping

a class member that has should be mapped to a column

key:K

the attribute name or method specification that matches with the given field.

Returns:boolean

true if the mapping has been successfully updated.