Class CSVCell

Object
CSVCell

public class CSVCell extends Object
A simple class for representing an individual cell of any specific row and column of a CSV file.
Author:
Vincent Neo
  • Field Details

    • value

      private String value
      Value of each CSV spreadsheet cell, unmodified.
    • commaSeperatedValues

      private String[] commaSeperatedValues
      Values of comma separated values within a cell.
  • Constructor Details

    • CSVCell

      CSVCell(String value)
      Construct an object based on contents of a CSV cell. It is generally expected that only the CSVParser class will construct this type of objects.
      Parameters:
      value - Contents of a CSV cell, either as is, or contents within
      "..."
      .
  • Method Details

    • getValue

      public String getValue()
      Provides the contents of the cell, as parsed by the CSVParser class. Note that no contents are manipulated here, so even comma separated values are represented as is.
      Returns:
      Value of CSV cell as a String.
    • getIntValue

      public int getIntValue()
      Convenience method to get value as an integer.
      Returns:
      value of the CSV cell as an int.
      Throws:
      NumberFormatException - - if cell content is not a number.
    • getBoolValue

      public boolean getBoolValue()
      Convenience method to get value as an boolean. Note that this method strictly considers "TRUE" and "FALSE" only (Excel style)
      Returns:
      value of the CSV cell as an boolean.
      Throws:
      IllegalArgumentException - - if cell content is not either "TRUE" or "FALSE".
    • getDateValue

      public LocalDate getDateValue()
      Convenience method to get value as date.
      Returns:
      value of the CSV cell as an LocalDate.
      Throws:
      DateTimeParseException - - if cell content is not of d/M/yy date format.
    • getDateTimeValue

      public LocalDateTime getDateTimeValue()
      Convenience method to get value as date and time.
      Returns:
      value of the CSV cell as an LocalDateTime.
      Throws:
      DateTimeParseException - - if cell content is not of correct date time format.
    • getUUIDValue

      public UUID getUUIDValue()
      Convenience method to get value as a UUID.
      Returns:
      value of the CSV cell as an UUID.
      Throws:
      IllegalArgumentException - - if cell content is not UUID compliant.
    • getValues

      public String[] getValues()
      Provides the values of the cell, separated by commas.
      Returns:
      values as a String[], if cell contains comma separated values or null,
    • getValuesOrValue

      public String[] getValuesOrValue()
      Provides multiple values of cell where possible, else, the single string value. As this method does not check the contents of cell if singular, it is up to your responsibility to ensure value are correct.
      Returns:
      values of getValues() or getValue()
    • hasMultipleValues

      public boolean hasMultipleValues()
      Provides a way to tell if there are multiple values retrievable in this cell.
      Returns:
      true if >1 values can be retrieved, false if cell only contains one value.
    • isBlank

      public boolean isBlank()
      Returns true if cell is blank. (e.g. not even a blank space)
      Returns:
      ture if cell blank.