|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.common.processor.core.AbstractProcessorSwitch<T>
com.univocity.parsers.common.processor.core.AbstractInputValueSwitch<T>
public abstract class AbstractInputValueSwitch<T extends Context>
A concrete implementation of Processor that allows switching among different implementations of
Processor based on values found on the rows parsed from the input.
| Constructor Summary | |
|---|---|
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 |
|
AbstractInputValueSwitch(int columnIndex)
Creates a switch that will analyze a column of rows parsed from the input to determine which Processor to use. |
|
AbstractInputValueSwitch(String columnName)
Creates a switch that will analyze a column in rows parsed from the input to determine which Processor to use. |
|
| Method Summary | |
|---|---|
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. |
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. |
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. |
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. |
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. |
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. |
String[] |
getHeaders()
Returns the headers in use by the current row processor implementation, which can vary among row processors. |
int[] |
getIndexes()
Returns the indexes in use by the current row processor implementation, which can vary among row processors. |
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. |
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. |
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. |
void |
setDefaultSwitch(Processor<T> processor)
Defines a default Processor implementation to use when no matching value is found in the input row. |
void |
setDefaultSwitch(Processor<T> processor,
int... indexesToUse)
Defines a default Processor implementation to use when no matching value is found in the input row. |
void |
setDefaultSwitch(Processor<T> processor,
String... headersToUse)
Defines a default Processor implementation to use when no matching value is found in the input row. |
protected Processor<T> |
switchRowProcessor(String[] row,
T context)
Analyzes the input to determine whether or not the row processor implementation must be changed |
| Methods inherited from class com.univocity.parsers.common.processor.core.AbstractProcessorSwitch |
|---|
preventColumnReordering, processEnded, processorSwitched, processStarted, rowProcessed, rowProcessorSwitched |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractInputValueSwitch()
Processor to use for each parsed row
public AbstractInputValueSwitch(int columnIndex)
Processor to use.
columnIndex - the column index whose value will be used to determine which Processor to use for each parsed row.public AbstractInputValueSwitch(String columnName)
Processor to use.
columnName - name of the column whose values will be used to determine which Processor to use for each parsed row.| Method Detail |
|---|
public void setCaseSensitive(boolean caseSensitive)
addSwitchForValue(String, Processor, String...)
with the column given in the constructor of this class.
caseSensitive - a flag indicating whether the switch should compare values not considering the character case.public void setComparator(Comparator<String> comparator)
Comparator to compare values in the column to analyze which is given in the constructor of this class.
comparator - the comparator to use for matching values in the input column with the values provided in addSwitchForValue(String, Processor, String...)
public void setDefaultSwitch(Processor<T> processor,
String... headersToUse)
Processor implementation to use when no matching value is found in the input row.
processor - the default processor implementationheadersToUse - the (optional) sequence of headers to assign to the ParsingContext of the given processorpublic void setDefaultSwitch(Processor<T> processor)
Processor implementation to use when no matching value is found in the input row.
processor - the default processor implementation
public void setDefaultSwitch(Processor<T> processor,
int... indexesToUse)
Processor implementation to use when no matching value is found in the input row.
processor - the default processor implementationindexesToUse - the (optional) sequence of column indexes to assign to the ParsingContext of the given processorpublic boolean hasDefaultSwitch()
Processor implementation to use when no matching value is found in the input row.
true if a Processor implementation has been provided to process input rows that doesn't have any matching value.
public void addSwitchForValue(String value,
Processor<T> processor)
Processor implementation with an expected value to be matched in the column provided in the constructor of this class.
value - the value to match against the column of the current input row and trigger the usage of the given processor implementation.processor - the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.
public void addSwitchForValue(String value,
Processor<T> processor,
String... headersToUse)
Processor implementation with an expected value to be matched in the column provided in the constructor of this class.
value - the value to match against the column of the current input row and trigger the usage of the given processor implementation.processor - the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.headersToUse - the (optional) sequence of headers to assign to the ParsingContext of the given processor
public void addSwitchForValue(CustomMatcher matcher,
Processor<T> processor)
Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.
matcher - 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 - the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.
public void addSwitchForValue(CustomMatcher matcher,
Processor<T> processor,
String... headersToUse)
Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.
matcher - 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 - the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.headersToUse - the (optional) sequence of headers to assign to the ParsingContext of the given processor
public void addSwitchForValue(String value,
Processor<T> processor,
int... indexesToUse)
Processor implementation with an expected value to be matched in the column provided in the constructor of this class.
value - the value to match against the column of the current input row and trigger the usage of the given processor implementation.processor - the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.indexesToUse - the (optional) sequence of column indexes to assign to the ParsingContext of the given processor
public void addSwitchForValue(CustomMatcher matcher,
Processor<T> processor,
int... indexesToUse)
Processor implementation with a custom matching algorithm to be executed in the column provided in the constructor of this class.
matcher - 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 - the processor implementation when the given value matches with the contents in the column provided in the constructor of this class.indexesToUse - the (optional) sequence of column indexes to assign to the ParsingContext of the given processorpublic String[] getHeaders()
AbstractProcessorSwitchnull, the headers parsed by the input, or defined in CommonSettings.getHeaders() will be returned.
getHeaders in class AbstractProcessorSwitch<T extends Context>public int[] getIndexes()
AbstractProcessorSwitchnull all columns of a given record will be considered.
getIndexes in class AbstractProcessorSwitch<T extends Context>
protected Processor<T> switchRowProcessor(String[] row,
T context)
AbstractProcessorSwitch
switchRowProcessor in class AbstractProcessorSwitch<T extends Context>row - a row parsed from the inputcontext - the current parsing context (not associated with the current row processor used by this class)
AbstractProcessorSwitch.processorSwitched(Processor, Processor) method
will be called.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||