org.kuali.kfs.module.ld.util
Class LaborOriginEntryFileIterator

java.lang.Object
  extended by org.kuali.kfs.module.ld.util.LaborOriginEntryFileIterator
All Implemented Interfaces:
Iterator<LaborOriginEntry>
Direct Known Subclasses:
FilteringLaborOriginEntryFileIterator

public class LaborOriginEntryFileIterator
extends Object
implements Iterator<LaborOriginEntry>

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  LaborOriginEntry nextEntry
           
protected  BufferedReader reader
           
 
Constructor Summary
LaborOriginEntryFileIterator(BufferedReader reader)
          Constructs a LaborOriginEntryFileIterator
LaborOriginEntryFileIterator(BufferedReader reader, boolean autoCloseReader)
          Constructs a LaborOriginEntryFileIterator
LaborOriginEntryFileIterator(File file)
          Constructs a LaborOriginEntryFileIterator 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()
           
protected  void finalize()
           
 boolean hasNext()
           
 LaborOriginEntry next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nextEntry

protected LaborOriginEntry nextEntry

reader

protected BufferedReader reader

lineNumber

protected int lineNumber

autoCloseReader

protected boolean autoCloseReader
Constructor Detail

LaborOriginEntryFileIterator

public LaborOriginEntryFileIterator(BufferedReader reader)
Constructs a LaborOriginEntryFileIterator

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)

LaborOriginEntryFileIterator

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

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)

LaborOriginEntryFileIterator

public LaborOriginEntryFileIterator(File file)
Constructs a LaborOriginEntryFileIterator 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<LaborOriginEntry>
See Also:
Iterator.hasNext()

next

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

remove

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

fetchNextEntry

protected void fetchNextEntry()

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.