Class CsvRow

java.lang.Object
org.miaixz.bus.core.lang.wrapper.SimpleWrapper<List<String>>
org.miaixz.bus.core.center.list.ListWrapper<String>
org.miaixz.bus.office.csv.CsvRow
All Implemented Interfaces:
Iterable<String>, Collection<String>, List<String>, SequencedCollection<String>, org.miaixz.bus.core.lang.Wrapper<List<String>>, org.miaixz.bus.core.Provider

public final class CsvRow extends org.miaixz.bus.core.center.list.ListWrapper<String>
CSV中一行的表示
Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields inherited from class org.miaixz.bus.core.lang.wrapper.SimpleWrapper

    raw
  • Constructor Summary

    Constructors
    Constructor
    Description
    CsvRow(long originalLineNumber, Map<String,Integer> headerMap, List<String> fields)
    构造
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    get(int index)
     
    获取标题对应的字段内容
    获取标题与字段值对应的Map
    long
    获取原始行号,多行情况下为首行行号。
    <T> T
    toBean(Class<T> clazz)
    一行数据转换为Bean对象,忽略转换错误
     

    Methods inherited from class org.miaixz.bus.core.center.list.ListWrapper

    add, add, addAll, addAll, clear, contains, equals, forEach, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, parallelStream, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, stream, subList, toArray, toArray

    Methods inherited from class org.miaixz.bus.core.lang.wrapper.SimpleWrapper

    getRaw

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Collection

    toArray

    Methods inherited from interface java.util.List

    addFirst, addLast, getFirst, getLast, removeFirst, removeLast, reversed

    Methods inherited from interface org.miaixz.bus.core.lang.Wrapper

    type
  • Constructor Details

    • CsvRow

      public CsvRow(long originalLineNumber, Map<String,Integer> headerMap, List<String> fields)
      构造
      Parameters:
      originalLineNumber - 对应文件中的第几行
      headerMap - 标题Map
      fields - 数据列表
  • Method Details

    • getOriginalLineNumber

      public long getOriginalLineNumber()
      获取原始行号,多行情况下为首行行号。忽略注释行
      Returns:
      the original line number 行号
    • getByName

      public String getByName(String name)
      获取标题对应的字段内容
      Parameters:
      name - 标题名
      Returns:
      字段值,null表示无此字段值
      Throws:
      IllegalStateException - CSV文件无标题行抛出此异常
    • getFieldMap

      public Map<String,String> getFieldMap()
      获取标题与字段值对应的Map
      Returns:
      标题与字段值对应的Map
      Throws:
      IllegalStateException - CSV文件无标题行抛出此异常
    • toBean

      public <T> T toBean(Class<T> clazz)
      一行数据转换为Bean对象,忽略转换错误
      Type Parameters:
      T - Bean类型
      Parameters:
      clazz - bean类
      Returns:
      the object
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<String>
      Specified by:
      containsAll in interface List<String>
      Overrides:
      containsAll in class org.miaixz.bus.core.center.list.ListWrapper<String>
    • get

      public String get(int index)
      Specified by:
      get in interface List<String>
      Overrides:
      get in class org.miaixz.bus.core.center.list.ListWrapper<String>
    • toString

      public String toString()
      Overrides:
      toString in class Object