org.kuali.kfs.gl.batch.service.impl
Class OriginEntryFileIterator

java.lang.Object
  extended by org.kuali.kfs.gl.batch.service.impl.OriginEntryFileIterator
All Implemented Interfaces:
Iterator<OriginEntryFull>
Direct Known Subclasses:
FilteringOriginEntryFileIterator

public class OriginEntryFileIterator
extends Object
implements Iterator<OriginEntryFull>

This class lazy loads the origin entries in a flat file. This implementation uses a limited amount of memory because it does not pre-load all of the origin entries at once. (Assuming that the Java garbage collector is working well). However, if the code that uses this iterator stores the contents of this iterator in a big list somewhere, then a lot of memory may be consumed, depending on the size of the file.


Field Summary
protected  boolean autoCloseReader
           
protected  int lineNumber
           
protected  OriginEntryFull nextEntry
           
protected  BufferedReader reader
           
 
Constructor Summary
OriginEntryFileIterator(BufferedReader reader)
          Constructs a OriginEntryFileIterator
OriginEntryFileIterator(BufferedReader reader, boolean autoCloseReader)
          Constructs a OriginEntryFileIterator
OriginEntryFileIterator(File file)
          Constructs a OriginEntryFileIterator When constructed with this method, the file handle will be automatically closed when the end of origin entries has been reached (i.e.
 
Method Summary
protected  void fetchNextEntry()
          This method returns the next line in origin entry file
protected  void finalize()
           
 boolean hasNext()
           
 OriginEntryFull next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nextEntry

protected OriginEntryFull nextEntry

reader

protected BufferedReader reader

lineNumber

protected int lineNumber

autoCloseReader

protected boolean autoCloseReader
Constructor Detail

OriginEntryFileIterator

public OriginEntryFileIterator(BufferedReader reader)
Constructs a OriginEntryFileIterator

Parameters:
reader - a reader representing flat-file origin entries
autoCloseReader - whether to automatically close the reader when the end of origin entries has been reached (i.e. when hasNext() returns false)

OriginEntryFileIterator

public OriginEntryFileIterator(BufferedReader reader,
                               boolean autoCloseReader)
Constructs a OriginEntryFileIterator

Parameters:
reader - a reader representing flat-file origin entries
autoCloseReader - whether to automatically close the reader when the end of origin entries has been reached (i.e. when hasNext() returns false)

OriginEntryFileIterator

public OriginEntryFileIterator(File file)
Constructs a OriginEntryFileIterator When constructed with this method, the file handle will be automatically closed when the end of origin entries has been reached (i.e. when hasNext() returns false)

Parameters:
file - the file
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<OriginEntryFull>
See Also:
Iterator.hasNext()

next

public OriginEntryFull next()
Specified by:
next in interface Iterator<OriginEntryFull>
See Also:
Iterator.next()

remove

public void remove()
Specified by:
remove in interface Iterator<OriginEntryFull>
See Also:
Iterator.remove()

fetchNextEntry

protected void fetchNextEntry()
This method returns the next line in origin entry file


finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable
See Also:
Object.finalize()


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.