Class WorkbookRecord

java.lang.Object
io.leandev.appfuse.workbook.WorkbookRecord
All Implemented Interfaces:
Record

public class WorkbookRecord extends Object implements Record

工作表資料記錄

將一列(Row)包裝為框架統一的 Record,支援依欄位名稱(搭配 Header)或索引存取, 並繼承 Record 的型別安全轉換方法(getAsStringgetAsIntegergetAsBigDecimal…)。

Since:
4.0.0
  • Method Details

    • setHeaders

      public void setHeaders(List<String> headers)
      設定欄位名稱(供名稱存取)
      Parameters:
      headers - 欄位名稱列表
    • getHeaders

      public List<String> getHeaders()
      取得欄位名稱
      Returns:
      欄位名稱列表
    • size

      public int size()
      Description copied from interface: Record
      取得記錄的欄位數量
      Specified by:
      size in interface Record
      Returns:
      欄位數量
    • getValues

      public List<?> getValues()
      Description copied from interface: Record

      取得記錄中所有欄位的值列表。

      注意:此方法主要供內部 Record.isEmpty() 使用。 應用層請優先使用型別安全的存取方法,如 Record.getAsString(String)Record.getAsInteger(String) 等。

      使用通配符 List<?> 允許實作類(如 CsvRecord)回傳具體型別(如 List<String>), 保持型別安全與彈性。

      Specified by:
      getValues in interface Record
      Returns:
      包含所有欄位值的列表
    • getValue

      public Object getValue(int index)
      Description copied from interface: Record
      依索引取得欄位值
      Specified by:
      getValue in interface Record
      Parameters:
      index - 欄位索引
      Returns:
      欄位值
    • getValue

      public <S> S getValue(int index, Class<S> type)
      Description copied from interface: Record
      依索引取得並轉換欄位值
      Specified by:
      getValue in interface Record
      Type Parameters:
      S - 目標類型
      Parameters:
      index - 欄位索引
      type - 目標類型的 Class
      Returns:
      轉換後的值
    • indexOf

      public int indexOf(String name)
      Description copied from interface: Record
      取得欄位名稱對應的索引
      Specified by:
      indexOf in interface Record
      Parameters:
      name - 欄位名稱
      Returns:
      欄位索引,若不存在則返回 -1