Class AbstractItemCountingItemStreamItemReader<T>

    • Constructor Detail

      • AbstractItemCountingItemStreamItemReader

        public AbstractItemCountingItemStreamItemReader()
    • Method Detail

      • doRead

        @Nullable
        protected abstract T doRead()
                             throws java.lang.Exception
        Read next item from input.
        Returns:
        an item or null if the data source is exhausted
        Throws:
        java.lang.Exception - Allows subclasses to throw checked exceptions for interpretation by the framework
      • doOpen

        protected abstract void doOpen()
                                throws java.lang.Exception
        Open resources necessary to start reading input.
        Throws:
        java.lang.Exception - Allows subclasses to throw checked exceptions for interpretation by the framework
      • doClose

        protected abstract void doClose()
                                 throws java.lang.Exception
        Close the resources opened in doOpen().
        Throws:
        java.lang.Exception - Allows subclasses to throw checked exceptions for interpretation by the framework
      • jumpToItem

        protected void jumpToItem​(int itemIndex)
                           throws java.lang.Exception
        Move to the given item index. Subclasses should override this method if there is a more efficient way of moving to given index than re-reading the input using doRead().
        Parameters:
        itemIndex - index of item (0 based) to jump to.
        Throws:
        java.lang.Exception - Allows subclasses to throw checked exceptions for interpretation by the framework
      • read

        public T read()
               throws java.lang.Exception,
                      UnexpectedInputException,
                      ParseException
        Description copied from interface: ItemReader
        Reads a piece of input data and advance to the next one. Implementations must return null at the end of the input data set. In a transactional setting, caller might get the same item twice from successive calls (or otherwise), if the first call was in a transaction that rolled back.
        Returns:
        T the item to be processed or null if the data source is exhausted
        Throws:
        ParseException - if there is a problem parsing the current record (but the next one may still be valid)
        NonTransientResourceException - if there is a fatal exception in the underlying resource. After throwing this exception implementations should endeavour to return null from subsequent calls to read.
        UnexpectedInputException - if there is an uncategorised problem with the input data. Assume potentially transient, so subsequent calls to read might succeed.
        java.lang.Exception - if an there is a non-specific error.
      • getCurrentItemCount

        protected int getCurrentItemCount()
      • setCurrentItemCount

        public void setCurrentItemCount​(int count)
        The index of the item to start reading from. If the ExecutionContext contains a key [name].read.count (where [name] is the name of this component) the value from the ExecutionContext will be used in preference.
        Parameters:
        count - the value of the current item count
        See Also:
        ItemStreamSupport.setName(String)
      • setMaxItemCount

        public void setMaxItemCount​(int count)
        The maximum index of the items to be read. If the ExecutionContext contains a key [name].read.count.max (where [name] is the name of this component) the value from the ExecutionContext will be used in preference.
        Parameters:
        count - the value of the maximum item count. count must be greater than zero.
        See Also:
        ItemStreamSupport.setName(String)
      • setSaveState

        public void setSaveState​(boolean saveState)
        Set the flag that determines whether to save internal data for ExecutionContext. Only switch this to false if you don't want to save any state from this stream, and you don't need it to be restartable. Always set it to false if the reader is being used in a concurrent environment.
        Parameters:
        saveState - flag value (default true).
      • isSaveState

        public boolean isSaveState()
        The flag that determines whether to save internal state for restarts.
        Returns:
        true if the flag was set