Module jp.ecuacion.util.poi
Class StringExcelTableBean
java.lang.Object
jp.ecuacion.util.poi.excel.table.bean.StringExcelTableBean
Stores values obtained from excel tables with
StringFixedTableToBeanReader.-
Constructor Summary
ConstructorsConstructorDescriptionStringExcelTableBean(List<String> colList) Constructs a new instance with the list of strings which consists of data of a line from the excel table. -
Method Summary
Modifier and TypeMethodDescriptionvoidIs called after reading an excel file.protected StringemptyToNull(String value) Returnsnullif the argument value is empty or returns the argument value.protected abstract String[]ReturnsStringarray of field names in the bean.protected StringnullToEmpty(String value) Returnsemptyif the argument value is null or returns the argument value.protected BigDecimaltoBigDecimal(String value) ReturnsBigDecimaldatatype of the argument string.protected BigIntegertoBigInteger(String value) ReturnsBigIntegerdatatype of the argument string.protected DoubleReturnsDoubledatatype of the argument string.protected FloatReturnsFloatdatatype of the argument string.protected IntegerReturnsIntegerdatatype of the argument string.protected LongReturnsLongdatatype of the argument string.
-
Constructor Details
-
StringExcelTableBean
Constructs a new instance with the list of strings which consists of data of a line from the excel table.- Parameters:
colList- the list of strings which consists of data of a line from the excel table
-
-
Method Details
-
afterReading
public void afterReading() throws jp.ecuacion.lib.core.exception.checked.AppExceptionIs called after reading an excel file.This is assumed to use to deserialize (structure) the line of data into objects, and validate the inter-fields data.
Validations for each field are supposed to be done by bean vaildation. This method covers selective-requirement, or other inter-fields validations.- Throws:
jp.ecuacion.lib.core.exception.checked.AppException
-
getFieldNameArray
ReturnsStringarray of field names in the bean.For example, the table in an excel file is this.
name age phone number John 30 (+01)123456789 Ken 40 (+81)987654321 table 1 If you want to read all data from table 1 and put into a bean, you need to create a bean extends this class, define fields
name, age, and phoneNumber, override this method and return the following array.new String[] {"name", "age", "phoneNumber"}the value in the first column (name) is put into the field with the first element in the array (name).
If you don't need data in "age" column, you can set null like
new String[] {"name", null, "phoneNumber"} -
nullToEmpty
Returnsemptyif the argument value is null or returns the argument value. -
emptyToNull
Returnsnullif the argument value is empty or returns the argument value. -
toInteger
ReturnsIntegerdatatype of the argument string. -
toLong
ReturnsLongdatatype of the argument string. -
toFloat
ReturnsFloatdatatype of the argument string. -
toDouble
ReturnsDoubledatatype of the argument string. -
toBigInteger
ReturnsBigIntegerdatatype of the argument string. -
toBigDecimal
ReturnsBigDecimaldatatype of the argument string.
-