Class RowWriterProcessorSwitch

  • All Implemented Interfaces:
    RowWriterProcessor<java.lang.Object>
    Direct Known Subclasses:
    OutputValueSwitch

    public abstract class RowWriterProcessorSwitch
    extends java.lang.Object
    implements RowWriterProcessor<java.lang.Object>
    A special RowWriterProcessor implementation that combines and allows switching among different RowWriterProcessors. Concrete implementations of this class are expected to implement the switchRowProcessor(T) method and analyze the input row to determine whether or not the current RowWriterProcessor implementation must be changed to handle a special circumstance (determined by the concrete implementation) such as a different row format. When the row writer processor is switched, the rowProcessorSwitched(RowWriterProcessor, RowWriterProcessor) will be called, and must be overridden, to notify the change to the user.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract java.lang.String describeSwitch()  
      protected java.lang.String[] getHeaders()
      Returns the headers in use by the current row writer processor implementation, which can vary among row writer processors.
      abstract java.lang.String[] getHeaders​(java.lang.Object input)
      Returns the sequence of headers to use for processing an input record.
      abstract java.lang.String[] getHeaders​(java.util.Map headerMapping, java.util.Map mapInput)
      Returns the sequence of headers to use for processing an input record represented by a map A map of headers can be optionally provided to assign a name to the keys of the input map.
      protected int[] getIndexes()
      Returns the indexes in use by the current row writer processor implementation, which can vary among row writer processors.
      int getMinimumRowLength()
      Returns the minimum row length based on the number of headers and index sizes
      void rowProcessorSwitched​(RowWriterProcessor<?> from, RowWriterProcessor<?> to)
      Notifies a change of row writer processor implementation.
      protected abstract RowWriterProcessor<?> switchRowProcessor​(java.lang.Object row)
      Analyzes an output row to determine whether or not the row writer processor implementation must be changed
      java.lang.Object[] write​(java.lang.Object input, java.lang.String[] headers, int[] indicesToWrite)
      Converts the given input into an Object array that is suitable for writing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RowWriterProcessorSwitch

        public RowWriterProcessorSwitch()
    • Method Detail

      • switchRowProcessor

        protected abstract RowWriterProcessor<?> switchRowProcessor​(java.lang.Object row)
        Analyzes an output row to determine whether or not the row writer processor implementation must be changed
        Parameters:
        row - a record with data to be written to the output
        Returns:
        the row writer processor implementation to use. If it is not the same as the one used by the previous row, the returned row writer processor will be used, and the rowProcessorSwitched(RowWriterProcessor, RowWriterProcessor) method will be called.
      • getHeaders

        protected java.lang.String[] getHeaders()
        Returns the headers in use by the current row writer processor implementation, which can vary among row writer processors. If null, the headers defined in CommonSettings.getHeaders() will be returned.
        Returns:
        the current sequence of headers to use.
      • rowProcessorSwitched

        public void rowProcessorSwitched​(RowWriterProcessor<?> from,
                                         RowWriterProcessor<?> to)
        Notifies a change of row writer processor implementation. Users are expected to override this method to receive the notification.
        Parameters:
        from - the row writer processor previously in use
        to - the new row writer processor to use to continue processing the output rows.
      • getHeaders

        public abstract java.lang.String[] getHeaders​(java.util.Map headerMapping,
                                                      java.util.Map mapInput)
        Returns the sequence of headers to use for processing an input record represented by a map A map of headers can be optionally provided to assign a name to the keys of the input map. This is useful when the input map has keys will generate unwanted header names.
        Parameters:
        headerMapping - an optional map associating keys of the rowData map with expected header names
        mapInput - the record data
        Returns:
        the sequence of headers to use when processing the given input map.
      • getHeaders

        public abstract java.lang.String[] getHeaders​(java.lang.Object input)
        Returns the sequence of headers to use for processing an input record.
        Parameters:
        input - the record data
        Returns:
        the sequence of headers to use when processing the given record.
      • describeSwitch

        protected abstract java.lang.String describeSwitch()
      • getMinimumRowLength

        public final int getMinimumRowLength()
        Returns the minimum row length based on the number of headers and index sizes
        Returns:
        the minimum length a row must have in order to be sent to the output