public class FieldConversionMapping
extends java.lang.Object
implements java.lang.Cloneable
Conversion objects| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.Integer,java.util.List<Conversion<?,?>>> |
conversionsByIndex
This is the final sequence of conversions applied to each index in a record.
|
private java.util.List<FieldSelector> |
conversionSequence
This list contains the sequence of conversions applied to sets of fields over multiple calls.
|
private AbstractConversionMapping<java.lang.Integer> |
convertAllMapping |
private static Conversion[] |
EMPTY_CONVERSION_ARRAY |
private AbstractConversionMapping<java.lang.Enum> |
fieldEnumConversionMapping |
private AbstractConversionMapping<java.lang.Integer> |
fieldIndexConversionMapping |
private AbstractConversionMapping<java.lang.String> |
fieldNameConversionMapping |
int[] |
validatedIndexes |
private java.util.Map<java.lang.Integer,java.util.List<ValidatedConversion>> |
validationsByIndex |
| Constructor and Description |
|---|
FieldConversionMapping() |
| Modifier and Type | Method and 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 fields
|
FieldSet<java.lang.Integer> |
applyConversionsOnFieldIndexes(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on a selection of field indexes
|
FieldSet<java.lang.String> |
applyConversionsOnFieldNames(Conversion<java.lang.String,?>... conversions)
Applies a sequence of conversions on a selection of field name
|
FieldConversionMapping |
clone() |
void |
executeValidations(int index,
java.lang.Object value)
Applies any validations associated with a field at a given index in a record
|
Conversion[] |
getConversions(int index,
java.lang.Class<?> expectedType)
Returns the sequence of conversions to be applied at a given column index
|
void |
prepareExecution(boolean writing,
java.lang.String[] values)
Prepares the conversions registered in this object to be executed against a given sequence of fields
|
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.
|
private static final Conversion[] EMPTY_CONVERSION_ARRAY
public int[] validatedIndexes
private java.util.List<FieldSelector> conversionSequence
It is shared by fieldNameConversionMapping, fieldIndexConversionMapping and convertAllMapping.
Every time the user associates a sequence of conversions to a field, conversionSequence list will receive the FieldSelector.
private AbstractConversionMapping<java.lang.String> fieldNameConversionMapping
private AbstractConversionMapping<java.lang.Integer> fieldIndexConversionMapping
private AbstractConversionMapping<java.lang.Enum> fieldEnumConversionMapping
private AbstractConversionMapping<java.lang.Integer> convertAllMapping
private java.util.Map<java.lang.Integer,java.util.List<Conversion<?,?>>> conversionsByIndex
prepareExecution(boolean, String[]) is invoked.private java.util.Map<java.lang.Integer,java.util.List<ValidatedConversion>> validationsByIndex
public void prepareExecution(boolean writing,
java.lang.String[] values)
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).
public void applyConversionsOnAllFields(Conversion<java.lang.String,?>... conversions)
conversions - the sequence of conversions to be appliedpublic FieldSet<java.lang.Integer> applyConversionsOnFieldIndexes(Conversion<java.lang.String,?>... conversions)
conversions - the sequence of conversions to be appliedpublic FieldSet<java.lang.String> applyConversionsOnFieldNames(Conversion<java.lang.String,?>... conversions)
conversions - the sequence of conversions to be appliedpublic FieldSet<java.lang.Enum> applyConversionsOnFieldEnums(Conversion<java.lang.String,?>... conversions)
conversions - the sequence of conversions to be appliedpublic void executeValidations(int index,
java.lang.Object value)
index - The index of parsed value in a recordvalue - The value of the record at the given indexpublic java.lang.Object reverseConversions(boolean executeInReverseOrder,
int index,
java.lang.Object value,
boolean[] convertedFlags)
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 with ConversionProcessor.convertType(Class, Conversion[])) should be applied.public java.lang.Object applyConversions(int index,
java.lang.String stringValue,
boolean[] convertedFlags)
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 with ConversionProcessor.convertType(Class, Conversion[])) should be applied.public Conversion[] getConversions(int index, java.lang.Class<?> expectedType)
index - the index of the column where the conversions should be executedexpectedType - the type resulting from the conversion sequence.public FieldConversionMapping clone()
clone in class java.lang.Object