Package org.apache.ofbiz.datafile
Class RecordIterator
java.lang.Object
org.apache.ofbiz.datafile.RecordIterator
Record Iterator for reading large files
Note: this is a memory intensive and will not handle files that exceed memory.
-
Constructor Summary
ConstructorsConstructorDescriptionRecordIterator
(InputStream dataFileStream, ModelDataFile modelDataFile, String locationInfo) RecordIterator
(URL fileUrl, ModelDataFile modelDataFile) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close.protected static ModelRecord
findModelForLine
(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
Gets current line number.protected boolean
Gets next line.boolean
hasNext()
Has next boolean.next()
Next record.protected void
setupStream
(InputStream dataFileStream, String locationInfo) Sets stream.
-
Constructor Details
-
RecordIterator
- Throws:
DataFileException
-
RecordIterator
public RecordIterator(InputStream dataFileStream, ModelDataFile modelDataFile, String locationInfo) throws DataFileException - Throws:
DataFileException
-
-
Method Details
-
setupStream
protected void setupStream(InputStream dataFileStream, String locationInfo) throws DataFileException Sets stream.- Parameters:
dataFileStream
- the data file streamlocationInfo
- the location info- Throws:
DataFileException
- the data file exception
-
getNextLine
Gets next line.- Returns:
- the next line
- Throws:
DataFileException
- the data file exception
-
getCurrentLineNumber
public int getCurrentLineNumber()Gets current line number.- Returns:
- the current line number
-
hasNext
public boolean hasNext()Has next boolean.- Returns:
- the boolean
-
next
Next record.- Returns:
- the record
- Throws:
DataFileException
- the data file exception
-
close
Close.- Throws:
DataFileException
- the data file exception
-
findModelForLine
protected static ModelRecord findModelForLine(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
-