public class CellImpl extends Object implements Cell
Cell
interface.Constructor and Description |
---|
CellImpl(Spreadsheet spreadsheet,
Address address)
Creates a new cell at the given address in the given spreadsheet.
|
CellImpl(Spreadsheet spreadsheet,
Address address,
String content)
Creates a new cell at the given address in the given spreadsheet,
initialized with the given content (not intended to be used directly).
|
Modifier and Type | Method and Description |
---|---|
void |
addCellListener(CellListener listener)
Registers the given listener on the cell.
|
void |
clear()
Clears the content of the cell.
|
int |
compareTo(Cell cell)
Compares this cell with the specified cell for order,
by comparing their addresses.
|
void |
copyFrom(Cell source)
Copies all data from the source cell to this one.
|
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.
|
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.
|
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()
Returns a string representation of the cell.
|
CellImpl(Spreadsheet spreadsheet, Address address)
spreadsheet
- the spreadsheetaddress
- the address of the cellSpreadsheet.getCell(Address)
CellImpl(Spreadsheet spreadsheet, Address address, String content) throws FormulaCompilationException
spreadsheet
- the spreadsheetaddress
- the address of the cellcontent
- the content of the cellExpressionSyntaxException
- if an incorrectly formatted formula was enteredFormulaCompilationException
Spreadsheet.getCell(Address)
public Spreadsheet getSpreadsheet()
Cell
getSpreadsheet
in interface Cell
public Address getAddress()
Cell
getAddress
in interface Cell
public Value getValue()
Cell
public String getContent()
Cell
getContent
in interface Cell
public Formula getFormula()
Cell
getFormula
in interface Cell
public void setContent(String content) throws FormulaCompilationException
Cell
setContent
in interface Cell
FormulaCompilationException
- if an incorrectly formatted formula was enteredpublic SortedSet<Cell> getPrecedents()
Cell
getPrecedents
in interface Cell
public SortedSet<Cell> getDependents()
Cell
getDependents
in interface Cell
public void copyFrom(Cell source)
Cell
public void moveFrom(Cell source)
Cell
public void addCellListener(CellListener listener)
Cell
addCellListener
in interface Cell
listener
- the listener to be addedpublic void removeCellListener(CellListener listener)
Cell
removeCellListener
in interface Cell
listener
- the listener to be removedpublic CellListener[] getCellListeners()
Cell
getCellListeners
in interface Cell
public Cell getExtension(String name)
Extensible
getExtension
in interface Extensible<Cell>
name
- the name of the extension (case-insensitive)public int compareTo(Cell cell)
compareTo
in interface Comparable<Cell>
cell
- the cell to be compared