Package sc2002.FCS1.grp2
Class CSVCell
Object
CSVCell
A simple class for representing an individual cell of any specific row and column of a CSV file.
- Author:
- Vincent Neo
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanConvenience method to get value as an boolean.Convenience method to get value as date and time.Convenience method to get value as date.intConvenience method to get value as an integer.Convenience method to get value as a UUID.getValue()Provides the contents of the cell, as parsed by the CSVParser class.String[]Provides the values of the cell, separated by commas.String[]Provides multiple values of cell where possible, else, the single string value.booleanProvides a way to tell if there are multiple values retrievable in this cell.booleanisBlank()Returns true if cell is blank.
-
Field Details
-
value
Value of each CSV spreadsheet cell, unmodified. -
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 theCSVParserclass will construct this type of objects.- Parameters:
value- Contents of a CSV cell, either as is, or contents within"..."
.
-
-
Method Details
-
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
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
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
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
Provides the values of the cell, separated by commas.- Returns:
- values as a
String[], if cell contains comma separated values or null,
-
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()orgetValue()
-
hasMultipleValues
public boolean hasMultipleValues()Provides a way to tell if there are multiple values retrievable in this cell.- Returns:
trueif >1 values can be retrieved,falseif 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.
-