Class ImportProcessingContext<R extends FileReaderContext>
java.lang.Object
com.broadleafcommerce.dataimport.processor.ImportProcessingContext<R>
- All Implemented Interfaces:
ContextualFileReader
public final class ImportProcessingContext<R extends FileReaderContext>
extends Object
implements ContextualFileReader
Execution information when an import is being processed. This is utilized by an
ImportProcessor to read through a particular file and actually emit the
BatchRequest- Author:
- Phillip Verheyden (phillipuniverse)
-
Constructor Summary
ConstructorsConstructorDescriptionImportProcessingContext(String importId, Set<String> restrictedHeaders, ImportSpecification importSpecification, FileReader<R> fileReader, InputStream fileStream, long startingLine) -
Method Summary
Modifier and TypeMethodDescriptionlongcountTotalItems(InputStream file) Counts all of the data records within the file.longThe current line that the context is pointing to, 1-indexedbooleanString[]Obtains the headers for the current fileThe import being processedThe current resolved specification being executedHeaders that the user specified should be restrictedinthashCode()booleanhasNext()Whether or not there are more data records to read.Returns the next row of data.toString()
-
Constructor Details
-
ImportProcessingContext
public ImportProcessingContext(String importId, Set<String> restrictedHeaders, ImportSpecification importSpecification, FileReader<R> fileReader, InputStream fileStream, long startingLine) throws IOException - Throws:
IOException
-
-
Method Details
-
getHeaders
Description copied from interface:ContextualFileReaderObtains the headers for the current file- Specified by:
getHeadersin interfaceContextualFileReader- Returns:
- the headers from the file
-
currentLineNumber
public long currentLineNumber()Description copied from interface:ContextualFileReaderThe current line that the context is pointing to, 1-indexed- Specified by:
currentLineNumberin interfaceContextualFileReader- Returns:
- the current line number that this reader is pointing to
-
hasNext
public boolean hasNext()Description copied from interface:ContextualFileReaderWhether or not there are more data records to read. Should be used as a guard againstContextualFileReader.readNextLine()to protect against an attempt at reading too far- Specified by:
hasNextin interfaceContextualFileReader- Returns:
- whether or not there are more data records to read
-
readNextLine
Description copied from interface:ContextualFileReaderReturns the next row of data. Keys correspond to the headers and values are the specific values for those headers- Specified by:
readNextLinein interfaceContextualFileReader- Returns:
- a row of data from the file
-
countTotalItems
Description copied from interface:ContextualFileReaderCounts all of the data records within the file. This should not include all of the physical lines within the file. For instance this should not include the header line or any lines that are denoted as comments- Specified by:
countTotalItemsin interfaceContextualFileReader- Parameters:
file- file to count records for- Returns:
- the total number of data records in the file
-
getImportId
The import being processed -
getRestrictedHeaders
Headers that the user specified should be restricted -
getImportSpecification
The current resolved specification being executed -
equals
-
hashCode
public int hashCode() -
toString
-