com.univocity.parsers.common.fields
Class FieldConversionMapping

java.lang.Object
  extended by com.univocity.parsers.common.fields.FieldConversionMapping

public class FieldConversionMapping
extends Object

A class for mapping field selections to sequences of Conversion objects

Author:
uniVocity Software Pty Ltd - parsers@univocity.com

Constructor Summary
FieldConversionMapping()
           
 
Method Summary
 Object applyConversions(int index, String stringValue, boolean[] convertedFlags)
          Applies a sequence of conversions associated with a String value parsed from a given index.
 void applyConversionsOnAllFields(Conversion<String,?>... conversions)
          Applies a sequence of conversions on all fields.
 FieldSet<Enum> applyConversionsOnFieldEnums(Conversion<String,?>... conversions)
          Applies a sequence of conversions on a selection of enumerations that represent fields
 FieldSet<Integer> applyConversionsOnFieldIndexes(Conversion<String,?>... conversions)
          Applies a sequence of conversions on a selection of field indexes
 FieldSet<String> applyConversionsOnFieldNames(Conversion<String,?>... conversions)
          Applies a sequence of conversions on a selection of field name
 Conversion[] getConversions(int index, Class<?> expectedType)
          Returns the sequence of conversions to be applied at a given column index
 void prepareExecution(boolean writing, String[] values)
          Prepares the conversions registered in this object to be executed against a given sequence of fields
 Object reverseConversions(boolean executeInReverseOrder, int index, Object value, boolean[] convertedFlags)
          Applies a sequence of conversions associated with an Object value at a given index in a record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldConversionMapping

public FieldConversionMapping()
Method Detail

prepareExecution

public void prepareExecution(boolean writing,
                             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<String,?>... conversions)
Applies a sequence of conversions on all fields.

Parameters:
conversions - the sequence of conversions to be applied

applyConversionsOnFieldIndexes

public FieldSet<Integer> applyConversionsOnFieldIndexes(Conversion<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<String> applyConversionsOnFieldNames(Conversion<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<Enum> applyConversionsOnFieldEnums(Conversion<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.

reverseConversions

public Object reverseConversions(boolean executeInReverseOrder,
                                 int index,
                                 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 order
index - The index of parsed value in a record
value - The value in a record
convertedFlags - 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.
Returns:
the Object resulting from a sequence of conversions against the original value.

applyConversions

public Object applyConversions(int index,
                               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 record
stringValue - The parsed value in a record
convertedFlags - 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.
Returns:
the Object produced by a sequence of conversions against the original String value.

getConversions

public Conversion[] getConversions(int index,
                                   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 executed
expectedType - the type resulting from the conversion sequence.
Returns:
the sequence of conversions to be applied at a given column index


Copyright © 2017 uniVocity Software Pty Ltd. All rights reserved.