org.statcato.spreadsheet
Class Cell

java.lang.Object
  extended by org.statcato.spreadsheet.Cell

public class Cell
extends java.lang.Object

A cell in a Spreadsheet object.

Since:
1.0
Version:
%I%, %G%
Author:
myau
See Also:
Spreadsheet

Constructor Summary
Cell(java.lang.String contents, int row, int column)
          Constructor, given the contents as a string and the row and column of the cell.
 
Method Summary
 void clear()
          Clears the cell contents by setting to the empty string.
 boolean equals(Cell cell)
          Returns true iff the given cell object is equal to this object.
 int getColumn()
          Returns the column number of this cell
 java.lang.String getContents()
          Returns the unformatted string representation the contents of this cell.
 java.lang.Double getNumValue()
          Returns the numerical value of the cell contents, or null if not a number.
 int getRow()
          Returns the row number of this cell.
 boolean hasData()
          Returns true iff this cell is non-empty (the contents is not equal to an empty string).
 boolean isNumeric()
          Returns true if the cell contents represent a number.
 void setColumn(int col)
          Sets the column number of the cell.
 void setContents(java.lang.String svalue)
          Sets the contents to the cell to the specified string.
 void setRow(int row)
          Sets the row number of the cell.
 java.lang.String toString()
          Returns the string representation of this cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cell

public Cell(java.lang.String contents,
            int row,
            int column)
Constructor, given the contents as a string and the row and column of the cell.

Parameters:
contents - string representation of the cell contents
row - row number (integer)
column - column number (integer)
Method Detail

getContents

public java.lang.String getContents()
Returns the unformatted string representation the contents of this cell.

Returns:
string representation of the contents

getRow

public int getRow()
Returns the row number of this cell.

Returns:
row number (integer)

getColumn

public int getColumn()
Returns the column number of this cell

Returns:
column number (integer)

toString

public java.lang.String toString()
Returns the string representation of this cell. If the string represents an integer, simply converts it to string. If the string represents a non-integer number, converts it to string such that there are at most six decimal places. Otherwise, simply returns the unformatted string representation of the contents.

Overrides:
toString in class java.lang.Object
Returns:
string representation

getNumValue

public java.lang.Double getNumValue()
Returns the numerical value of the cell contents, or null if not a number.

Returns:
double value of the cell contents, or null if not a number

setContents

public void setContents(java.lang.String svalue)
Sets the contents to the cell to the specified string.

Parameters:
svalue - string used to set the cell contents

clear

public void clear()
Clears the cell contents by setting to the empty string.


setRow

public void setRow(int row)
Sets the row number of the cell.

Parameters:
row - row number

setColumn

public void setColumn(int col)
Sets the column number of the cell.

Parameters:
col - column number

equals

public boolean equals(Cell cell)
Returns true iff the given cell object is equal to this object. Two cells are equal if their contents, row numbers, and column numbers are equal.

Parameters:
cell - the Cell object to be compared to this object
Returns:
true iff objects are equal

isNumeric

public boolean isNumeric()
Returns true if the cell contents represent a number.

Returns:
true iff the cell contains a number

hasData

public boolean hasData()
Returns true iff this cell is non-empty (the contents is not equal to an empty string).

Returns:
true iff not empty