Class RecordMetaDataImpl<C extends Context>
java.lang.Object
com.univocity.parsers.common.record.RecordMetaDataImpl<C>
- All Implemented Interfaces:
RecordMetaData
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<Integer,
Annotation> (package private) final C
private Map<Class,
Conversion> private FieldConversionMapping
private Map<Class,
Map<Annotation, Conversion>> private MetaData[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) <T> Annotation
buildAnnotation
(Class<T> type, String args1, String... args2) (package private) static Annotation
buildBooleanStringAnnotation
(String[] trueStrings, String[] falseStrings) boolean
containsColumn
(String headerName) Queries whether a given header name exists in theRecord
s parsed from the inputprivate static Object
convert
(MetaData md, String[] data, Conversion[] conversions) private <T> T
convert
(MetaData md, String[] data, Class<T> expectedType, Conversion[] conversions) private <T> T
convert
(MetaData md, String[] data, Class<T> type, T defaultValue, Annotation annotation) private Object
convert
(MetaData md, String[] data, Object defaultValue, Conversion[] conversions) convertFields
(Conversion... conversions) Associates a sequence ofConversion
s to fields of a given set of field namesconvertFields
(Class<T> enumType, Conversion... conversions) Associates a sequence ofConversion
s to fields of a given set of fieldsconvertIndexes
(Conversion... conversions) Associates a sequence ofConversion
s to fields of a given set of column indexesdefaultValueOf
(int columnIndex) Returns the default value associated with a column (defined usingsetDefaultValueOf(Column, Object)
)defaultValueOf
(Enum<?> column) Returns the default value associated with a column (defined usingsetDefaultValueOf(Column, Object)
)defaultValueOf
(String headerName) Returns the default value associated with a column (defined usingsetDefaultValueOf(Column, Object)
)private FieldConversionMapping
getMetaData
(int index) private MetaData
getMetaData
(Enum<?> column) private MetaData
getMetaData
(String name) (package private) <T> T
getObjectValue
(String[] data, int columnIndex, Class<T> type, T defaultValue) (package private) <T> T
getObjectValue
(String[] data, int columnIndex, Class<T> type, T defaultValue, String format, String... formatOptions) (package private) <T> T
getObjectValue
(String[] data, Enum<?> column, Class<T> type, T defaultValue) (package private) <T> T
getObjectValue
(String[] data, Enum<?> column, Class<T> type, T defaultValue, String format, String... formatOptions) (package private) <T> T
getObjectValue
(String[] data, String headerName, Class<T> type, T defaultValue) (package private) <T> T
getObjectValue
(String[] data, String headerName, Class<T> type, T defaultValue, String format, String... formatOptions) private NormalizedString[]
(package private) String
(package private) <T> T
getValue
(String[] data, int columnIndex, Class<T> expectedType, Conversion[] conversions) (package private) <T> T
getValue
(String[] data, int columnIndex, T defaultValue, Conversion[] conversions) (package private) String
(package private) <T> T
getValue
(String[] data, Enum<?> column, Class<T> expectedType, Conversion[] conversions) (package private) <T> T
getValue
(String[] data, Enum<?> column, T defaultValue, Conversion[] conversions) (package private) String
(package private) <T> T
getValue
(String[] data, String headerName, Class<T> expectedType, Conversion[] conversions) (package private) <T> T
getValue
(String[] data, String headerName, T defaultValue, Conversion[] conversions) String[]
headers()
Returns the column names of theRecord
s parsed from the input.int
Returns the index of a given columnint
Returns the index of a given columnprivate void
initializeMetadataConversions
(String[] data, MetaData md) (package private) MetaData
metadataOf
(int columnIndex) (package private) MetaData
metadataOf
(Enum<?> column) (package private) MetaData
metadataOf
(String headerName) private static Annotation
newFormatAnnotation
(String format, String... formatOptions) String[]
Returns the sequence of headers that have been selected.<T> void
setDefaultValueOfColumns
(T defaultValue, int... columnIndexes) Associates a default value with one or more columns, in case the values contained arenull
<T> void
setDefaultValueOfColumns
(T defaultValue, Enum<?>... columns) Associates a default value with one or more columns, in case the values contained arenull
<T> void
setDefaultValueOfColumns
(T defaultValue, String... headerNames) Associates a default value with one or more columns, in case the values contained arenull
void
setTypeOfColumns
(Class<?> type, int... columnIndexes) Associates a type with one or more column.void
setTypeOfColumns
(Class<?> type, Enum... columns) Associates a type with one or more column.void
setTypeOfColumns
(Class<?> type, String... headerNames) Associates a type with one or more column.Class<?>
typeOf
(int columnIndex) Returns the type associated with a given column, defined with the methodsetTypeOfColumns(type, columns)
Class<?>
Returns the type associated with a given column, defined with the methodsetTypeOfColumns(type, columns)
Class<?>
Returns the type associated with a given column name, defined with the methodsetTypeOfColumns(type, columns)
-
Field Details
-
context
-
conversionByType
-
conversionsByAnnotation
-
annotationHashes
-
indexMap
-
conversions
-
-
Constructor Details
-
RecordMetaDataImpl
RecordMetaDataImpl(C context)
-
-
Method Details
-
getMetaData
-
getValidatedHeaders
-
getMetaData
-
getMetaData
-
indexOf
Description copied from interface:RecordMetaData
Returns the index of a given column- Specified by:
indexOf
in interfaceRecordMetaData
- Parameters:
column
- the column whose index will be returned- Returns:
- index of the given column
-
metadataOf
-
metadataOf
-
metadataOf
-
indexOf
Description copied from interface:RecordMetaData
Returns the index of a given column- Specified by:
indexOf
in interfaceRecordMetaData
- Parameters:
headerName
- name of the column whose index will be returned- Returns:
- index of the given column
-
typeOf
Description copied from interface:RecordMetaData
Returns the type associated with a given column, defined with the methodsetTypeOfColumns(type, columns)
- Specified by:
typeOf
in interfaceRecordMetaData
- Parameters:
column
- the column whose type will be returned- Returns:
- the type of the given column
-
typeOf
Description copied from interface:RecordMetaData
Returns the type associated with a given column name, defined with the methodsetTypeOfColumns(type, columns)
- Specified by:
typeOf
in interfaceRecordMetaData
- Parameters:
headerName
- name of the column whose type will be returned- Returns:
- the type of the given column
-
typeOf
Description copied from interface:RecordMetaData
Returns the type associated with a given column, defined with the methodsetTypeOfColumns(type, columns)
- Specified by:
typeOf
in interfaceRecordMetaData
- Parameters:
columnIndex
- the position of the column whose type will be returned- Returns:
- the type of the given column
-
setDefaultValueOfColumns
Description copied from interface:RecordMetaData
Associates a default value with one or more columns, in case the values contained arenull
- Specified by:
setDefaultValueOfColumns
in interfaceRecordMetaData
- Type Parameters:
T
- type of the default value.- Parameters:
defaultValue
- the value to be used for the given column when the parsed result isnull
columns
- the columns to be associated with a default value.
-
setDefaultValueOfColumns
Description copied from interface:RecordMetaData
Associates a default value with one or more columns, in case the values contained arenull
- Specified by:
setDefaultValueOfColumns
in interfaceRecordMetaData
- Type Parameters:
T
- type of the default value.- Parameters:
defaultValue
- the value to be used for the given column when the parsed result isnull
headerNames
- the column names to be associated with a default value.
-
setDefaultValueOfColumns
public <T> void setDefaultValueOfColumns(T defaultValue, int... columnIndexes) Description copied from interface:RecordMetaData
Associates a default value with one or more columns, in case the values contained arenull
- Specified by:
setDefaultValueOfColumns
in interfaceRecordMetaData
- Type Parameters:
T
- type of the default value.- Parameters:
defaultValue
- the value to be used for the given column when the parsed result isnull
columnIndexes
- the column indexes to be associated with a default value.
-
defaultValueOf
Description copied from interface:RecordMetaData
Returns the default value associated with a column (defined usingsetDefaultValueOf(Column, Object)
)- Specified by:
defaultValueOf
in interfaceRecordMetaData
- Parameters:
column
- the column whose default value will be returned- Returns:
- the default value associated with the given column or
null
.
-
defaultValueOf
Description copied from interface:RecordMetaData
Returns the default value associated with a column (defined usingsetDefaultValueOf(Column, Object)
)- Specified by:
defaultValueOf
in interfaceRecordMetaData
- Parameters:
headerName
- the column name whose default value will be returned- Returns:
- the default value associated with the given column or
null
.
-
defaultValueOf
Description copied from interface:RecordMetaData
Returns the default value associated with a column (defined usingsetDefaultValueOf(Column, Object)
)- Specified by:
defaultValueOf
in interfaceRecordMetaData
- Parameters:
columnIndex
- the column index whose default value will be returned- Returns:
- the default value associated with the given column or
null
.
-
getConversions
-
convertFields
Description copied from interface:RecordMetaData
Associates a sequence ofConversion
s to fields of a given set of fields- Specified by:
convertFields
in interfaceRecordMetaData
- Type Parameters:
T
- the enumeration type- Parameters:
enumType
- the type of the enumeration whose values represent headers in the inputRecord
sconversions
- the sequence of conversions to apply- Returns:
- (modifiable) set of fields to be selected and against which the given conversion sequence will be applied.
-
convertFields
Description copied from interface:RecordMetaData
Associates a sequence ofConversion
s to fields of a given set of field names- Specified by:
convertFields
in interfaceRecordMetaData
- Parameters:
conversions
- the sequence of conversions to apply- Returns:
- (modifiable) set of fields names to be selected and against which the given conversion sequence will be applied.
-
convertIndexes
Description copied from interface:RecordMetaData
Associates a sequence ofConversion
s to fields of a given set of column indexes- Specified by:
convertIndexes
in interfaceRecordMetaData
- Parameters:
conversions
- the sequence of conversions to apply- Returns:
- (modifiable) set of column indexes to be selected and against which the given conversion sequence will be applied.
-
headers
Description copied from interface:RecordMetaData
Returns the column names of theRecord
s parsed from the input.If the headers are extracted from the input (i.e.
CommonParserSettings.isHeaderExtractionEnabled()
== true), then these values will be returned.If no headers are extracted from the input, then the configured headers in
CommonSettings.getHeaders()
will be returned.- Specified by:
headers
in interfaceRecordMetaData
- Returns:
- the headers associated with the
Record
s parsed from the input
-
selectedHeaders
Description copied from interface:RecordMetaData
Returns the sequence of headers that have been selected. If no selection has been made, all available headers will be returned, producing the same output as a call to methodRecordMetaData.headers()
.- Specified by:
selectedHeaders
in interfaceRecordMetaData
- Returns:
- the sequence of selected headers, or all headers if no selection has been made.
-
getValue
-
getValue
-
getValue
-
convert
-
convert
-
convert
-
getValue
-
getValue
-
getValue
-
getValue
-
getValue
-
getValue
-
convert
private <T> T convert(MetaData md, String[] data, Class<T> type, T defaultValue, Annotation annotation) -
initializeMetadataConversions
-
getObjectValue
-
getObjectValue
-
getObjectValue
-
getObjectValue
-
getObjectValue
-
getObjectValue
-
buildBooleanStringAnnotation
-
newFormatAnnotation
-
buildAnnotation
-
setTypeOfColumns
Description copied from interface:RecordMetaData
Associates a type with one or more column. This allows the parsed data to be converted automatically to the given type when reading data from aRecord
, e.g.Record.toFieldObjectMap(String...)
will convert the selected field values to their respective types, and then set the result as the values in the map.- Specified by:
setTypeOfColumns
in interfaceRecordMetaData
- Parameters:
type
- the type to associate with a list of columncolumns
- the columns that will be associated with the given type.
-
setTypeOfColumns
Description copied from interface:RecordMetaData
Associates a type with one or more column. This allows the parsed data to be converted automatically to the given type when reading data from aRecord
, e.g.Record.toFieldObjectMap(String...)
will convert the selected field values to their respective types, and then set the result as the values in the map.- Specified by:
setTypeOfColumns
in interfaceRecordMetaData
- Parameters:
type
- the type to associate with a list of columnheaderNames
- the columns that will be associated with the given type.
-
setTypeOfColumns
Description copied from interface:RecordMetaData
Associates a type with one or more column. This allows the parsed data to be converted automatically to the given type when reading data from aRecord
, e.g.Record.toFieldObjectMap(String...)
will convert the selected field values to their respective types, and then set the result as the values in the map.- Specified by:
setTypeOfColumns
in interfaceRecordMetaData
- Parameters:
type
- the type to associate with a list of columncolumnIndexes
- the columns that will be associated with the given type.
-
containsColumn
Description copied from interface:RecordMetaData
Queries whether a given header name exists in theRecord
s parsed from the input- Specified by:
containsColumn
in interfaceRecordMetaData
- Parameters:
headerName
- name of the header- Returns:
true
if the given header name exists in the input records, otherwisefalse
-