Package org.apache.ofbiz.datafile
Class RecordIterator
- java.lang.Object
-
- org.apache.ofbiz.datafile.RecordIterator
-
public class RecordIterator extends java.lang.Object
Record Iterator for reading large files Note: this is a memory intensive and will not handle files that exceed memory.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.BufferedReader
br
protected boolean
closed
protected java.lang.String
curLine
protected Record
curRecord
protected java.io.InputStream
dataFileStream
protected java.lang.String
eof
protected java.lang.String
locationInfo
protected ModelDataFile
modelDataFile
static java.lang.String
module
protected java.lang.String
nextLine
protected int
nextLineNum
protected Record
nextRecord
-
Constructor Summary
Constructors Constructor Description RecordIterator(java.io.InputStream dataFileStream, ModelDataFile modelDataFile, java.lang.String locationInfo)
RecordIterator(java.net.URL fileUrl, ModelDataFile modelDataFile)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected static ModelRecord
findModelForLine(java.lang.String line, int lineNum, ModelDataFile modelDataFile)
Searches through the record models to find one with a matching type-code, if no type-code exists that model will always be used if it gets to itint
getCurrentLineNumber()
protected boolean
getNextLine()
boolean
hasNext()
Record
next()
protected void
setupStream(java.io.InputStream dataFileStream, java.lang.String locationInfo)
-
-
-
Field Detail
-
module
public static final java.lang.String module
-
br
protected java.io.BufferedReader br
-
modelDataFile
protected ModelDataFile modelDataFile
-
dataFileStream
protected java.io.InputStream dataFileStream
-
closed
protected boolean closed
-
locationInfo
protected java.lang.String locationInfo
-
nextLineNum
protected int nextLineNum
-
curLine
protected java.lang.String curLine
-
curRecord
protected Record curRecord
-
nextLine
protected java.lang.String nextLine
-
nextRecord
protected Record nextRecord
-
eof
protected java.lang.String eof
-
-
Constructor Detail
-
RecordIterator
public RecordIterator(java.net.URL fileUrl, ModelDataFile modelDataFile) throws DataFileException
- Throws:
DataFileException
-
RecordIterator
public RecordIterator(java.io.InputStream dataFileStream, ModelDataFile modelDataFile, java.lang.String locationInfo) throws DataFileException
- Throws:
DataFileException
-
-
Method Detail
-
setupStream
protected void setupStream(java.io.InputStream dataFileStream, java.lang.String locationInfo) throws DataFileException
- Throws:
DataFileException
-
getNextLine
protected boolean getNextLine() throws DataFileException
- Throws:
DataFileException
-
getCurrentLineNumber
public int getCurrentLineNumber()
-
hasNext
public boolean hasNext()
-
next
public Record next() throws DataFileException
- Throws:
DataFileException
-
close
public void close() throws DataFileException
- Throws:
DataFileException
-
findModelForLine
protected static ModelRecord findModelForLine(java.lang.String line, int lineNum, ModelDataFile modelDataFile) throws DataFileException
Searches through the record models to find one with a matching type-code, if no type-code exists that model will always be used if it gets to it- Parameters:
line
-lineNum
-modelDataFile
-- Returns:
- return the ModelRecord Object found
- Throws:
DataFileException
- Exception thown for various errors, generally has a nested exception
-
-