Class FieldConversionMapping
- java.lang.Object
-
- com.univocity.parsers.common.fields.FieldConversionMapping
-
- All Implemented Interfaces:
java.lang.Cloneable
public class FieldConversionMapping extends java.lang.Object implements java.lang.Cloneable
A class for mapping field selections to sequences ofConversion
objects- Author:
- Univocity Software Pty Ltd - parsers@univocity.com
-
-
Field Summary
Fields Modifier and Type Field Description int[]
validatedIndexes
-
Constructor Summary
Constructors Constructor Description FieldConversionMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
applyConversions(int index, java.lang.String stringValue, boolean[] convertedFlags)
Applies a sequence of conversions associated with a String value parsed from a given index.void
applyConversionsOnAllFields(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on all fields.FieldSet<java.lang.Enum>
applyConversionsOnFieldEnums(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on a selection of enumerations that represent fieldsFieldSet<java.lang.Integer>
applyConversionsOnFieldIndexes(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on a selection of field indexesFieldSet<java.lang.String>
applyConversionsOnFieldNames(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on a selection of field nameFieldConversionMapping
clone()
void
executeValidations(int index, java.lang.Object value)
Applies any validations associated with a field at a given index in a recordConversion[]
getConversions(int index, java.lang.Class<?> expectedType)
Returns the sequence of conversions to be applied at a given column indexvoid
prepareExecution(boolean writing, java.lang.String[] values)
Prepares the conversions registered in this object to be executed against a given sequence of fieldsjava.lang.Object
reverseConversions(boolean executeInReverseOrder, int index, java.lang.Object value, boolean[] convertedFlags)
Applies a sequence of conversions associated with an Object value at a given index in a record.
-
-
-
Method Detail
-
prepareExecution
public void prepareExecution(boolean writing, java.lang.String[] values)
Prepares the conversions registered in this object to be executed against a given sequence of fields- Parameters:
writing
- flag indicating whether a writing process is being initialized.values
- The field sequence that identifies how records will be organized.This is generally the sequence of headers in a record, but it might be just the first parsed row from a given input (as field selection by index is allowed).
-
applyConversionsOnAllFields
public void applyConversionsOnAllFields(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on all fields.- Parameters:
conversions
- the sequence of conversions to be applied
-
applyConversionsOnFieldIndexes
public FieldSet<java.lang.Integer> applyConversionsOnFieldIndexes(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on a selection of field indexes- Parameters:
conversions
- the sequence of conversions to be applied- Returns:
- a selector of column indexes.
-
applyConversionsOnFieldNames
public FieldSet<java.lang.String> applyConversionsOnFieldNames(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on a selection of field name- Parameters:
conversions
- the sequence of conversions to be applied- Returns:
- a selector of column names.
-
applyConversionsOnFieldEnums
public FieldSet<java.lang.Enum> applyConversionsOnFieldEnums(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on a selection of enumerations that represent fields- Parameters:
conversions
- the sequence of conversions to be applied- Returns:
- a selector of enumerations.
-
executeValidations
public void executeValidations(int index, java.lang.Object value)
Applies any validations associated with a field at a given index in a record- Parameters:
index
- The index of parsed value in a recordvalue
- The value of the record at the given index
-
reverseConversions
public java.lang.Object reverseConversions(boolean executeInReverseOrder, int index, java.lang.Object value, boolean[] convertedFlags)
Applies a sequence of conversions associated with an Object value at a given index in a record.- Parameters:
executeInReverseOrder
- flag to indicate whether or not the conversion sequence must be executed in reverse orderindex
- The index of parsed value in a recordvalue
- The value in a recordconvertedFlags
- an array of flags that indicate whether a conversion occurred. Used to determine whether or not a default conversion by type (specified withConversionProcessor.convertType(Class, Conversion[])
) should be applied.- Returns:
- the Object resulting from a sequence of conversions against the original value.
-
applyConversions
public java.lang.Object applyConversions(int index, java.lang.String stringValue, boolean[] convertedFlags)
Applies a sequence of conversions associated with a String value parsed from a given index.- Parameters:
index
- The index of parsed value in a recordstringValue
- The parsed value in a recordconvertedFlags
- an array of flags that indicate whether a conversion occurred. Used to determine whether or not a default conversion by type (specified withConversionProcessor.convertType(Class, Conversion[])
) should be applied.- Returns:
- the Object produced by a sequence of conversions against the original String value.
-
getConversions
public Conversion[] getConversions(int index, java.lang.Class<?> expectedType)
Returns the sequence of conversions to be applied at a given column index- Parameters:
index
- the index of the column where the conversions should be executedexpectedType
- the type resulting from the conversion sequence.- Returns:
- the sequence of conversions to be applied at a given column index
-
clone
public FieldConversionMapping clone()
- Overrides:
clone
in classjava.lang.Object
-
-