Class AbstractMultiBeanListProcessor<C extends Context>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List[] beans  
      private java.lang.Class[] beanTypes  
      private int expectedBeanCount  
      private java.lang.String[] headers  
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractMultiBeanListProcessor​(int expectedBeanCount, java.lang.Class... beanTypes)
      Creates a processor for java beans of multiple types
      AbstractMultiBeanListProcessor​(java.lang.Class... beanTypes)
      Creates a processor for java beans of multiple types
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.Class<?>,​java.util.List<?>> getBeans()
      Returns a map of all beans processed from the input.
      <T> java.util.List<T> getBeans​(java.lang.Class<T> beanType)
      Returns the beans of a given type processed from the input.
      java.lang.String[] getHeaders()
      Returns the record headers.
      void processEnded​(C context)
      This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.
      void processStarted​(C context)
      This method will by invoked by the parser once, when it is ready to start processing the input.
      protected void rowProcessed​(java.util.Map<java.lang.Class<?>,​java.lang.Object> row, C context)
      Invoked by the processor after all beans of a valid record have been processed.
      • Methods inherited from class java.lang.Object

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

      • beanTypes

        private final java.lang.Class[] beanTypes
      • beans

        private final java.util.List[] beans
      • headers

        private java.lang.String[] headers
      • expectedBeanCount

        private final int expectedBeanCount
    • Constructor Detail

      • AbstractMultiBeanListProcessor

        public AbstractMultiBeanListProcessor​(int expectedBeanCount,
                                              java.lang.Class... beanTypes)
        Creates a processor for java beans of multiple types
        Parameters:
        expectedBeanCount - expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List returned by getBeans()
        beanTypes - the classes with their attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.
      • AbstractMultiBeanListProcessor

        public AbstractMultiBeanListProcessor​(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

      • processStarted

        public final 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>
        Overrides:
        processStarted in class AbstractMultiBeanRowProcessor<C extends Context>
        Parameters:
        context - A contextual object with information and controls over the current state of the parsing process
      • rowProcessed

        protected final void rowProcessed​(java.util.Map<java.lang.Class<?>,​java.lang.Object> row,
                                          C context)
        Description copied from class: AbstractMultiBeanRowProcessor
        Invoked by the processor after all beans of a valid record have been processed.
        Specified by:
        rowProcessed in class AbstractMultiBeanRowProcessor<C extends Context>
        Parameters:
        row - a map containing all object instances generated from an input row. The map is reused internally. Make a copy if you want to keep the map.
        context - A contextual object with information and controls over the current state of the parsing process
      • processEnded

        public final 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>
        Overrides:
        processEnded in class AbstractMultiBeanRowProcessor<C extends Context>
        Parameters:
        context - A contextual object with information and controls over the state of the parsing process
      • getHeaders

        public final java.lang.String[] getHeaders()
        Returns the record headers. This can be either the headers defined in CommonSettings.getHeaders() or the headers parsed in the file when CommonSettings.getHeaders() equals true
        Returns:
        the headers of all records parsed.
      • getBeans

        public <T> java.util.List<T> getBeans​(java.lang.Class<T> beanType)
        Returns the beans of a given type processed from the input.
        Type Parameters:
        T - the type of bean processed
        Parameters:
        beanType - the type of bean processed
        Returns:
        a list with all beans of the given that were processed from the input. Might contain nulls.
      • getBeans

        public java.util.Map<java.lang.Class<?>,​java.util.List<?>> getBeans()
        Returns a map of all beans processed from the input.
        Returns:
        all beans processed from the input.