Top Description Inners Fields Constructors Methods
com.univocity.parsers.common.processor.core

public abstract Class AbstractInputValueSwitch<T extends Context>

extends AbstractProcessorSwitch<T extends Context>
Class Inheritance
Known Direct Subclasses
com.univocity.parsers.common.processor.InputValueSwitch
Imports
com.univocity.parsers.common.*, com.univocity.parsers.common.processor.*, java.util.*

A concrete implementation of Processor that allows switching among different implementations of Processor based on values found on the rows parsed from the input.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final Comparator<String>
private static final Comparator<String>
private int
private NormalizedString
private Comparator<String>
private AbstractInputValueSwitch.Switch<T extends Context>
private String[]
private int[]
private AbstractInputValueSwitch.Switch<T extends Context>[]

Constructor Summary

AccessConstructor and Description
public
AbstractInputValueSwitch()

Creates a switch that will analyze the first column of rows found in the input to determine which Processor to use for each parsed row

public
AbstractInputValueSwitch(int
the column index whose value will be used to determine which Processor to use for each parsed row.
columnIndex
)

Creates a switch that will analyze a column of rows parsed from the input to determine which Processor to use.

public
AbstractInputValueSwitch(String
name of the column whose values will be used to determine which Processor to use for each parsed row.
columnName
)

Creates a switch that will analyze a column in rows parsed from the input to determine which Processor to use.

Method Summary

Modifier and TypeMethod and Description
public void
addSwitchForValue(String
the value to match against the column of the current input row and trigger the usage of the given processor implementation.
value
,
Processor<T>
the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.
processor
)

Associates a Processor implementation with an expected value to be matched in the column provided in the constructor of this class.

public void
addSwitchForValue(String
the value to match against the column of the current input row and trigger the usage of the given processor implementation.
value
,
Processor<T>
the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.
processor
,
String...
the (optional) sequence of headers to assign to the ParsingContext of the given processor
headersToUse
)

Associates a Processor implementation with an expected value to be matched in the column provided in the constructor of this class.

public void
addSwitchForValue(CustomMatcher
a user defined matching implementation to execute against the values in the column of the current input row and trigger the usage of the given processor implementation.
matcher
,
Processor<T>
the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.
processor
)

Associates a Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.

public void
addSwitchForValue(CustomMatcher
a user defined matching implementation to execute against the values in the column of the current input row and trigger the usage of the given processor implementation.
matcher
,
Processor<T>
the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.
processor
,
String...
the (optional) sequence of headers to assign to the ParsingContext of the given processor
headersToUse
)

Associates a Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.

public void
addSwitchForValue(String
the value to match against the column of the current input row and trigger the usage of the given processor implementation.
value
,
Processor<T>
the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.
processor
,
int...
the (optional) sequence of column indexes to assign to the ParsingContext of the given processor
indexesToUse
)

Associates a Processor implementation with an expected value to be matched in the column provided in the constructor of this class.

public void
addSwitchForValue(CustomMatcher
a user defined matching implementation to execute against the values in the column of the current input row and trigger the usage of the given processor implementation.
matcher
,
Processor<T>
the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.
processor
,
int...
the (optional) sequence of column indexes to assign to the ParsingContext of the given processor
indexesToUse
)

Associates a Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.

public String[]
getHeaders()

Overrides com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.getHeaders.

Returns the headers in use by the current row processor implementation, which can vary among row processors.
public int[]
getIndexes()

Overrides com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.getIndexes.

Returns the indexes in use by the current row processor implementation, which can vary among row processors.
public boolean

Returns:

true if a Processor implementation has been provided to process input rows that doesn't have any matching value.
hasDefaultSwitch
()

Returns a flag indicating whether this switch contains a default Processor implementation to use when no matching value is found in the input row.

public void
setCaseSensitive(boolean
a flag indicating whether the switch should compare values not considering the character case.
caseSensitive
)

Configures the switch to be case sensitive when comparing values provided in addSwitchForValue(String, Processor, String...) with the column given in the constructor of this class.

public void
setComparator(Comparator<String>
the comparator to use for matching values in the input column with the values provided in addSwitchForValue(String, Processor, String...)
comparator
)

Configures the switch to use a custom Comparator to compare values in the column to analyze which is given in the constructor of this class.

public void
setDefaultSwitch(Processor<T>
the default processor implementation
processor
,
String...
the (optional) sequence of headers to assign to the ParsingContext of the given processor
headersToUse
)

Defines a default Processor implementation to use when no matching value is found in the input row.

public void
setDefaultSwitch(Processor<T>
the default processor implementation
processor
)

Defines a default Processor implementation to use when no matching value is found in the input row.

public void
setDefaultSwitch(Processor<T>
the default processor implementation
processor
,
int...
the (optional) sequence of column indexes to assign to the ParsingContext of the given processor
indexesToUse
)

Defines a default Processor implementation to use when no matching value is found in the input row.

protected final Processor<T>
switchRowProcessor(String[]
a row parsed from the input
row
,
T
the current parsing context (not associated with the current row processor used by this class)
context
)

Implements abstract com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.switchRowProcessor.

Analyzes the input to determine whether or not the row processor implementation must be changed
Inherited from com.univocity.parsers.common.processor.core.AbstractProcessorSwitch:
preventColumnReorderingprocessEndedprocessorSwitchedprocessStartedrowProcessedrowProcessorSwitchedwrapContext

Field Detail

caseInsensitiveComparatorback to summary
private static final Comparator<String> caseInsensitiveComparator
caseSensitiveComparatorback to summary
private static final Comparator<String> caseSensitiveComparator
columnIndexback to summary
private int columnIndex
columnNameback to summary
private NormalizedString columnName
comparatorback to summary
private Comparator<String> comparator
defaultSwitchback to summary
private AbstractInputValueSwitch.Switch<T extends Context> defaultSwitch
headersback to summary
private String[] headers
indexesback to summary
private int[] indexes
switchesback to summary
private AbstractInputValueSwitch.Switch<T extends Context>[] switches

Constructor Detail

AbstractInputValueSwitchback to summary
public AbstractInputValueSwitch()

Creates a switch that will analyze the first column of rows found in the input to determine which Processor to use for each parsed row

AbstractInputValueSwitchback to summary
public AbstractInputValueSwitch(int columnIndex)

Creates a switch that will analyze a column of rows parsed from the input to determine which Processor to use.

Parameters
columnIndex:int

the column index whose value will be used to determine which Processor to use for each parsed row.

AbstractInputValueSwitchback to summary
public AbstractInputValueSwitch(String columnName)

Creates a switch that will analyze a column in rows parsed from the input to determine which Processor to use.

Parameters
columnName:String

name of the column whose values will be used to determine which Processor to use for each parsed row.

Method Detail

addSwitchForValueback to summary
public void addSwitchForValue(String value, Processor<T> processor)

Associates a Processor implementation with an expected value to be matched in the column provided in the constructor of this class.

Parameters
value:String

the value to match against the column of the current input row and trigger the usage of the given processor implementation.

processor:Processor<T>

the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.

addSwitchForValueback to summary
public void addSwitchForValue(String value, Processor<T> processor, String... headersToUse)

Associates a Processor implementation with an expected value to be matched in the column provided in the constructor of this class.

Parameters
value:String

the value to match against the column of the current input row and trigger the usage of the given processor implementation.

processor:Processor<T>

the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.

headersToUse:String[]

the (optional) sequence of headers to assign to the ParsingContext of the given processor

addSwitchForValueback to summary
public void addSwitchForValue(CustomMatcher matcher, Processor<T> processor)

Associates a Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.

Parameters
matcher:CustomMatcher

a user defined matching implementation to execute against the values in the column of the current input row and trigger the usage of the given processor implementation.

processor:Processor<T>

the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.

addSwitchForValueback to summary
public void addSwitchForValue(CustomMatcher matcher, Processor<T> processor, String... headersToUse)

Associates a Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.

Parameters
matcher:CustomMatcher

a user defined matching implementation to execute against the values in the column of the current input row and trigger the usage of the given processor implementation.

processor:Processor<T>

the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.

headersToUse:String[]

the (optional) sequence of headers to assign to the ParsingContext of the given processor

addSwitchForValueback to summary
public void addSwitchForValue(String value, Processor<T> processor, int... indexesToUse)

Associates a Processor implementation with an expected value to be matched in the column provided in the constructor of this class.

Parameters
value:String

the value to match against the column of the current input row and trigger the usage of the given processor implementation.

processor:Processor<T>

the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.

indexesToUse:int[]

the (optional) sequence of column indexes to assign to the ParsingContext of the given processor

addSwitchForValueback to summary
public void addSwitchForValue(CustomMatcher matcher, Processor<T> processor, int... indexesToUse)

Associates a Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.

Parameters
matcher:CustomMatcher

a user defined matching implementation to execute against the values in the column of the current input row and trigger the usage of the given processor implementation.

processor:Processor<T>

the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.

indexesToUse:int[]

the (optional) sequence of column indexes to assign to the ParsingContext of the given processor

getHeadersback to summary
public String[] getHeaders()

Overrides com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.getHeaders.

Doc from com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.getHeaders.

Returns the headers in use by the current row processor implementation, which can vary among row processors. If null, the headers parsed by the input, or defined in CommonParserSettings#getHeaders() will be returned.

Returns:String[]

the current sequence of headers to use.

Annotations
@Override
getIndexesback to summary
public int[] getIndexes()

Overrides com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.getIndexes.

Doc from com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.getIndexes.

Returns the indexes in use by the current row processor implementation, which can vary among row processors. If null all columns of a given record will be considered.

Returns:int[]

the current sequence of indexes to use.

Annotations
@Override
hasDefaultSwitchback to summary
public boolean hasDefaultSwitch()

Returns a flag indicating whether this switch contains a default Processor implementation to use when no matching value is found in the input row.

Returns:boolean

true if a Processor implementation has been provided to process input rows that doesn't have any matching value.

setCaseSensitiveback to summary
public void setCaseSensitive(boolean caseSensitive)

Configures the switch to be case sensitive when comparing values provided in addSwitchForValue(String, Processor, String...) with the column given in the constructor of this class.

Parameters
caseSensitive:boolean

a flag indicating whether the switch should compare values not considering the character case.

setComparatorback to summary
public void setComparator(Comparator<String> comparator)

Configures the switch to use a custom Comparator to compare values in the column to analyze which is given in the constructor of this class.

Parameters
comparator:Comparator<String>

the comparator to use for matching values in the input column with the values provided in addSwitchForValue(String, Processor, String...)

setDefaultSwitchback to summary
public void setDefaultSwitch(Processor<T> processor, String... headersToUse)

Defines a default Processor implementation to use when no matching value is found in the input row.

Parameters
processor:Processor<T>

the default processor implementation

headersToUse:String[]

the (optional) sequence of headers to assign to the ParsingContext of the given processor

setDefaultSwitchback to summary
public void setDefaultSwitch(Processor<T> processor)

Defines a default Processor implementation to use when no matching value is found in the input row.

Parameters
processor:Processor<T>

the default processor implementation

setDefaultSwitchback to summary
public void setDefaultSwitch(Processor<T> processor, int... indexesToUse)

Defines a default Processor implementation to use when no matching value is found in the input row.

Parameters
processor:Processor<T>

the default processor implementation

indexesToUse:int[]

the (optional) sequence of column indexes to assign to the ParsingContext of the given processor

switchRowProcessorback to summary
protected final Processor<T> switchRowProcessor(String[] row, T context)

Implements abstract com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.switchRowProcessor.

Doc from com.univocity.parsers.common.processor.core.AbstractProcessorSwitch.switchRowProcessor.

Analyzes the input to determine whether or not the row processor implementation must be changed

Parameters
row:String[]

a row parsed from the input

context:T

the current parsing context (not associated with the current row processor used by this class)

Returns:Processor<T>

the row processor implementation to use. If it is not the same as the one used by the previous row, the returned row processor will be used, and the processorSwitched(Processor, Processor) method will be called.

Annotations
@Override
com.univocity.parsers.common.processor.core back to summary

private Class AbstractInputValueSwitch.Switch<T extends Context>

extends Object
Class Inheritance
  • java.lang.Object
  • com.univocity.parsers.common.processor.core.AbstractInputValueSwitch.Switch

Field Summary

Modifier and TypeField and Description
pack-priv final String[]
pack-priv final int[]
pack-priv final CustomMatcher
pack-priv final Processor<T>
pack-priv final String

Constructor Summary

AccessConstructor and Description
pack-priv
Switch(Processor<T> processor, String[] headers, int[] indexes, String value, CustomMatcher matcher)

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

headersback to summary
pack-priv final String[] headers
indexesback to summary
pack-priv final int[] indexes
matcherback to summary
pack-priv final CustomMatcher matcher
processorback to summary
pack-priv final Processor<T> processor
valueback to summary
pack-priv final String value

Constructor Detail

Switchback to summary
pack-priv Switch(Processor<T> processor, String[] headers, int[] indexes, String value, CustomMatcher matcher)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override