Class ImportValidationContext<R extends FileReaderContext>
java.lang.Object
com.broadleafcommerce.dataimport.service.ImportValidationContext<R>
- All Implemented Interfaces:
ContextualFileReader
public final class ImportValidationContext<R extends FileReaderContext>
extends Object
implements ContextualFileReader
Execution data when validating an import before processing it. Used by the
ImportValidator
- Author:
- Phillip Verheyden (phillipuniverse)
-
Constructor Summary
ConstructorDescriptionImportValidationContext
(ImportRequest request, ImportSpecification importSpecification, FileReader<R> fileReader, org.springframework.core.io.InputStreamSource inputStreamSource) -
Method Summary
Modifier and TypeMethodDescriptionlong
countTotalItems
(InputStream file) Counts all of the data records within the file.long
The current line that the context is pointing to, 1-indexedboolean
String[]
Obtains the headers for the current fileThe current resolved specification being executedorg.springframework.core.io.InputStreamSource
The input stream source for where import data should be loadedThe original import requestint
hashCode()
boolean
hasNext()
Whether or not there are more data records to read.Returns the next row of data.toString()
-
Constructor Details
-
ImportValidationContext
public ImportValidationContext(ImportRequest request, ImportSpecification importSpecification, FileReader<R> fileReader, org.springframework.core.io.InputStreamSource inputStreamSource) throws IOException - Throws:
IOException
-
-
Method Details
-
getHeaders
Description copied from interface:ContextualFileReader
Obtains the headers for the current file- Specified by:
getHeaders
in interfaceContextualFileReader
- Returns:
- the headers from the file
-
currentLineNumber
public long currentLineNumber()Description copied from interface:ContextualFileReader
The current line that the context is pointing to, 1-indexed- Specified by:
currentLineNumber
in interfaceContextualFileReader
- Returns:
- the current line number that this reader is pointing to
-
hasNext
public boolean hasNext()Description copied from interface:ContextualFileReader
Whether 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:
hasNext
in interfaceContextualFileReader
- Returns:
- whether or not there are more data records to read
-
readNextLine
Description copied from interface:ContextualFileReader
Returns the next row of data. Keys correspond to the headers and values are the specific values for those headers- Specified by:
readNextLine
in interfaceContextualFileReader
- Returns:
- a row of data from the file
-
countTotalItems
Description copied from interface:ContextualFileReader
Counts 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:
countTotalItems
in interfaceContextualFileReader
- Parameters:
file
- file to count records for- Returns:
- the total number of data records in the file
-
getRequest
The original import request -
getImportSpecification
The current resolved specification being executed -
getInputStreamSource
public org.springframework.core.io.InputStreamSource getInputStreamSource()The input stream source for where import data should be loaded -
equals
-
hashCode
public int hashCode() -
toString
-