Top Fields Constructors Methods
com.univocity.parsers.common.record

pack-priv Class RecordMetaDataImpl<C extends Context>

extends Object
implements RecordMetaData
Class Inheritance
All Implemented Interfaces
com.univocity.parsers.common.record.RecordMetaData
Imports
com.univocity.parsers.annotations.helpers.*, com.univocity.parsers.common.*, com.univocity.parsers.common.fields.*, com.univocity.parsers.conversions.*, java.lang.annotation.*, java.util.*

Field Summary

Modifier and TypeField and Description
private Map<Integer, Annotation>
pack-priv final C
private Map<Class<T>, Conversion<I, O>>
private FieldConversionMapping
private Map<Class<T>, Map<Annotation, Conversion<I, O>>>
private MetaData[]

Constructor Summary

AccessConstructor and Description
pack-priv
RecordMetaDataImpl(C context)

Method Summary

Modifier and TypeMethod and Description
pack-priv <T> Annotation
buildAnnotation(Class<T> type, final String args1, final String... args2)

pack-priv static Annotation
buildBooleanStringAnnotation(final String[] trueStrings, final String[] falseStrings)

public boolean
containsColumn(String
name of the header
headerName
)

Implements com.univocity.parsers.common.record.RecordMetaData.containsColumn.

Queries whether a given header name exists in the Records parsed from the input
private <T> T
convert(MetaData md, String[] data, Class<T> expectedType, Conversion<I, O>[] conversions)

private Object
convert(MetaData md, String[] data, Object defaultValue, Conversion<I, O>[] conversions)

private static Object
convert(MetaData md, String[] data, Conversion<I, O>[] conversions)

private <T> T
convert(MetaData md, String[] data, Class<T> type, T defaultValue, Annotation annotation)

public <T extends Enum<T>> FieldSet<T>
convertFields(Class<T>
the type of the enumeration whose values represent headers in the input Records
enumType
,
Conversion<I, O>...
the sequence of conversions to apply
conversions
)

Implements com.univocity.parsers.common.record.RecordMetaData.convertFields.

Associates a sequence of Conversions to fields of a given set of fields
public FieldSet<String>
convertFields(Conversion<I, O>...
the sequence of conversions to apply
conversions
)

Implements com.univocity.parsers.common.record.RecordMetaData.convertFields.

Associates a sequence of Conversions to fields of a given set of field names
public FieldSet<Integer>
convertIndexes(Conversion<I, O>...
the sequence of conversions to apply
conversions
)

Implements com.univocity.parsers.common.record.RecordMetaData.convertIndexes.

Associates a sequence of Conversions to fields of a given set of column indexes
public Object
defaultValueOf(Enum<?>
the column whose default value will be returned
column
)

Implements com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
public Object
defaultValueOf(String
the column name whose default value will be returned
headerName
)

Implements com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
public Object
defaultValueOf(int
the column index whose default value will be returned
columnIndex
)

Implements com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
private FieldConversionMapping
private MetaData
private MetaData
getMetaData(Enum<?> column)

public MetaData
getMetaData(int index)

pack-priv <T> T
getObjectValue(String[] data, String headerName, Class<T> type, T defaultValue)

pack-priv <T> T
getObjectValue(String[] data, int columnIndex, Class<T> type, T defaultValue)

pack-priv <T> T
getObjectValue(String[] data, Enum<?> column, Class<T> type, T defaultValue)

pack-priv <T> T
getObjectValue(String[] data, String headerName, Class<T> type, T defaultValue, String format, String... formatOptions)

pack-priv <T> T
getObjectValue(String[] data, int columnIndex, Class<T> type, T defaultValue, String format, String... formatOptions)

pack-priv <T> T
getObjectValue(String[] data, Enum<?> column, Class<T> type, T defaultValue, String format, String... formatOptions)

private NormalizedString[]
pack-priv String
getValue(String[] data, String headerName)

pack-priv String
getValue(String[] data, int columnIndex)

pack-priv String
getValue(String[] data, Enum<?> column)

pack-priv <T> T
getValue(String[] data, String headerName, T defaultValue, Conversion<I, O>[] conversions)

pack-priv <T> T
getValue(String[] data, int columnIndex, T defaultValue, Conversion<I, O>[] conversions)

pack-priv <T> T
getValue(String[] data, Enum<?> column, T defaultValue, Conversion<I, O>[] conversions)

pack-priv <T> T
getValue(String[] data, String headerName, Class<T> expectedType, Conversion<I, O>[] conversions)

pack-priv <T> T
getValue(String[] data, int columnIndex, Class<T> expectedType, Conversion<I, O>[] conversions)

pack-priv <T> T
getValue(String[] data, Enum<?> column, Class<T> expectedType, Conversion<I, O>[] conversions)

public String[]
headers()

Implements com.univocity.parsers.common.record.RecordMetaData.headers.

Returns the column names of the Records parsed from the input.
public int
indexOf(Enum<?>
the column whose index will be returned
column
)

Implements com.univocity.parsers.common.record.RecordMetaData.indexOf.

Returns the index of a given column
public int
indexOf(String
name of the column whose index will be returned
headerName
)

Implements com.univocity.parsers.common.record.RecordMetaData.indexOf.

Returns the index of a given column
private void
pack-priv MetaData
metadataOf(String headerName)

pack-priv MetaData
metadataOf(Enum<?> column)

pack-priv MetaData
metadataOf(int columnIndex)

private static Annotation
newFormatAnnotation(final String format, final String... formatOptions)

public String[]
selectedHeaders()

Implements com.univocity.parsers.common.record.RecordMetaData.selectedHeaders.

Returns the sequence of headers that have been selected.
public <T> void
setDefaultValueOfColumns(T
the value to be used for the given column when the parsed result is null
defaultValue
,
Enum<?>...
the columns to be associated with a default value.
columns
)

Implements com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Associates a default value with one or more columns, in case the values contained are null
public <T> void
setDefaultValueOfColumns(T
the value to be used for the given column when the parsed result is null
defaultValue
,
String...
the column names to be associated with a default value.
headerNames
)

Implements com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Associates a default value with one or more columns, in case the values contained are null
public <T> void
setDefaultValueOfColumns(T
the value to be used for the given column when the parsed result is null
defaultValue
,
int...
the column indexes to be associated with a default value.
columnIndexes
)

Implements com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Associates a default value with one or more columns, in case the values contained are null
public void
setTypeOfColumns(Class<?>
the type to associate with a list of column
type
,
Enum<E extends Enum<E>>...
the columns that will be associated with the given type.
columns
)

Implements com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

Associates a type with one or more column.
public void
setTypeOfColumns(Class<?>
the type to associate with a list of column
type
,
String...
the columns that will be associated with the given type.
headerNames
)

Implements com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

Associates a type with one or more column.
public void
setTypeOfColumns(Class<?>
the type to associate with a list of column
type
,
int...
the columns that will be associated with the given type.
columnIndexes
)

Implements com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

Associates a type with one or more column.
public Class<?>
typeOf(Enum<?>
the column whose type will be returned
column
)

Implements com.univocity.parsers.common.record.RecordMetaData.typeOf.

Returns the type associated with a given column, defined with the method setTypeOfColumns(type, columns)
public Class<?>
typeOf(String
name of the column whose type will be returned
headerName
)

Implements com.univocity.parsers.common.record.RecordMetaData.typeOf.

Returns the type associated with a given column name, defined with the method setTypeOfColumns(type, columns)
public Class<?>
typeOf(int
the position of the column whose type will be returned
columnIndex
)

Implements com.univocity.parsers.common.record.RecordMetaData.typeOf.

Returns the type associated with a given column, defined with the method setTypeOfColumns(type, columns)
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationHashesback to summary
private Map<Integer, Annotation> annotationHashes
contextback to summary
pack-priv final C context
conversionByTypeback to summary
private Map<Class<T>, Conversion<I, O>> conversionByType
Annotations
@SuppressWarnings:rawtypes
conversionsback to summary
private FieldConversionMapping conversions
conversionsByAnnotationback to summary
private Map<Class<T>, Map<Annotation, Conversion<I, O>>> conversionsByAnnotation
Annotations
@SuppressWarnings:rawtypes
indexMapback to summary
private MetaData[] indexMap

Constructor Detail

RecordMetaDataImplback to summary
pack-priv RecordMetaDataImpl(C context)

Method Detail

buildAnnotationback to summary
pack-priv <T> Annotation buildAnnotation(Class<T> type, final String args1, final String... args2)
buildBooleanStringAnnotationback to summary
pack-priv static Annotation buildBooleanStringAnnotation(final String[] trueStrings, final String[] falseStrings)
containsColumnback to summary
public boolean containsColumn(String headerName)

Implements com.univocity.parsers.common.record.RecordMetaData.containsColumn.

Doc from com.univocity.parsers.common.record.RecordMetaData.containsColumn.

Queries whether a given header name exists in the Records parsed from the input

Parameters
headerName:String

name of the header

Returns:boolean

true if the given header name exists in the input records, otherwise false

Annotations
@Override
convertback to summary
private <T> T convert(MetaData md, String[] data, Class<T> expectedType, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes
convertback to summary
private Object convert(MetaData md, String[] data, Object defaultValue, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes
convertback to summary
private static Object convert(MetaData md, String[] data, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes, unchecked
convertback to summary
private <T> T convert(MetaData md, String[] data, Class<T> type, T defaultValue, Annotation annotation)
Annotations
@SuppressWarnings:rawtypes, unchecked
convertFieldsback to summary
public <T extends Enum<T>> FieldSet<T> convertFields(Class<T> enumType, Conversion<I, O>... conversions)

Implements com.univocity.parsers.common.record.RecordMetaData.convertFields.

Doc from com.univocity.parsers.common.record.RecordMetaData.convertFields.

Associates a sequence of Conversions to fields of a given set of fields

Parameters
<T>
the enumeration type
enumType:Class<T>

the type of the enumeration whose values represent headers in the input Records

conversions:Conversion<I, O>[]

the sequence of conversions to apply

Returns:FieldSet<T>

(modifiable) set of fields to be selected and against which the given conversion sequence will be applied.

Annotations
@SuppressWarnings:rawtypes, unchecked
@Override
convertFieldsback to summary
public FieldSet<String> convertFields(Conversion<I, O>... conversions)

Implements com.univocity.parsers.common.record.RecordMetaData.convertFields.

Doc from com.univocity.parsers.common.record.RecordMetaData.convertFields.

Associates a sequence of Conversions to fields of a given set of field names

Parameters
conversions:Conversion<I, O>[]

the sequence of conversions to apply

Returns:FieldSet<String>

(modifiable) set of fields names to be selected and against which the given conversion sequence will be applied.

Annotations
@SuppressWarnings:rawtypes, unchecked
@Override
convertIndexesback to summary
public FieldSet<Integer> convertIndexes(Conversion<I, O>... conversions)

Implements com.univocity.parsers.common.record.RecordMetaData.convertIndexes.

Doc from com.univocity.parsers.common.record.RecordMetaData.convertIndexes.

Associates a sequence of Conversions to fields of a given set of column indexes

Parameters
conversions:Conversion<I, O>[]

the sequence of conversions to apply

Returns:FieldSet<Integer>

(modifiable) set of column indexes to be selected and against which the given conversion sequence will be applied.

Annotations
@SuppressWarnings:rawtypes, unchecked
@Override
defaultValueOfback to summary
public Object defaultValueOf(Enum<?> column)

Implements com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Doc from com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))

Parameters
column:Enum<?>

the column whose default value will be returned

Returns:Object

the default value associated with the given column or null.

Annotations
@Override
defaultValueOfback to summary
public Object defaultValueOf(String headerName)

Implements com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Doc from com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))

Parameters
headerName:String

the column name whose default value will be returned

Returns:Object

the default value associated with the given column or null.

Annotations
@Override
defaultValueOfback to summary
public Object defaultValueOf(int columnIndex)

Implements com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Doc from com.univocity.parsers.common.record.RecordMetaData.defaultValueOf.

Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))

Parameters
columnIndex:int

the column index whose default value will be returned

Returns:Object

the default value associated with the given column or null.

Annotations
@Override
getConversionsback to summary
private FieldConversionMapping getConversions()
getMetaDataback to summary
private MetaData getMetaData(String name)
getMetaDataback to summary
private MetaData getMetaData(Enum<?> column)
getMetaDataback to summary
public MetaData getMetaData(int index)
getObjectValueback to summary
pack-priv <T> T getObjectValue(String[] data, String headerName, Class<T> type, T defaultValue)
getObjectValueback to summary
pack-priv <T> T getObjectValue(String[] data, int columnIndex, Class<T> type, T defaultValue)
getObjectValueback to summary
pack-priv <T> T getObjectValue(String[] data, Enum<?> column, Class<T> type, T defaultValue)
getObjectValueback to summary
pack-priv <T> T getObjectValue(String[] data, String headerName, Class<T> type, T defaultValue, String format, String... formatOptions)
getObjectValueback to summary
pack-priv <T> T getObjectValue(String[] data, int columnIndex, Class<T> type, T defaultValue, String format, String... formatOptions)
getObjectValueback to summary
pack-priv <T> T getObjectValue(String[] data, Enum<?> column, Class<T> type, T defaultValue, String format, String... formatOptions)
getValidatedHeadersback to summary
private NormalizedString[] getValidatedHeaders()
getValueback to summary
pack-priv String getValue(String[] data, String headerName)
getValueback to summary
pack-priv String getValue(String[] data, int columnIndex)
getValueback to summary
pack-priv String getValue(String[] data, Enum<?> column)
getValueback to summary
pack-priv <T> T getValue(String[] data, String headerName, T defaultValue, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes, unchecked
getValueback to summary
pack-priv <T> T getValue(String[] data, int columnIndex, T defaultValue, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes, unchecked
getValueback to summary
pack-priv <T> T getValue(String[] data, Enum<?> column, T defaultValue, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes, unchecked
getValueback to summary
pack-priv <T> T getValue(String[] data, String headerName, Class<T> expectedType, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes
getValueback to summary
pack-priv <T> T getValue(String[] data, int columnIndex, Class<T> expectedType, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes
getValueback to summary
pack-priv <T> T getValue(String[] data, Enum<?> column, Class<T> expectedType, Conversion<I, O>[] conversions)
Annotations
@SuppressWarnings:rawtypes
headersback to summary
public String[] headers()

Implements com.univocity.parsers.common.record.RecordMetaData.headers.

Doc from com.univocity.parsers.common.record.RecordMetaData.headers.

Returns the column names of the Records 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.

Returns:String[]

the headers associated with the Records parsed from the input

Annotations
@Override
indexOfback to summary
public int indexOf(Enum<?> column)

Implements com.univocity.parsers.common.record.RecordMetaData.indexOf.

Doc from com.univocity.parsers.common.record.RecordMetaData.indexOf.

Returns the index of a given column

Parameters
column:Enum<?>

the column whose index will be returned

Returns:int

index of the given column

Annotations
@Override
indexOfback to summary
public int indexOf(String headerName)

Implements com.univocity.parsers.common.record.RecordMetaData.indexOf.

Doc from com.univocity.parsers.common.record.RecordMetaData.indexOf.

Returns the index of a given column

Parameters
headerName:String

name of the column whose index will be returned

Returns:int

index of the given column

Annotations
@Override
initializeMetadataConversionsback to summary
private void initializeMetadataConversions(String[] data, MetaData md)
metadataOfback to summary
pack-priv MetaData metadataOf(String headerName)
metadataOfback to summary
pack-priv MetaData metadataOf(Enum<?> column)
metadataOfback to summary
pack-priv MetaData metadataOf(int columnIndex)
newFormatAnnotationback to summary
private static Annotation newFormatAnnotation(final String format, final String... formatOptions)
selectedHeadersback to summary
public String[] selectedHeaders()

Implements com.univocity.parsers.common.record.RecordMetaData.selectedHeaders.

Doc from com.univocity.parsers.common.record.RecordMetaData.selectedHeaders.

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 method headers().

Returns:String[]

the sequence of selected headers, or all headers if no selection has been made.

Annotations
@Override
setDefaultValueOfColumnsback to summary
public <T> void setDefaultValueOfColumns(T defaultValue, Enum<?>... columns)

Implements com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Doc from com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Associates a default value with one or more columns, in case the values contained are null

Parameters
<T>
type of the default value.
defaultValue:T

the value to be used for the given column when the parsed result is null

columns:Enum<?>[]

the columns to be associated with a default value.

Annotations
@Override
setDefaultValueOfColumnsback to summary
public <T> void setDefaultValueOfColumns(T defaultValue, String... headerNames)

Implements com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Doc from com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Associates a default value with one or more columns, in case the values contained are null

Parameters
<T>
type of the default value.
defaultValue:T

the value to be used for the given column when the parsed result is null

headerNames:String[]

the column names to be associated with a default value.

Annotations
@Override
setDefaultValueOfColumnsback to summary
public <T> void setDefaultValueOfColumns(T defaultValue, int... columnIndexes)

Implements com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Doc from com.univocity.parsers.common.record.RecordMetaData.setDefaultValueOfColumns.

Associates a default value with one or more columns, in case the values contained are null

Parameters
<T>
type of the default value.
defaultValue:T

the value to be used for the given column when the parsed result is null

columnIndexes:int[]

the column indexes to be associated with a default value.

Annotations
@Override
setTypeOfColumnsback to summary
public void setTypeOfColumns(Class<?> type, Enum<E extends Enum<E>>... columns)

Implements com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

Doc from com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

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 a Record, 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.

Parameters
type:Class<?>

the type to associate with a list of column

columns:Enum<E extends Enum<E>>[]

the columns that will be associated with the given type.

Annotations
@SuppressWarnings:rawtypes
@Override
setTypeOfColumnsback to summary
public void setTypeOfColumns(Class<?> type, String... headerNames)

Implements com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

Doc from com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

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 a Record, 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.

Parameters
type:Class<?>

the type to associate with a list of column

headerNames:String[]

the columns that will be associated with the given type.

Annotations
@Override
setTypeOfColumnsback to summary
public void setTypeOfColumns(Class<?> type, int... columnIndexes)

Implements com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

Doc from com.univocity.parsers.common.record.RecordMetaData.setTypeOfColumns.

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 a Record, 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.

Parameters
type:Class<?>

the type to associate with a list of column

columnIndexes:int[]

the columns that will be associated with the given type.

Annotations
@Override
typeOfback to summary
public Class<?> typeOf(Enum<?> column)

Implements com.univocity.parsers.common.record.RecordMetaData.typeOf.

Doc from com.univocity.parsers.common.record.RecordMetaData.typeOf.

Returns the type associated with a given column, defined with the method setTypeOfColumns(type, columns)

Parameters
column:Enum<?>

the column whose type will be returned

Returns:Class<?>

the type of the given column

Annotations
@Override
typeOfback to summary
public Class<?> typeOf(String headerName)

Implements com.univocity.parsers.common.record.RecordMetaData.typeOf.

Doc from com.univocity.parsers.common.record.RecordMetaData.typeOf.

Returns the type associated with a given column name, defined with the method setTypeOfColumns(type, columns)

Parameters
headerName:String

name of the column whose type will be returned

Returns:Class<?>

the type of the given column

Annotations
@Override
typeOfback to summary
public Class<?> typeOf(int columnIndex)

Implements com.univocity.parsers.common.record.RecordMetaData.typeOf.

Doc from com.univocity.parsers.common.record.RecordMetaData.typeOf.

Returns the type associated with a given column, defined with the method setTypeOfColumns(type, columns)

Parameters
columnIndex:int

the position of the column whose type will be returned

Returns:Class<?>

the type of the given column

Annotations
@Override