public abstract class AbstractPoiFileParser<T> extends Object
| Constructor and Description |
|---|
AbstractPoiFileParser() |
AbstractPoiFileParser(Map<String,Integer> columnFieldNameMapping) |
AbstractPoiFileParser(Map<String,Integer> columnFieldNameMapping,
Set<Integer> requiredFields) |
| Modifier and Type | Method and Description |
|---|---|
void |
addColumnFieldNameMapping(String fieldName,
Integer columnNumber)
Add a mapping for a column
|
void |
addColumnFieldRegex(String fieldName,
String regex)
Validate if regex patter is correct and it to the validation rules
|
void |
addReadIgnoreColumn(Integer columnNumber)
Add a column number for ignoring when reading.
|
void |
addRequiredField(Integer columnNumber)
Add the column number for a required field
|
void |
addWriteIgnoreColumn(Integer columnNumber)
Add a column number for ignoring when writing.
|
Map<String,Integer> |
getColumnFieldNameMapping() |
DefaultConverterFactory |
getDefaultConverterFactory() |
Map<String,String> |
getHeaderFieldNameTranslationMapping() |
Set<Integer> |
getReadIgnoreColumns() |
Set<Integer> |
getWriteIgnoreColumns() |
boolean |
ignoreRow(org.apache.poi.ss.usermodel.Row row)
If row is empty, the ignore empty row setting will determine the adding of the row.
|
boolean |
isEmptyRow(org.apache.poi.ss.usermodel.Row row)
Check whether a row is empty based on the column values
|
boolean |
isEmptyValue(org.apache.poi.ss.usermodel.Cell cell)
Check if the hssfCell is empty or blank
|
boolean |
isIgnoreEmptyRows() |
boolean |
isIgnoreFirstRow() |
boolean |
isRemoveWriteIgnoreColumns()
If columns that are ignored must be deleted from the sheet when writing.
|
abstract List<T> |
readExcelFile(File excelFile,
String sheetName,
Class<T> clazz) |
abstract List<T> |
readExcelFile(File excelFile,
String sheetName,
Class<T> clazz,
int startRow)
Read a excel file from start row to last row.
|
abstract List<T> |
readExcelFile(File excelFile,
String sheetName,
Class<T> clazz,
int startRow,
int endRow)
Read a excel file from start row to end row
|
abstract List<T> |
readExcelFile(InputStream inputStream,
String sheetName,
Class<T> clazz) |
abstract List<T> |
readExcelFile(InputStream inputStream,
String sheetName,
Class<T> clazz,
int startRow)
Read a excel file input stream from given start row until last row
|
abstract List<T> |
readExcelFile(InputStream inputStream,
String sheetName,
Class<T> clazz,
int startRow,
int endRow)
Read a excel file inputstream start row to end row
|
protected void |
readField(String sheetName,
org.apache.poi.ss.usermodel.Row row,
T rowDimension,
String fieldName)
Read a specific field and fill it with the value in the excel
|
protected T |
readRow(String sheetName,
org.apache.poi.ss.usermodel.Row row,
T rowDimension)
Read a excel row and convert the selected field into a row dimension
|
protected List<T> |
readSheet(org.apache.poi.ss.usermodel.Sheet sheet,
Class<T> clazz)
Read Excel sheet.
|
protected List<T> |
readSheet(org.apache.poi.ss.usermodel.Sheet sheet,
Class<T> clazz,
int startRow) |
protected List<T> |
readSheet(org.apache.poi.ss.usermodel.Sheet sheet,
Class<T> clazz,
int startRow,
int endRow) |
protected void |
remapColumnFieldMapForWriting()
Re-map the columns when empty columns are ignored
|
void |
setHeaderFieldNameTranslationMapping(Map<String,String> headerFieldNameTranslationMapping) |
void |
setIgnoreEmptyRows(boolean ignoreEmptyRows) |
void |
setIgnoreFirstRow(boolean ignoreFirstRow) |
void |
setRemoveWriteIgnoreColumns(boolean removeWriteIgnoreColumns)
Set if the parser deletes the columns when writing a sheet.
|
protected void |
validateColumnFieldMapForWriting()
Validate if columns are used more than once.
|
protected void |
writeCell(org.apache.poi.ss.usermodel.Row row,
T dimension,
String fieldName) |
abstract void |
writeExcelFile(OutputStream outputStream,
LinkedHashMap<String,List<T>> excelDataMap,
Class<T> clazz) |
protected void |
writeHeaderRow(org.apache.poi.ss.usermodel.Sheet sheet,
Integer rowNumber) |
protected void |
writeRow(org.apache.poi.ss.usermodel.Sheet sheet,
T dimension,
Integer rowNumber) |
protected void |
writeSheet(org.apache.poi.ss.usermodel.Workbook workbook,
String sheetName,
List<T> dimensionList) |
protected org.apache.poi.ss.usermodel.Workbook |
writeWorkbook(LinkedHashMap<String,List<T>> excelDataMap) |
public abstract List<T> readExcelFile(File excelFile, String sheetName, Class<T> clazz) throws IOException, FileNotFoundException, InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
public abstract List<T> readExcelFile(InputStream inputStream, String sheetName, Class<T> clazz) throws IOException, FileNotFoundException, InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
public abstract List<T> readExcelFile(File excelFile, String sheetName, Class<T> clazz, int startRow, int endRow) throws IOException, FileNotFoundException, InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
excelFile - sheetName - clazz - startRow - endRow - IOExceptionFileNotFoundExceptionInstantiationExceptionIllegalAccessExceptionRequiredFieldPoiParserExceptionReadPoiParserExceptionpublic abstract List<T> readExcelFile(File excelFile, String sheetName, Class<T> clazz, int startRow) throws IOException, FileNotFoundException, InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
excelFile - sheetName - clazz - startRow - IOExceptionFileNotFoundExceptionInstantiationExceptionIllegalAccessExceptionRequiredFieldPoiParserExceptionReadPoiParserExceptionpublic abstract List<T> readExcelFile(InputStream inputStream, String sheetName, Class<T> clazz, int startRow, int endRow) throws IOException, FileNotFoundException, InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
inputStream - sheetName - clazz - startRow - endRow - IOExceptionFileNotFoundExceptionInstantiationExceptionIllegalAccessExceptionRequiredFieldPoiParserExceptionReadPoiParserExceptionpublic abstract List<T> readExcelFile(InputStream inputStream, String sheetName, Class<T> clazz, int startRow) throws IOException, FileNotFoundException, InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
inputStream - sheetName - clazz - startRow - IOExceptionFileNotFoundExceptionInstantiationExceptionIllegalAccessExceptionRequiredFieldPoiParserExceptionReadPoiParserExceptionpublic abstract void writeExcelFile(OutputStream outputStream, LinkedHashMap<String,List<T>> excelDataMap, Class<T> clazz) throws IOException, InitialWritePoiParserException, WritePoiParserException
protected List<T> readSheet(org.apache.poi.ss.usermodel.Sheet sheet, Class<T> clazz) throws InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
sheet - clazz - InstantiationExceptionIllegalAccessExceptionRequiredFieldPoiParserExceptionReadPoiParserExceptionprotected List<T> readSheet(org.apache.poi.ss.usermodel.Sheet sheet, Class<T> clazz, int startRow) throws InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
protected List<T> readSheet(org.apache.poi.ss.usermodel.Sheet sheet, Class<T> clazz, int startRow, int endRow) throws InstantiationException, IllegalAccessException, RequiredFieldPoiParserException, ReadPoiParserException
protected T readRow(String sheetName, org.apache.poi.ss.usermodel.Row row, T rowDimension) throws RequiredFieldPoiParserException, ReadPoiParserException
Read a excel row and convert the selected field into a row dimension
row - rowDimension - RequiredFieldPoiParserExceptionReadPoiParserExceptionprotected void readField(String sheetName, org.apache.poi.ss.usermodel.Row row, T rowDimension, String fieldName) throws RequiredFieldPoiParserException, ReadPoiParserException
Read a specific field and fill it with the value in the excel
row - Excel rowrowDimension - Abstract representation of a rowfieldName - Name of a field in the class RequiredFieldPoiParserExceptionReadPoiParserExceptionprotected org.apache.poi.ss.usermodel.Workbook writeWorkbook(LinkedHashMap<String,List<T>> excelDataMap) throws InitialWritePoiParserException, WritePoiParserException
protected void writeSheet(org.apache.poi.ss.usermodel.Workbook workbook,
String sheetName,
List<T> dimensionList)
throws WritePoiParserException
WritePoiParserExceptionprotected void writeRow(org.apache.poi.ss.usermodel.Sheet sheet,
T dimension,
Integer rowNumber)
throws WritePoiParserException
WritePoiParserExceptionprotected void writeHeaderRow(org.apache.poi.ss.usermodel.Sheet sheet,
Integer rowNumber)
protected void writeCell(org.apache.poi.ss.usermodel.Row row,
T dimension,
String fieldName)
throws WritePoiParserException
WritePoiParserExceptionpublic boolean ignoreRow(org.apache.poi.ss.usermodel.Row row)
hssfRow - public boolean isEmptyRow(org.apache.poi.ss.usermodel.Row row)
hssfRow - public boolean isEmptyValue(org.apache.poi.ss.usermodel.Cell cell)
hssfCell - protected void validateColumnFieldMapForWriting()
throws InitialWritePoiParserException
InitialWritePoiParserExceptionprotected void remapColumnFieldMapForWriting()
throws InitialWritePoiParserException
InitialWritePoiParserExceptionpublic boolean isIgnoreEmptyRows()
public void setIgnoreEmptyRows(boolean ignoreEmptyRows)
public void setIgnoreFirstRow(boolean ignoreFirstRow)
public boolean isIgnoreFirstRow()
public boolean isRemoveWriteIgnoreColumns()
public void setRemoveWriteIgnoreColumns(boolean removeWriteIgnoreColumns)
removeWriteIgnoreColumns - public Map<String,String> getHeaderFieldNameTranslationMapping()
public void setHeaderFieldNameTranslationMapping(Map<String,String> headerFieldNameTranslationMapping)
public void addColumnFieldNameMapping(String fieldName, Integer columnNumber)
fieldName - columnNumber - public void addRequiredField(Integer columnNumber)
columnNumber - public void addColumnFieldRegex(String fieldName, String regex)
fieldName - regex - public void addReadIgnoreColumn(Integer columnNumber)
columnNumber - public void addWriteIgnoreColumn(Integer columnNumber)
columnNumber - public DefaultConverterFactory getDefaultConverterFactory()
Copyright © 2011-2012 BSTOI.NL. All Rights Reserved.