Module jp.ecuacion.util.poi
Class StringOneLineHeaderExcelTableToBeanReader<T extends StringExcelTableBean>
java.lang.Object
jp.ecuacion.util.poi.excel.table.ExcelTable<String>
jp.ecuacion.util.poi.excel.table.reader.ExcelTableReader<String>
jp.ecuacion.util.poi.excel.table.reader.concrete.StringExcelTableReader
jp.ecuacion.util.poi.excel.table.reader.concrete.StringOneLineHeaderExcelTableReader
jp.ecuacion.util.poi.excel.table.reader.concrete.StringOneLineHeaderExcelTableToBeanReader<T>
- All Implemented Interfaces:
IfDataTypeStringExcelTable,IfExcelTable<String>,IfFormatOneLineHeaderExcelTable<String>,IfDataTypeStringExcelTableReader,IfExcelTableReader<String>,IfFormatOneLineHeaderExcelTableReader<String>
public class StringOneLineHeaderExcelTableToBeanReader<T extends StringExcelTableBean>
extends StringOneLineHeaderExcelTableReader
Stores the excel table data into a bean.
-
Nested Class Summary
Nested classes/interfaces inherited from class jp.ecuacion.util.poi.excel.table.reader.ExcelTableReader
ExcelTableReader.IterableReader<T>, ExcelTableReader.IteratorReader<T>Nested classes/interfaces inherited from class jp.ecuacion.util.poi.excel.table.ExcelTable
ExcelTable.ContextContainer -
Field Summary
Fields inherited from class jp.ecuacion.util.poi.excel.table.reader.concrete.StringExcelTableReader
columnDateTimeFormatMap, dateTimeFormatFields inherited from class jp.ecuacion.util.poi.excel.table.reader.ExcelTableReader
tableColumnSizeGivenByConstructor, tableRowSizeGivenByConstructorFields inherited from class jp.ecuacion.util.poi.excel.table.ExcelTable
ignoresAdditionalColumnsOfHeaderData, isVerticalAndHorizontalOpposite, sheetName, tableStartColumnNumber, tableStartRowNumber -
Constructor Summary
ConstructorsConstructorDescriptionStringOneLineHeaderExcelTableToBeanReader(Class<?> beanClass, String sheetName, String[] headerLabels, Integer tableStartRowNumber, int tableStartColumnNumber, Integer tableRowSize, NoDataString noDataString) Constructs a new instance with the obtained value from an empty cell.StringOneLineHeaderExcelTableToBeanReader(Class<?> beanClass, String sheetName, String[] headerLabels, Integer tableStartRowNumber, int tableStartColumnNumber, Integer tableRowSize, T... parameterClass) Constructs a new instance. the obtained value from an empty cell isnull. -
Method Summary
Modifier and TypeMethodDescriptioncolumnDateTimeFormat(int columnNumber, DateTimeFormatter dateTimeFormat) Sets dateTimeFormat for specific column.defaultDateTimeFormat(DateTimeFormatter dateTimeFormat) Sets defaultDateTimeFormat.excelTableToBeanList(String filePath) Obtains excel table in the form ofList<PoiStringTableBean>.ignoresAdditionalColumnsOfHeaderData(boolean value) Stores the boolean value which indicates whethervalidateHeaderDataignores additional header columns.readToBean(String filePath) Obtains excel table in the form ofList<PoiStringTableBean>and validate obtained values..readToBean(String filePath, boolean validates) Obtains excel table in the form ofList<PoiStringTableBean>and validate obtained values..Methods inherited from class jp.ecuacion.util.poi.excel.table.reader.concrete.StringOneLineHeaderExcelTableReader
getHeaderLabels, getNoDataStringMethods inherited from class jp.ecuacion.util.poi.excel.table.reader.concrete.StringExcelTableReader
getDateTimeFormatMethods inherited from class jp.ecuacion.util.poi.excel.table.reader.ExcelTableReader
getIterable, getReadyToReadTableData, getTableColumnSize, getTableRowSize, isVerticalAndHorizontalOpposite, read, read, setTableColumnSizeMethods inherited from class jp.ecuacion.util.poi.excel.table.ExcelTable
getPoiBasisDeterminedTableStartColumnNumber, getPoiBasisDeterminedTableStartRowNumber, getSheetName, ignoresAdditionalColumnsOfHeaderData, isVerticalAndHorizontalOppositeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jp.ecuacion.util.poi.excel.table.IfDataTypeStringExcelTable
getStringValueMethods inherited from interface jp.ecuacion.util.poi.excel.table.reader.IfDataTypeStringExcelTableReader
getCellData, isCellDataEmptyMethods inherited from interface jp.ecuacion.util.poi.excel.table.IfExcelTable
getSheetName, ignoresAdditionalColumnsOfHeaderData, isVerticalAndHorizontalOpposite, isVerticalAndHorizontalOppositeMethods inherited from interface jp.ecuacion.util.poi.excel.table.reader.IfExcelTableReader
validateHeaderDataMethods inherited from interface jp.ecuacion.util.poi.excel.table.IfFormatOneLineHeaderExcelTable
getFarLeftAndTopHeaderLabel, getHeaderLabelData, getNumberOfHeaderLinesMethods inherited from interface jp.ecuacion.util.poi.excel.table.reader.IfFormatOneLineHeaderExcelTableReader
updateAndGetHeaderData
-
Constructor Details
-
StringOneLineHeaderExcelTableToBeanReader
public StringOneLineHeaderExcelTableToBeanReader(Class<?> beanClass, @RequireNonnull String sheetName, @RequireNonnull String[] headerLabels, Integer tableStartRowNumber, int tableStartColumnNumber, Integer tableRowSize, T... parameterClass) Constructs a new instance. the obtained value from an empty cell isnull.In most cases
nullis recommended becauseJakarta Validationannotations (likeMax) returns valid fornull, but invalid for"".- Parameters:
beanClass- the class of the generic parameterTis hard to obtain especially the constructor of this class is called directly with setting a class instead of T, likeList<Foo> list = new StringOneLineHeaderExcelTableToBeanReader<Foo>(...).
See here.
-
StringOneLineHeaderExcelTableToBeanReader
public StringOneLineHeaderExcelTableToBeanReader(Class<?> beanClass, @RequireNonnull String sheetName, @RequireNonnull String[] headerLabels, Integer tableStartRowNumber, int tableStartColumnNumber, Integer tableRowSize, @Nonnull NoDataString noDataString) Constructs a new instance with the obtained value from an empty cell.- Parameters:
beanClass- the class of the generic parameterTis hard to obtain especially the constructor of this class is called directly with setting a class instead of T, likeList<Foo> list = new StringOneLineHeaderExcelTableToBeanReader<Foo>(...).
See here.noDataString- the obtained value from an empty cell.nullor"".
-
-
Method Details
-
readToBean
public List<T> readToBean(String filePath) throws jp.ecuacion.lib.core.exception.checked.AppException, org.apache.poi.EncryptedDocumentException, IOException Obtains excel table in the form ofList<PoiStringTableBean>and validate obtained values..- Parameters:
filePath- excelPath- Returns:
- the list of
PoiStringTableBean. - Throws:
jp.ecuacion.lib.core.exception.checked.AppException- AppExceptionorg.apache.poi.EncryptedDocumentException- EncryptedDocumentExceptionIOException- IOException
-
readToBean
public List<T> readToBean(String filePath, boolean validates) throws jp.ecuacion.lib.core.exception.checked.AppException, org.apache.poi.EncryptedDocumentException, IOException Obtains excel table in the form ofList<PoiStringTableBean>and validate obtained values..- Parameters:
filePath- excelPathvalidates- whether validation is enabled or not- Returns:
- the list of
PoiStringTableBean. - Throws:
jp.ecuacion.lib.core.exception.checked.AppException- AppExceptionorg.apache.poi.EncryptedDocumentException- EncryptedDocumentExceptionIOException- IOException
-
excelTableToBeanList
protected List<T> excelTableToBeanList(String filePath) throws jp.ecuacion.lib.core.exception.checked.AppException, IOException Obtains excel table in the form ofList<PoiStringTableBean>.Since
readmethod contains validation function, you may want to test the validations. Although you don't want to prepare excel files to test each case.
When that's the case, you can skip the preparation of excel files by overriding this method and return list you want to test.- Throws:
jp.ecuacion.lib.core.exception.checked.AppExceptionIOException
-
defaultDateTimeFormat
public StringOneLineHeaderExcelTableToBeanReader<T> defaultDateTimeFormat(DateTimeFormatter dateTimeFormat) Description copied from class:StringExcelTableReaderSets defaultDateTimeFormat.- Overrides:
defaultDateTimeFormatin classStringOneLineHeaderExcelTableReader- Parameters:
dateTimeFormat- dateTimeFormat string forDateTimeFormatter.- Returns:
- StringExcelTableReader (for method chain)
-
columnDateTimeFormat
public StringOneLineHeaderExcelTableToBeanReader<T> columnDateTimeFormat(int columnNumber, DateTimeFormatter dateTimeFormat) Description copied from class:StringExcelTableReaderSets dateTimeFormat for specific column.- Overrides:
columnDateTimeFormatin classStringOneLineHeaderExcelTableReader- Parameters:
columnNumber- the column number data is obtained from, starting with 1 and column A is equal to columnNumber 1. When the far left column of a table is 2 and you want to speciries the far left column, the columnNumber is 2.dateTimeFormat- dateTimeFormat string forDateTimeFormatter.- Returns:
- StringExcelTableReader (for method chain)
-
ignoresAdditionalColumnsOfHeaderData
public StringOneLineHeaderExcelTableToBeanReader<T> ignoresAdditionalColumnsOfHeaderData(boolean value) Description copied from interface:IfExcelTableStores the boolean value which indicates whethervalidateHeaderDataignores additional header columns.- Specified by:
ignoresAdditionalColumnsOfHeaderDatain interfaceIfExcelTable<T extends StringExcelTableBean>- Overrides:
ignoresAdditionalColumnsOfHeaderDatain classExcelTableReader<String>- Parameters:
value- boolean
-