wims
3.65+svn20090927

This is a wrapper class for all objects in the table. More...
Public Member Functions  
Cell ()  
Creates an empty cell.  
Cell (Object datum)  
This constructor constructs a cell that will not have cells referencing it and are not formulas.  
Cell (Object datum, TreeSet reference)  
The constructor creates a new data cell which is not a formula.  
Cell (Formula thing, Object eVal, TreeSet reference)  
This version of the constructor constructs a formula cell.  
Formula  getFormula () 
This method returns the formula associated with the cell or null if it does not exist.  
Object  getValue () 
If it is a data cell, it returns the data of the cell.  
void  setValue (Object datum) 
Sets the value field of the cell.  
void  setData (Object datum) 
This method changes the cell to a data cell with value datum.  
void  setFormula (Formula form) 
This method sets the cell to be a formula cell.  
boolean  isEmpty () 
Returns true if cell at specified position is empty.  
boolean  hasRefs () 
This method returns true if there are cells that reference this one.  
TreeSet  getRefs () 
This method gets the list of cells that reference this one.  
void  removeRef (CellPoint reference) 
This method removes a cell from reference list.  
void  addRef (CellPoint reference) 
This method adds a cell to the dependency list.  
int  getType () 
This method is useful for determining what information a cell holds.  
boolean  isFormula () 
This method returns true IFF it is a formula cell.  
boolean  isErrorCell () 
This method determines a cell is a formula cell that has a error.  
int  compare (Cell x, boolean ascending) 
This is a method similar to compareTo except that it is not consistent with the equals method.  
String  toString () 
Static Public Attributes  
static final int  TEXT = 0 
The integer code that denotes the cell holds text.  
static final int  NUMBER = 1 
The integer code that denotes the cell holds numbers.  
static final int  FORMULA = 2 
The integer code that denotes the cell holds a formula.  
Private Attributes  
Object  value 
Value of the cell.  
Formula  expression 
This expression contains the string and internal representation of the formula if it exists.  
TreeSet  refs 
The list of cells that reference this cell. 
This is a wrapper class for all objects in the table.
A cell has a value which is either text or a number. If it is a formula cell it also has an expression associated with it. In addition, a cell has a list of all cells that reference it.
SharpTools.Cell.Cell  (  )  [inline] 
Creates an empty cell.
Definition at line 49 of file Cell.java.
{ value = null; expression = null; refs = null; }
SharpTools.Cell.Cell  (  Object  datum  )  [inline] 
This constructor constructs a cell that will not have cells referencing it and are not formulas.
Basically only used for creating the row and column labels.
Warning: Do not use this with Formulas
datum  the value of the "label" cell (not a Formula) 
Definition at line 63 of file Cell.java.
{ value = datum; expression = null; refs = null; }
SharpTools.Cell.Cell  (  Object  datum, 
TreeSet  reference  
)  [inline] 
The constructor creates a new data cell which is not a formula.
Note: A normal cell's data is stored in value field but expression (i.e. formula) field is null.
datum  the value of the cell (text or number) 
reference  the list of cells that reference this one (can be null) 
Definition at line 77 of file Cell.java.
{ value = datum; expression = null; refs = reference; }
SharpTools.Cell.Cell  (  Formula  thing, 
Object  eVal,  
TreeSet  reference  
)  [inline] 
This version of the constructor constructs a formula cell.
thing  internal represenation of the formula 
eVal  the evaluated value of the formula (thing) 
reference  the list of cells that reference this one (can be null) 
Definition at line 90 of file Cell.java.
{ expression = thing; value = eVal; refs = reference; }
void SharpTools.Cell.addRef  (  CellPoint  reference  )  [inline] 
This method adds a cell to the dependency list.
reference  a new cell that references this one that needs to be added to the reference list 
Definition at line 206 of file Cell.java.
{ // System.out.println("add ref "+reference+" to ("+this); if (refs == null) {// check if refs is initiated refs = new TreeSet(); } refs.add(reference); }
int SharpTools.Cell.compare  (  Cell  x, 
boolean  ascending  
)  [inline] 
This is a method similar to compareTo except that it is not consistent with the equals method.
It is used for sorting. Cells are rated in increasing order: blank, error, string, number (including formulas). If two cells are blank or errors then they are "equal" by this compare method. Numbers and strings are compared the usual way.
x  cell to compare this to 
Definition at line 256 of file Cell.java.
{ //if this is blank which is lowest value if (this.value.equals("")) { //x is not blank so this is less than if (!x.value.equals("")) { if (ascending) { return 1; } else { return 1; } } else { //otherwise equal return 0; } } else { if (x.value.equals("")) { if (ascending) { return 1; }else { return 1; } } else { //both have values if (this.isErrorCell()) { if (x.isErrorCell()) { return 0; } else { return 1; } } else { if (x.isErrorCell()) { return 1; } else { if (this.getType() == Cell.TEXT) { if (x.getType() == Cell.TEXT) { String temp = (String)this.value; return temp.compareToIgnoreCase((String)x.value); } else { return 1; } } else { if (x.getType() == Cell.TEXT) { return 1; } else { Float first = (Float)this.value; Float second = (Float)x.value; return first.compareTo(second); } } } } } } }
Formula SharpTools.Cell.getFormula  (  )  [inline] 
This method returns the formula associated with the cell or null if it does not exist.
Definition at line 103 of file Cell.java.
{ return expression; }
TreeSet SharpTools.Cell.getRefs  (  )  [inline] 
This method gets the list of cells that reference this one.
This method should be used after the cell's value has been changed to find out which cells need to be updated.
Definition at line 183 of file Cell.java.
{ return refs; }
int SharpTools.Cell.getType  (  )  [inline] 
This method is useful for determining what information a cell holds.
To check if a cell holds a certain type just see if getType() == Cell.CODE where CODE is any of the cell constants.
Definition at line 221 of file Cell.java.
{ if (expression != null) return Cell.FORMULA; if (value instanceof Number) return Cell.NUMBER; return Cell.TEXT; }
Object SharpTools.Cell.getValue  (  )  [inline] 
boolean SharpTools.Cell.hasRefs  (  )  [inline] 
boolean SharpTools.Cell.isEmpty  (  )  [inline] 
Returns true if cell at specified position is empty.
Definition at line 160 of file Cell.java.
{ if(value.equals("") && expression == null) return true; else return false; }
boolean SharpTools.Cell.isErrorCell  (  )  [inline] 
boolean SharpTools.Cell.isFormula  (  )  [inline] 
This method returns true IFF it is a formula cell.
Definition at line 232 of file Cell.java.
{ return (expression != null); }
void SharpTools.Cell.removeRef  (  CellPoint  reference  )  [inline] 
This method removes a cell from reference list.
reference  the cell to be removed from the reference list 
Definition at line 192 of file Cell.java.
{ // System.out.println("remove ref "+reference+" from "+this); if (refs != null) { refs.remove(reference); if (refs.isEmpty()) refs = null; } }
void SharpTools.Cell.setData  (  Object  datum  )  [inline] 
This method changes the cell to a data cell with value datum.
This method useful because changing the value does not affect the value of the reference list.
Warning: If the cell is going to be set to a formula, you must use setFormula() because this present method sets the associated formula field, expression, to null.
datum  the new value of cell 
Definition at line 140 of file Cell.java.
{ value = datum; expression = null; }
void SharpTools.Cell.setFormula  (  Formula  form  )  [inline] 
This method sets the cell to be a formula cell.
It puts the formula object into the expression field. The Table of Cells is responsible for recalculating and setting the appropriate value in the value field of this cell.
form  the internal representation of formula to set this cell to 
Definition at line 153 of file Cell.java.
{ expression = form; }
void SharpTools.Cell.setValue  (  Object  datum  )  [inline] 
String SharpTools.Cell.toString  (  )  [inline] 
Definition at line 309 of file Cell.java.
{ if (expression != null) return "="+expression.toString(); else return value.toString(); }
Formula SharpTools.Cell.expression [private] 
final int SharpTools.Cell.FORMULA = 2 [static] 
final int SharpTools.Cell.NUMBER = 1 [static] 
TreeSet SharpTools.Cell.refs [private] 
final int SharpTools.Cell.TEXT = 0 [static] 
Object SharpTools.Cell.value [private] 