Class StringExcelTableBean

java.lang.Object
jp.ecuacion.util.poi.excel.table.bean.StringExcelTableBean

public abstract class StringExcelTableBean extends Object
Stores values obtained from excel tables with StringFixedTableToBeanReader.
  • Constructor Details

    • StringExcelTableBean

      public StringExcelTableBean(@RequireNonnull List<String> colList)
      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.AppException
      Is 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

      @Nonnull protected abstract String[] getFieldNameArray()
      Returns String array 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

      @Nonnull protected String nullToEmpty(@Nullable String value)
      Returns empty if the argument value is null or returns the argument value.
    • emptyToNull

      @Nullable protected String emptyToNull(@Nullable String value)
      Returns null if the argument value is empty or returns the argument value.
    • toInteger

      @Nullable protected Integer toInteger(@Nullable String value)
      Returns Integer datatype of the argument string.
    • toLong

      @Nullable protected Long toLong(@Nullable String value)
      Returns Long datatype of the argument string.
    • toFloat

      @Nullable protected Float toFloat(@Nullable String value)
      Returns Float datatype of the argument string.
    • toDouble

      @Nullable protected Double toDouble(@Nullable String value)
      Returns Double datatype of the argument string.
    • toBigInteger

      @Nullable protected BigInteger toBigInteger(@Nullable String value)
      Returns BigInteger datatype of the argument string.
    • toBigDecimal

      @Nullable protected BigDecimal toBigDecimal(@Nullable String value)
      Returns BigDecimal datatype of the argument string.