|
||||||||||
| 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>
public abstract class AbstractProcessorSwitch<T extends Context>
A special Processor implementation that combines and allows switching among different
Processors. Each Processor will have its own Context. Concrete implementations of this class
are expected to implement the switchRowProcessor(String[], Context) method and analyze the input row
to determine whether or not the current Processor implementation must be changed to handle a special
circumstance (determined by the concrete implementation) such as a different row format.
When the processor is switched, the processorSwitched(Processor, Processor) will be called, and
must be overridden, to notify the change to the user.
| Constructor Summary | |
|---|---|
AbstractProcessorSwitch()
|
|
| Method Summary | |
|---|---|
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 |
preventColumnReordering()
Returns a flag indicating whether or not columns should be reordered by the parser |
void |
processEnded(T context)
This method will by invoked by the parser once, after the parsing process stopped and all resources were closed. |
void |
processorSwitched(Processor<T> from,
Processor<T> to)
Notifies a change of Processor implementation. |
void |
processStarted(T context)
This method will by invoked by the parser once, when it is ready to start processing the input. |
void |
rowProcessed(String[] row,
T context)
Invoked by the parser after all values of a valid record have been processed. |
void |
rowProcessorSwitched(RowProcessor from,
RowProcessor to)
Notifies a change of RowProcessor implementation. |
protected abstract 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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractProcessorSwitch()
| Method Detail |
|---|
protected abstract Processor<T> switchRowProcessor(String[] row,
T context)
row - a row parsed from the inputcontext - the current parsing context (not associated with the current row processor used by this class)
processorSwitched(Processor, Processor) method
will be called.public String[] getHeaders()
null, the headers parsed by the input, or defined in CommonSettings.getHeaders() will be returned.
public int[] getIndexes()
null all columns of a given record will be considered.
public void processorSwitched(Processor<T> from,
Processor<T> to)
Processor implementation. Users are expected to override this method to receive the notification.
from - the processor previously in useto - the new processor to use to continue processing the input.
public void rowProcessorSwitched(RowProcessor from,
RowProcessor to)
RowProcessor implementation. Users are expected to override this method to receive the notification.
from - the row processor previously in useto - the new row processor to use to continue processing the input.public void processStarted(T context)
Processor
processStarted in interface Processor<T extends Context>context - A contextual object with information and controls over the current state of the parsing process
public final void rowProcessed(String[] row,
T context)
Processor
rowProcessed in interface Processor<T extends Context>row - the data extracted by the parser for an individual record. Note that:
CommonSettings.setSkipEmptyLines(boolean)Format.setComment(char) to '\0'context - A contextual object with information and controls over the current state of the parsing processpublic void processEnded(T context)
Processor It will always be called by the parser: in case of errors, if the end of the input us reached, or if the user stopped the process manually using Context.stop().
processEnded in interface Processor<T extends Context>context - A contextual object with information and controls over the state of the parsing processpublic boolean preventColumnReordering()
ColumnOrderDependent
preventColumnReordering in interface ColumnOrderDependent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||