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.
| Modifier and Type | Field and Description |
|---|---|
| private T | |
| private Map | |
| private Processor |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String[] | Returns: the current sequence of headers to use.Returns the headers in use by the current row processor implementation, which can vary among row processors. |
| public int[] | Returns: the current sequence of indexes to use.Returns the indexes in use by the current row processor implementation, which can vary among row processors. |
| public boolean | preventColumnReordering()
Implements com. |
| public void | processEnded(T
A contextual object with information and controls over the state of the parsing process context)Implements com. |
| public void | processorSwitched(Processor<T>
the processor previously in use from, Processor<T> the new processor to use to continue processing the input. to)Notifies a change of |
| public void | processStarted(T
A contextual object with information and controls over the current state of the parsing process context)Implements com. |
| public final void | rowProcessed(String[]
the data extracted by the parser for an individual record. Note that:
row, final T
A contextual object with information and controls over the current state of the parsing process context)Implements com. |
| public void | rowProcessorSwitched(RowProcessor
the row processor previously in use from, RowProcessor the new row processor to use to continue processing the input. to)Notifies a change of |
| protected abstract Processor | Returns: 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 theprocessorSwitched(Processor, Processor) method
will be called.a row parsed from the input row, T the current parsing context (not associated with the current row processor used by this class) context)Analyzes the input to determine whether or not the row processor implementation must be changed |
| protected abstract T | Returns: a wrapped context that returns the headers and extracted field indexes fromgetHeaders() and getIndexes()the context to wrap context)Wraps a given parser context object that returns headers and extracted field indexes associated with a given processor in this switch. |
| contextForProcessor | back to summary |
|---|---|
| private T contextForProcessor | |
| processors | back to summary |
|---|---|
| private Map<Processor<T extends Context>, T> processors | |
| selectedProcessor | back to summary |
|---|---|
| private Processor<T extends Context> selectedProcessor | |
| AbstractProcessorSwitch | back to summary |
|---|---|
| public AbstractProcessorSwitch() | |
| getHeaders | back to summary |
|---|---|
| public String[] getHeaders() Returns the headers in use by the current row processor implementation, which can vary among row processors.
If
| |
| getIndexes | back to summary |
|---|---|
| public int[] getIndexes() Returns the indexes in use by the current row processor implementation, which can vary among row processors.
If
| |
| preventColumnReordering | back to summary |
|---|---|
| public boolean preventColumnReordering() Implements com. Doc from com. Returns a flag indicating whether or not columns should be reordered by the parser
| |
| processEnded | back to summary |
|---|---|
| public void processEnded(T context) Implements com. Doc from com. This method will by invoked by the parser once, after the parsing process stopped and all resources were closed. 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
| |
| processorSwitched | back to summary |
|---|---|
| public void processorSwitched(Processor<T> from, Processor<T> to) Notifies a change of | |
| processStarted | back to summary |
|---|---|
| public void processStarted(T context) Implements com. Doc from com. This method will by invoked by the parser once, when it is ready to start processing the input.
| |
| rowProcessed | back to summary |
|---|---|
| public final void rowProcessed(String[] row, final T context) Implements com. Doc from com. Invoked by the parser after all values of a valid record have been processed.
| |
| rowProcessorSwitched | back to summary |
|---|---|
| public void rowProcessorSwitched(RowProcessor from, RowProcessor to) Notifies a change of
| |
| switchRowProcessor | back to summary |
|---|---|
| protected abstract Processor Analyzes the input to determine whether or not the row processor implementation must be changed
| |
| wrapContext | back to summary |
|---|---|
| protected abstract T wrapContext(T context) Wraps a given parser context object that returns headers and extracted field indexes associated with a given processor in this switch.
| |