Class AbstractMultiBeanProcessor<C extends Context>

    • Constructor Detail

      • AbstractMultiBeanProcessor

        public AbstractMultiBeanProcessor​(java.lang.Class... beanTypes)
        Creates a processor for java beans of multiple types
        Parameters:
        beanTypes - the classes with their attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.
    • Method Detail

      • getBeanClasses

        public final java.lang.Class[] getBeanClasses()
      • getProcessorOfType

        public <T> AbstractBeanProcessor<T,​C> getProcessorOfType​(java.lang.Class<T> type)
        Returns the BeanProcessor responsible for processing a given class
        Type Parameters:
        T - the type of java bean being processed
        Parameters:
        type - the type of java bean being processed
        Returns:
        the BeanProcessor that handles java beans of the given class.
      • beanProcessed

        public abstract void beanProcessed​(java.lang.Class<?> beanType,
                                           java.lang.Object beanInstance,
                                           C context)
        Invoked by the processor after all values of a valid record have been processed and converted into a java object.
        Parameters:
        beanType - the type of the object created by the parser using the information collected for an individual record.
        beanInstance - java object created with the information extracted by the parser for an individual record.
        context - A contextual object with information and controls over the current state of the parsing process
      • processStarted

        public void processStarted​(C context)
        Description copied from interface: Processor
        This method will by invoked by the parser once, when it is ready to start processing the input.
        Specified by:
        processStarted in interface Processor<C extends Context>
        Parameters:
        context - A contextual object with information and controls over the current state of the parsing process
      • rowProcessed

        public final void rowProcessed​(java.lang.String[] row,
                                       C context)
        Description copied from interface: Processor
        Invoked by the parser after all values of a valid record have been processed.
        Specified by:
        rowProcessed in interface Processor<C extends Context>
        Parameters:
        row - the data extracted by the parser for an individual record. Note that:
        context - A contextual object with information and controls over the current state of the parsing process
      • processEnded

        public void processEnded​(C context)
        Description copied from interface: Processor
        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 Context.stop().

        Specified by:
        processEnded in interface Processor<C extends Context>
        Parameters:
        context - A contextual object with information and controls over the state of the parsing process
      • convertIndexes

        public FieldSet<java.lang.Integer> convertIndexes​(Conversion... conversions)
        Description copied from interface: ConversionProcessor
        Applies a set of Conversion objects over indexes of a record.

        The idiom to define which indexes should have these conversions applies is as follows:


        
         processor.convertIndexes(Conversions.trim(), Conversions.toUpperCase()).add(2, 5); // applies trim and uppercase conversions to fields in indexes 2 and 5
         

        Specified by:
        convertIndexes in interface ConversionProcessor
        Parameters:
        conversions - The sequence of conversions to be executed in a set of field indexes.
        Returns:
        A FieldSet for indexes.
      • convertAll

        public void convertAll​(Conversion... conversions)
        Description copied from interface: ConversionProcessor
        Applies a set of Conversion objects over all elements of a record
        Specified by:
        convertAll in interface ConversionProcessor
        Parameters:
        conversions - The sequence of conversions to be executed in all elements of a record
      • convertFields

        public FieldSet<java.lang.String> convertFields​(Conversion... conversions)
        Description copied from interface: ConversionProcessor
        Applies a set of Conversion objects over fields of a record by name.

        The idiom to define which fields should have these conversions applied is as follows:


        
         processor.convertFields(Conversions.trim(), Conversions.toUpperCase()).add("name", "position"); // applies trim and uppercase conversions to fields with headers "name" and "position"
         

        Specified by:
        convertFields in interface ConversionProcessor
        Parameters:
        conversions - The sequence of conversions to be executed in a set of field indexes.
        Returns:
        A FieldSet for field names.
      • convertType

        public void convertType​(java.lang.Class<?> type,
                                Conversion... conversions)
        Description copied from interface: ConversionProcessor
        Applies a sequence of conversions over values of a given type. Used for writing.
        Specified by:
        convertType in interface ConversionProcessor
        Parameters:
        type - the type over which a sequence of conversions should be applied
        conversions - the sequence of conversions to apply over values of the given type.