csheets.ext
Class CellExtension

java.lang.Object
  extended by csheets.ext.CellExtension
All Implemented Interfaces:
Cell, CellListener, Extensible<Cell>, Serializable, Comparable<Cell>, EventListener
Direct Known Subclasses:
AssertableCell, StylableCell, TestableCell

public abstract class CellExtension
extends Object
implements Cell, CellListener

A base class for extensions of cells in a spreadsheet that uses delegation to provide cell data.

Author:
Einar Pehrson
See Also:
Serialized Form

Constructor Summary
CellExtension(Cell delegate, String name)
          Creates a new cell extension.
 
Method Summary
 void addCellListener(CellListener listener)
          Registers the given listener on the cell.
 void cellCleared(Cell cell)
          Invoked when a cell has been cleared.
 void cellCopied(Cell cell, Cell source)
          Invoked when a cell has been copied.
 void clear()
          Clears the content of the cell.
 int compareTo(Cell cell)
           
 void contentChanged(Cell cell)
          Invoked when the content of a cell has been changed.
 void copyFrom(Cell source)
          Copies all data from the source cell to this one.
 void dependentsChanged(Cell cell)
          Invoked when a new dependent has been registered on a cell, or when an old one has been removed.
 Address getAddress()
          Returns the address of the cell.
 CellListener[] getCellListeners()
          Returns the listeners that have been registered on the cell.
 String getContent()
          Returns the content of the cell, as entered by the user.
 Cell getDelegate()
          Returns the extension's delegate.
 SortedSet<Cell> getDependents()
          Returns the dependents of the cell, i.e. the cells that contain a reference to the cell in their formula.
 Cell getExtension(String name)
          Returns the extension with the given key.
 Formula getFormula()
          Returns an expression representing the cell's formula.
 String getName()
          Returns the name of the extension to which the cell extension belongs.
 SortedSet<Cell> getPrecedents()
          Returns the precedents of the cell, i.e. the cells that the formula in the cell references.
 Spreadsheet getSpreadsheet()
          Returns the spreadsheet to which the cell belongs.
 Value getValue()
          Returns the value of the cell.
 void moveFrom(Cell source)
          Moves all data from the source cell to this one.
 void removeCellListener(CellListener listener)
          Removes the given listener from the cell.
 void setContent(String content)
          Sets the content of the cell and if it starts with the assignment operator attempts to parse a formula from it.
 String toString()
           
 void valueChanged(Cell cell)
          Invoked when the value of a cell has changed, either by a change in its content, or by a change of value in one of its precedents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CellExtension

public CellExtension(Cell delegate,
                     String name)
Creates a new cell extension.

Parameters:
delegate - the delegate of the extension
name - the name of the extension to which the cell extension belongs
Method Detail

getDelegate

public final Cell getDelegate()
Returns the extension's delegate.

Returns:
the extension's delegate, i.e. the cell to which it belongs

getName

public final String getName()
Returns the name of the extension to which the cell extension belongs.

Returns:
the name of the extension to which the cell extension belongs

getSpreadsheet

public final Spreadsheet getSpreadsheet()
Description copied from interface: Cell
Returns the spreadsheet to which the cell belongs.

Specified by:
getSpreadsheet in interface Cell
Returns:
the spreadsheet to which the cell belongs

getAddress

public final Address getAddress()
Description copied from interface: Cell
Returns the address of the cell.

Specified by:
getAddress in interface Cell
Returns:
the address of the cell

getValue

public final Value getValue()
Description copied from interface: Cell
Returns the value of the cell.

Specified by:
getValue in interface Cell
Returns:
the value of the cell

getContent

public final String getContent()
Description copied from interface: Cell
Returns the content of the cell, as entered by the user.

Specified by:
getContent in interface Cell
Returns:
the content of the cell

getFormula

public final Formula getFormula()
Description copied from interface: Cell
Returns an expression representing the cell's formula.

Specified by:
getFormula in interface Cell
Returns:
the cell's formula, or null if the cell does not contain one

setContent

public final void setContent(String content)
                      throws FormulaCompilationException
Description copied from interface: Cell
Sets the content of the cell and if it starts with the assignment operator attempts to parse a formula from it.

Specified by:
setContent in interface Cell
Throws:
FormulaCompilationException - if an incorrectly formatted formula was entered

clear

public void clear()
Description copied from interface: Cell
Clears the content of the cell.

Specified by:
clear in interface Cell

getPrecedents

public final SortedSet<Cell> getPrecedents()
Description copied from interface: Cell
Returns the precedents of the cell, i.e. the cells that the formula in the cell references.

Specified by:
getPrecedents in interface Cell
Returns:
a set of the cell's precedents

getDependents

public final SortedSet<Cell> getDependents()
Description copied from interface: Cell
Returns the dependents of the cell, i.e. the cells that contain a reference to the cell in their formula.

Specified by:
getDependents in interface Cell
Returns:
a set of the cells which depend on the cell

copyFrom

public final void copyFrom(Cell source)
Description copied from interface: Cell
Copies all data from the source cell to this one.

Specified by:
copyFrom in interface Cell
Parameters:
source - the cell from which data should be copied

moveFrom

public final void moveFrom(Cell source)
Description copied from interface: Cell
Moves all data from the source cell to this one.

Specified by:
moveFrom in interface Cell
Parameters:
source - the cell from which data should be moved

addCellListener

public final void addCellListener(CellListener listener)
Description copied from interface: Cell
Registers the given listener on the cell.

Specified by:
addCellListener in interface Cell
Parameters:
listener - the listener to be added

removeCellListener

public final void removeCellListener(CellListener listener)
Description copied from interface: Cell
Removes the given listener from the cell.

Specified by:
removeCellListener in interface Cell
Parameters:
listener - the listener to be removed

getCellListeners

public final CellListener[] getCellListeners()
Description copied from interface: Cell
Returns the listeners that have been registered on the cell.

Specified by:
getCellListeners in interface Cell
Returns:
the listeners that have been registered on the cell

getExtension

public final Cell getExtension(String name)
Description copied from interface: Extensible
Returns the extension with the given key.

Specified by:
getExtension in interface Extensible<Cell>
Parameters:
name - the name of the extension (case-insensitive)
Returns:
the appropriate extension, or null if no extension with the given name was found

compareTo

public final int compareTo(Cell cell)
Specified by:
compareTo in interface Comparable<Cell>

toString

public final String toString()
Overrides:
toString in class Object

valueChanged

public void valueChanged(Cell cell)
Description copied from interface: CellListener
Invoked when the value of a cell has changed, either by a change in its content, or by a change of value in one of its precedents.

Specified by:
valueChanged in interface CellListener
Parameters:
cell - the cell that was modified

contentChanged

public void contentChanged(Cell cell)
Description copied from interface: CellListener
Invoked when the content of a cell has been changed. As a consequence, the cell's formula and its precedents may have changed.

Specified by:
contentChanged in interface CellListener
Parameters:
cell - the cell that was modified

dependentsChanged

public void dependentsChanged(Cell cell)
Description copied from interface: CellListener
Invoked when a new dependent has been registered on a cell, or when an old one has been removed.

Specified by:
dependentsChanged in interface CellListener
Parameters:
cell - the cell that was modified

cellCleared

public void cellCleared(Cell cell)
Description copied from interface: CellListener
Invoked when a cell has been cleared.

Specified by:
cellCleared in interface CellListener
Parameters:
cell - the cell that was modified

cellCopied

public void cellCopied(Cell cell,
                       Cell source)
Description copied from interface: CellListener
Invoked when a cell has been copied.

Specified by:
cellCopied in interface CellListener
Parameters:
cell - the cell that was modified
source - the cell from which data was copied