Package adams.data.spreadsheet
Interface Cell
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
CellView
,DataCellView
,DoubleCell
,FloatCell
public interface Cell extends Serializable
Represents a single cell.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Cell.ContentType
the type of content.
-
Field Summary
Fields Modifier and Type Field Description static String
FORMULA_ERROR
display string in case of an error in a formula.static String
PREFIX_FORMULA
the prefix for a formula.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
assign(Cell cell)
Obtains the content/type of the other cell, but not the owner.void
calculate()
Recalculates the value from the cell's formula.String
getContent()
Returns the content of the cell.Cell.ContentType
getContentType()
Returns the content type.String
getFormula()
Returns the formula.Object
getNative()
Returns the cell as native object, according to its type.Object
getObject()
Returns the object.Row
getOwner()
Returns the row this cell belongs to.SpreadSheet
getSpreadSheet()
Returns the spreadsheet this cell belongs to.int
index()
Returns the column this cell is in.boolean
isAnyDateType()
Checks whether the cell represents a date, time or date/time value.boolean
isBoolean()
Checks whether the cell represents a boolean value.boolean
isDate()
Checks whether the cell represents a date value.boolean
isDateTime()
Checks whether the cell represents a date/time value.boolean
isDateTimeMsec()
Checks whether the cell represents a date/time with msec value.boolean
isDouble()
Returns whether the content represents a double number.boolean
isFormula()
Returns whether the content represents a formula.boolean
isLong()
Returns whether the content represents a long number.boolean
isMissing()
Checks whether the cell contains a missing value.boolean
isNumeric()
Checks whether the stored string is numeric.boolean
isObject()
Returns whether the content represents an object.boolean
isTime()
Checks whether the cell represents a time value.boolean
isTimeMsec()
Checks whether the cell represents a time/msec value.Cell
parseContent(String value)
Attempts to determine the data type of the string.Object
parseContent(String value, Cell.ContentType type)
Parses the content of the cell using the specified type.Cell
setContent(DateTime value)
Sets the content of the cell.Cell
setContent(DateTimeMsec value)
Sets the content of the cell.Cell
setContent(Time value)
Sets the content of the cell.Cell
setContent(TimeMsec value)
Sets the content of the cell.Cell
setContent(Boolean value)
Sets the content of the cell.Cell
setContent(Byte value)
Sets the content of the cell.Cell
setContent(Double value)
Sets the content of the cell.Cell
setContent(Float value)
Sets the content of the cell.Cell
setContent(Integer value)
Sets the content of the cell.Cell
setContent(Long value)
Sets the content of the cell.Cell
setContent(Short value)
Sets the content of the cell.Cell
setContent(String value)
Sets the content of the cell.Cell
setContent(Date value)
Sets the content of the cell.Cell
setContentAs(String value, Cell.ContentType type)
Sets the content of the cell, trying to parse the content using the specified content type.Cell
setContentAsString(String value)
Sets the string content of the cell.Cell
setFormula(String value)
Sets the formula content of the cell.void
setMissing()
Sets the cell to missing.Cell
setNative(Object value)
Determines the best set-method based on the class of the provided object.Cell
setObject(Object value)
Sets the object content of the cell.void
setOwner(Row owner)
Sets the row this cell belongs to.Date
toAnyDateType()
Returns the date content, null if not a date, time or date/time.Boolean
toBoolean()
Returns the boolean content, null if not a boolean.Date
toDate()
Returns the date content, null if not a date.DateTime
toDateTime()
Returns the date/time content, null if not a date/time.DateTimeMsec
toDateTimeMsec()
Returns the date/time msec content, null if not a date/time.Double
toDouble()
Returns the content as double, if possible.Long
toLong()
Returns the content as long, if possible.String
toString()
Returns the content of the cell.Time
toTime()
Returns the time content, null if not a time.TimeMsec
toTimeMsec()
Returns the time/msec content, null if not a time/msec.
-
-
-
Field Detail
-
PREFIX_FORMULA
static final String PREFIX_FORMULA
the prefix for a formula.- See Also:
- Constant Field Values
-
FORMULA_ERROR
static final String FORMULA_ERROR
display string in case of an error in a formula.- See Also:
- Constant Field Values
-
-
Method Detail
-
setOwner
void setOwner(Row owner)
Sets the row this cell belongs to.- Parameters:
owner
- the owner
-
getOwner
Row getOwner()
Returns the row this cell belongs to.- Returns:
- the owner
-
getSpreadSheet
SpreadSheet getSpreadSheet()
Returns the spreadsheet this cell belongs to.- Returns:
- the spreadsheet
-
assign
void assign(Cell cell)
Obtains the content/type of the other cell, but not the owner.- Parameters:
cell
- the cell to get the content/type from
-
setMissing
void setMissing()
Sets the cell to missing.
-
setContent
Cell setContent(Boolean value)
Sets the content of the cell.- Parameters:
value
- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(Byte value)
Sets the content of the cell.- Parameters:
value
- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(Short value)
Sets the content of the cell.- Parameters:
value
- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(Integer value)
Sets the content of the cell.- Parameters:
value
- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(Long value)
Sets the content of the cell.- Parameters:
value
- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(Float value)
Sets the content of the cell.- Parameters:
value
- the content; null or NaN is interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(Double value)
Sets the content of the cell.- Parameters:
value
- the content; null or NaN is interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(Date value)
Sets the content of the cell.- Parameters:
value
- the content; null is interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(DateTime value)
Sets the content of the cell.- Parameters:
value
- the content; null is interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(DateTimeMsec value)
Sets the content of the cell.- Parameters:
value
- the content; null is interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(Time value)
Sets the content of the cell.- Parameters:
value
- the content; null is interpreted as missing value- Returns:
- the cell itself
-
setContent
Cell setContent(TimeMsec value)
Sets the content of the cell.- Parameters:
value
- the content; null is interpreted as missing value- Returns:
- the cell itself
-
parseContent
Cell parseContent(String value)
Attempts to determine the data type of the string.- Parameters:
value
- the non-empty string to parse- Returns:
- the cell itself
-
setContent
Cell setContent(String value)
Sets the content of the cell. Tries to determine whether the cell content is numeric or not.- Parameters:
value
- the content- Returns:
- the cell itself
-
parseContent
Object parseContent(String value, Cell.ContentType type)
Parses the content of the cell using the specified type. If the string cannot be parsed according to the type, missing is used instead.- Parameters:
value
- the contenttype
- the expected type- Returns:
- the parsed content
-
setContentAsString
Cell setContentAsString(String value)
Sets the string content of the cell.- Parameters:
value
- the content- Returns:
- the cell itself
-
setContentAs
Cell setContentAs(String value, Cell.ContentType type)
Sets the content of the cell, trying to parse the content using the specified content type.- Parameters:
value
- the contenttype
- the type to use- Returns:
- the cell itself
-
setObject
Cell setObject(Object value)
Sets the object content of the cell.- Parameters:
value
- the content- Returns:
- the cell itself
-
setFormula
Cell setFormula(String value)
Sets the formula content of the cell.- Parameters:
value
- the content- Returns:
- the cell itself
-
getFormula
String getFormula()
Returns the formula.- Returns:
- the formula, null if none used
-
getObject
Object getObject()
Returns the object.- Returns:
- the object, null if none set
-
getContent
String getContent()
Returns the content of the cell.- Returns:
- the content
-
getContentType
Cell.ContentType getContentType()
Returns the content type.- Returns:
- the type
-
setNative
Cell setNative(Object value)
Determines the best set-method based on the class of the provided object. Fallback is thesetObject(Object)
method.- Parameters:
value
- the value to set- Returns:
- the cell itself
-
getNative
Object getNative()
Returns the cell as native object, according to its type. If a cell is missing, the result is theSpreadSheet.MISSING_VALUE
string.- Returns:
- the corresponding object
-
index
int index()
Returns the column this cell is in.- Returns:
- the column index, -1 if not available
-
isNumeric
boolean isNumeric()
Checks whether the stored string is numeric.- Returns:
- true if the content is numeric
-
isMissing
boolean isMissing()
Checks whether the cell contains a missing value.- Returns:
- true if missing value
-
isBoolean
boolean isBoolean()
Checks whether the cell represents a boolean value.- Returns:
- true if boolean value
-
toBoolean
Boolean toBoolean()
Returns the boolean content, null if not a boolean.- Returns:
- the date, null if not boolean
-
isAnyDateType
boolean isAnyDateType()
Checks whether the cell represents a date, time or date/time value.- Returns:
- true if date, time or date/time value
-
toAnyDateType
Date toAnyDateType()
Returns the date content, null if not a date, time or date/time.- Returns:
- the date, null if not date, time or date/time
-
isDate
boolean isDate()
Checks whether the cell represents a date value.- Returns:
- true if date value
-
toDate
Date toDate()
Returns the date content, null if not a date.- Returns:
- the date, null if not date
-
isDateTime
boolean isDateTime()
Checks whether the cell represents a date/time value.- Returns:
- true if date/time value
-
toDateTime
DateTime toDateTime()
Returns the date/time content, null if not a date/time.- Returns:
- the date/time, null if not date/time
-
isDateTimeMsec
boolean isDateTimeMsec()
Checks whether the cell represents a date/time with msec value.- Returns:
- true if date/time msec value
-
toDateTimeMsec
DateTimeMsec toDateTimeMsec()
Returns the date/time msec content, null if not a date/time.- Returns:
- the date/time msec, null if not date/time
-
isTime
boolean isTime()
Checks whether the cell represents a time value.- Returns:
- true if time value
-
toTime
Time toTime()
Returns the time content, null if not a time.- Returns:
- the time, null if not time
-
isTimeMsec
boolean isTimeMsec()
Checks whether the cell represents a time/msec value.- Returns:
- true if time/msec value
-
toTimeMsec
TimeMsec toTimeMsec()
Returns the time/msec content, null if not a time/msec.- Returns:
- the time/msec, null if not time/msec
-
toString
String toString()
Returns the content of the cell.- Overrides:
toString
in classObject
- Returns:
- the content
- See Also:
getContent()
-
isDouble
boolean isDouble()
Returns whether the content represents a double number.- Returns:
- true if a double
-
toDouble
Double toDouble()
Returns the content as double, if possible.- Returns:
- the content as double, if representing a number, otherwise null
-
isLong
boolean isLong()
Returns whether the content represents a long number.- Returns:
- true if a long
-
toLong
Long toLong()
Returns the content as long, if possible. First, a Double object is created and then the longValue() method called to return the value.- Returns:
- the content as long, if representing a number, otherwise null
-
isFormula
boolean isFormula()
Returns whether the content represents a formula.- Returns:
- true if a formula
-
isObject
boolean isObject()
Returns whether the content represents an object.- Returns:
- true if an object
-
calculate
void calculate()
Recalculates the value from the cell's formula.
-
-