Package adams.ml.data
Class DataCellView
- java.lang.Object
-
- adams.ml.data.DataCellView
-
- All Implemented Interfaces:
adams.data.spreadsheet.Cell,Serializable
public class DataCellView extends Object implements adams.data.spreadsheet.Cell
Wrapper for single cell values in aInstanceobject. All dates are treated asDateTimeMsec.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_ColIndexthe column index.protected InstanceViewm_Ownerthe owning row.
-
Constructor Summary
Constructors Constructor Description DataCellView(InstanceView owner, int colIndex)Initializes the cell.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassign(adams.data.spreadsheet.Cell cell)Obtains the content/type of the other cell, but not the owner.voidcalculate()Does nothing.StringgetContent()Returns the content of the cell.adams.data.spreadsheet.Cell.ContentTypegetContentType()Returns the content type.StringgetFormula()Returns the formula.ObjectgetNative()Returns the cell as native object, according to its type.ObjectgetObject()Returns the object.booleangetOnlyStoreFormulas()Returns whether to only store formulas and not evaluate them.InstanceViewgetOwner()Returns the row this cell belongs to.adams.data.spreadsheet.SpreadSheetgetSpreadSheet()Returns the spreadsheet this cell belongs to.intindex()Returns the column this cell is in.booleanisAnyDateType()Checks whether the cell represents a date, time or date/time value.booleanisBoolean()Checks whether the cell represents a boolean value.booleanisDate()Checks whether the cell represents a date value.booleanisDateTime()Checks whether the cell represents a date/time value.booleanisDateTimeMsec()Checks whether the cell represents a date/time with msec value.booleanisDouble()Returns whether the content represents a double number.booleanisEmpty()Checks whether the cell is either missing or has no content.booleanisFormula()Returns whether the content represents a formula.booleanisLong()Returns whether the content represents a long number.booleanisMissing()Checks whether the cell contains a missing value.booleanisNumeric()Checks whether the stored string is numeric.booleanisObject()Returns whether the content represents an object.booleanisQuiet()Returns whether logging output is suppressed, e.g., from parse errors.booleanisTime()Checks whether the cell represents a time value.booleanisTimeMsec()Checks whether the cell represents a time/msec value.adams.data.spreadsheet.CellparseContent(String value)Attempts to determine the data type of the string.ObjectparseContent(String value, adams.data.spreadsheet.Cell.ContentType type)Parses the content of the cell using the specified type.adams.data.spreadsheet.CellsetContent(adams.core.DateTime value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(adams.core.DateTimeMsec value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(adams.core.Time value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(adams.core.TimeMsec value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(Boolean value)Ignored.adams.data.spreadsheet.CellsetContent(Byte value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(Double value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(Float value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(Integer value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(Long value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(Short value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(String value)Sets the content of the cell.adams.data.spreadsheet.CellsetContent(Date value)Sets the content of the cell.adams.data.spreadsheet.CellsetContentAs(String value, adams.data.spreadsheet.Cell.ContentType type)Sets the content of the cell, trying to parse the content using the specified content type.adams.data.spreadsheet.CellsetContentAsString(String value)Sets the string content of the cell.adams.data.spreadsheet.CellsetFormula(String value)Ignored.voidsetMissing()Sets the cell to missing.adams.data.spreadsheet.CellsetNative(Object value)Determines the best set-method based on the class of the provided object.adams.data.spreadsheet.CellsetObject(Object value)Ignored.voidsetOwner(adams.data.spreadsheet.Row owner)Sets the row this cell belongs to.DatetoAnyDateType()Returns the date content, null if not a date, time or date/time.BooleantoBoolean()Checks whether the cell represents a boolean value.DatetoDate()Returns the date content, null if not a date.adams.core.DateTimetoDateTime()Returns the date/time content, null if not a date/time.adams.core.DateTimeMsectoDateTimeMsec()Returns the date/time msec content, null if not a date/time.DoubletoDouble()Returns the content as double, if possible.LongtoLong()Returns the content as long, if possible.adams.core.TimetoTime()Returns the time content, null if not a time.adams.core.TimeMsectoTimeMsec()Returns the time/msec content, null if not a time/msec.
-
-
-
Field Detail
-
m_Owner
protected InstanceView m_Owner
the owning row.
-
m_ColIndex
protected int m_ColIndex
the column index.
-
-
Constructor Detail
-
DataCellView
public DataCellView(InstanceView owner, int colIndex)
Initializes the cell.- Parameters:
owner- the owning rowcolIndex- the column index
-
-
Method Detail
-
setOwner
public void setOwner(adams.data.spreadsheet.Row owner)
Sets the row this cell belongs to.- Specified by:
setOwnerin interfaceadams.data.spreadsheet.Cell- Parameters:
owner- the owner
-
getOwner
public InstanceView getOwner()
Returns the row this cell belongs to.- Specified by:
getOwnerin interfaceadams.data.spreadsheet.Cell- Returns:
- the owner
-
getSpreadSheet
public adams.data.spreadsheet.SpreadSheet getSpreadSheet()
Returns the spreadsheet this cell belongs to.- Specified by:
getSpreadSheetin interfaceadams.data.spreadsheet.Cell- Returns:
- the spreadsheet
-
assign
public void assign(adams.data.spreadsheet.Cell cell)
Obtains the content/type of the other cell, but not the owner.- Specified by:
assignin interfaceadams.data.spreadsheet.Cell- Parameters:
cell- the cell to get the content/type from
-
setMissing
public void setMissing()
Sets the cell to missing.- Specified by:
setMissingin interfaceadams.data.spreadsheet.Cell
-
setContent
public adams.data.spreadsheet.Cell setContent(Boolean value)
Ignored.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(Byte value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(Short value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(Integer value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(Long value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(Float value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(Double value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(Date value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(adams.core.DateTime value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(adams.core.DateTimeMsec value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(adams.core.Time value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(adams.core.TimeMsec value)
Sets the content of the cell.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content; null interpreted as missing value- Returns:
- the cell itself
-
parseContent
public adams.data.spreadsheet.Cell parseContent(String value)
Attempts to determine the data type of the string.- Specified by:
parseContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the non-empty string to parse- Returns:
- the cell itself
-
setContent
public adams.data.spreadsheet.Cell setContent(String value)
Sets the content of the cell. Tries to determine whether the cell content is numeric or not.- Specified by:
setContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content- Returns:
- the cell itself
-
parseContent
public Object parseContent(String value, adams.data.spreadsheet.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.- Specified by:
parseContentin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the contenttype- the expected type- Returns:
- the parsed content
-
setContentAsString
public adams.data.spreadsheet.Cell setContentAsString(String value)
Sets the string content of the cell.- Specified by:
setContentAsStringin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content- Returns:
- the cell itself
-
setContentAs
public adams.data.spreadsheet.Cell setContentAs(String value, adams.data.spreadsheet.Cell.ContentType type)
Sets the content of the cell, trying to parse the content using the specified content type.- Specified by:
setContentAsin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the contenttype- the type to use- Returns:
- the cell itself
-
setObject
public adams.data.spreadsheet.Cell setObject(Object value)
Ignored.- Specified by:
setObjectin interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content- Returns:
- the cell itself
-
setFormula
public adams.data.spreadsheet.Cell setFormula(String value)
Ignored.- Specified by:
setFormulain interfaceadams.data.spreadsheet.Cell- Parameters:
value- the content- Returns:
- the cell itself
-
getFormula
public String getFormula()
Returns the formula.- Specified by:
getFormulain interfaceadams.data.spreadsheet.Cell- Returns:
- the formula, null if none used
-
getObject
public Object getObject()
Returns the object.- Specified by:
getObjectin interfaceadams.data.spreadsheet.Cell- Returns:
- the object, null if none set
-
getContent
public String getContent()
Returns the content of the cell.- Specified by:
getContentin interfaceadams.data.spreadsheet.Cell- Returns:
- the content
-
getContentType
public adams.data.spreadsheet.Cell.ContentType getContentType()
Returns the content type.- Specified by:
getContentTypein interfaceadams.data.spreadsheet.Cell- Returns:
- the type
-
setNative
public adams.data.spreadsheet.Cell setNative(Object value)
Determines the best set-method based on the class of the provided object. Fallback is thesetObject(Object)method.- Specified by:
setNativein interfaceadams.data.spreadsheet.Cell- Parameters:
value- the value to set- Returns:
- the cell itself
-
getNative
public Object getNative()
Returns the cell as native object, according to its type. If a cell is missing, the result is theSpreadSheet.MISSING_VALUEstring.- Specified by:
getNativein interfaceadams.data.spreadsheet.Cell- Returns:
- the corresponding object
-
index
public int index()
Returns the column this cell is in.- Specified by:
indexin interfaceadams.data.spreadsheet.Cell- Returns:
- the column index, -1 if not available
-
isEmpty
public boolean isEmpty()
Checks whether the cell is either missing or has no content.- Specified by:
isEmptyin interfaceadams.data.spreadsheet.Cell- Returns:
- true if empty
-
isNumeric
public boolean isNumeric()
Checks whether the stored string is numeric.- Specified by:
isNumericin interfaceadams.data.spreadsheet.Cell- Returns:
- true if the content is numeric
-
isMissing
public boolean isMissing()
Checks whether the cell contains a missing value.- Specified by:
isMissingin interfaceadams.data.spreadsheet.Cell- Returns:
- true if missing value
-
isBoolean
public boolean isBoolean()
Checks whether the cell represents a boolean value.- Specified by:
isBooleanin interfaceadams.data.spreadsheet.Cell- Returns:
- true if boolean value
-
toBoolean
public Boolean toBoolean()
Checks whether the cell represents a boolean value.- Specified by:
toBooleanin interfaceadams.data.spreadsheet.Cell- Returns:
- true if boolean value
-
isAnyDateType
public boolean isAnyDateType()
Checks whether the cell represents a date, time or date/time value.- Specified by:
isAnyDateTypein interfaceadams.data.spreadsheet.Cell- Returns:
- true if date, time or date/time value
-
toAnyDateType
public Date toAnyDateType()
Returns the date content, null if not a date, time or date/time.- Specified by:
toAnyDateTypein interfaceadams.data.spreadsheet.Cell- Returns:
- the date, null if not date, time or date/time
-
isDate
public boolean isDate()
Checks whether the cell represents a date value.- Specified by:
isDatein interfaceadams.data.spreadsheet.Cell- Returns:
- true if date value
-
toDate
public Date toDate()
Returns the date content, null if not a date.- Specified by:
toDatein interfaceadams.data.spreadsheet.Cell- Returns:
- the date, null if not date
-
isDateTime
public boolean isDateTime()
Checks whether the cell represents a date/time value.- Specified by:
isDateTimein interfaceadams.data.spreadsheet.Cell- Returns:
- true if date/time value
-
toDateTime
public adams.core.DateTime toDateTime()
Returns the date/time content, null if not a date/time.- Specified by:
toDateTimein interfaceadams.data.spreadsheet.Cell- Returns:
- the date/time, null if not date/time
-
isDateTimeMsec
public boolean isDateTimeMsec()
Checks whether the cell represents a date/time with msec value.- Specified by:
isDateTimeMsecin interfaceadams.data.spreadsheet.Cell- Returns:
- true if date/time msec value
-
toDateTimeMsec
public adams.core.DateTimeMsec toDateTimeMsec()
Returns the date/time msec content, null if not a date/time.- Specified by:
toDateTimeMsecin interfaceadams.data.spreadsheet.Cell- Returns:
- the date/time msec, null if not date/time
-
isTime
public boolean isTime()
Checks whether the cell represents a time value.- Specified by:
isTimein interfaceadams.data.spreadsheet.Cell- Returns:
- true if time value
-
toTime
public adams.core.Time toTime()
Returns the time content, null if not a time.- Specified by:
toTimein interfaceadams.data.spreadsheet.Cell- Returns:
- the time, null if not time
-
isTimeMsec
public boolean isTimeMsec()
Checks whether the cell represents a time/msec value.- Specified by:
isTimeMsecin interfaceadams.data.spreadsheet.Cell- Returns:
- true if time/msec value
-
toTimeMsec
public adams.core.TimeMsec toTimeMsec()
Returns the time/msec content, null if not a time/msec.- Specified by:
toTimeMsecin interfaceadams.data.spreadsheet.Cell- Returns:
- the time/msec, null if not time/msec
-
isDouble
public boolean isDouble()
Returns whether the content represents a double number.- Specified by:
isDoublein interfaceadams.data.spreadsheet.Cell- Returns:
- true if a double
-
toDouble
public Double toDouble()
Returns the content as double, if possible.- Specified by:
toDoublein interfaceadams.data.spreadsheet.Cell- Returns:
- the content as double, if representing a number, otherwise null
-
isLong
public boolean isLong()
Returns whether the content represents a long number.- Specified by:
isLongin interfaceadams.data.spreadsheet.Cell- Returns:
- true if a long
-
toLong
public 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.- Specified by:
toLongin interfaceadams.data.spreadsheet.Cell- Returns:
- the content as long, if representing a number, otherwise null
-
isFormula
public boolean isFormula()
Returns whether the content represents a formula.- Specified by:
isFormulain interfaceadams.data.spreadsheet.Cell- Returns:
- true if a formula
-
isObject
public boolean isObject()
Returns whether the content represents an object.- Specified by:
isObjectin interfaceadams.data.spreadsheet.Cell- Returns:
- true if an object
-
isQuiet
public boolean isQuiet()
Returns whether logging output is suppressed, e.g., from parse errors.- Specified by:
isQuietin interfaceadams.data.spreadsheet.Cell- Returns:
- true if quiet
-
getOnlyStoreFormulas
public boolean getOnlyStoreFormulas()
Returns whether to only store formulas and not evaluate them.- Specified by:
getOnlyStoreFormulasin interfaceadams.data.spreadsheet.Cell- Returns:
- true if only stored
-
calculate
public void calculate()
Does nothing.- Specified by:
calculatein interfaceadams.data.spreadsheet.Cell
-
-