csheets.core
Class SpreadsheetImpl

java.lang.Object
  extended by csheets.core.SpreadsheetImpl
All Implemented Interfaces:
Spreadsheet, Extensible<Spreadsheet>, Serializable, Iterable<Cell>

public class SpreadsheetImpl
extends Object
implements Spreadsheet

The implementation of the Spreadsheet interface.

Author:
Einar Pehrson
See Also:
Serialized Form

Field Summary
static String BASE_TITLE
          The base of the titles of new spreadsheets
 
Constructor Summary
SpreadsheetImpl(Workbook workbook, String title)
          Creates a new spreadsheet.
SpreadsheetImpl(Workbook workbook, String title, String[][] content)
          Creates a new spreadsheet, in which cells are initialized with data from the given content matrix.
 
Method Summary
 void addCellListener(CellListener listener)
          Registers the given listener to receive events from all cells in the spreadsheet.
 Cell getCell(Address address)
          Returns the cell at the given address.
 Cell getCell(int column, int row)
          Returns the cell at the given column and row in the spreadsheet.
 CellListener[] getCellListeners()
          Returns the cell listeners that have been registered on the spreadsheet.
 SortedSet<Cell> getCells(Address address1, Address address2)
          Returns the cells in the range between the given addresses.
 Cell[] getColumn(int index)
          Returns the cells in the given column.
 int getColumnCount()
          Returns the number of columns in the spreadsheet.
 Spreadsheet getExtension(String name)
          Returns the extension with the given key.
 Cell[] getRow(int index)
          Returns the cells in the given row.
 int getRowCount()
          Returns the number of rows in the spreadsheet.
 String getTitle()
          Returns the title of the spreadsheet.
 Workbook getWorkbook()
          Returns the workbook to which the spreadsheet belongs.
 Iterator<Cell> iterator()
           
 void removeCellListener(CellListener listener)
          Deregisters the given listener from receiving events from all cells in the spreadsheet.
 void setTitle(String title)
          Sets the title of the spreadsheet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_TITLE

public static final String BASE_TITLE
The base of the titles of new spreadsheets

See Also:
Constant Field Values
Constructor Detail

SpreadsheetImpl

SpreadsheetImpl(Workbook workbook,
                String title)
Creates a new spreadsheet.

Parameters:
workbook - the workbook to which the spreadsheet belongs
title - the title of the spreadsheet

SpreadsheetImpl

SpreadsheetImpl(Workbook workbook,
                String title,
                String[][] content)
Creates a new spreadsheet, in which cells are initialized with data from the given content matrix.

Parameters:
workbook - the workbook to which the spreadsheet belongs
title - the title of the spreadsheet
content - the contents of the cells in the spreadsheet
Method Detail

getWorkbook

public Workbook getWorkbook()
Description copied from interface: Spreadsheet
Returns the workbook to which the spreadsheet belongs.

Specified by:
getWorkbook in interface Spreadsheet
Returns:
the workbook to which the spreadsheet belongs

getTitle

public String getTitle()
Description copied from interface: Spreadsheet
Returns the title of the spreadsheet.

Specified by:
getTitle in interface Spreadsheet
Returns:
the title of the spreadsheet.

setTitle

public void setTitle(String title)
Description copied from interface: Spreadsheet
Sets the title of the spreadsheet.

Specified by:
setTitle in interface Spreadsheet
Parameters:
title - the title of the spreadsheet.

getColumnCount

public int getColumnCount()
Description copied from interface: Spreadsheet
Returns the number of columns in the spreadsheet.

Specified by:
getColumnCount in interface Spreadsheet
Returns:
the number of columns in the spreadsheet.

getRowCount

public int getRowCount()
Description copied from interface: Spreadsheet
Returns the number of rows in the spreadsheet.

Specified by:
getRowCount in interface Spreadsheet
Returns:
the number of rows in the spreadsheet.

getCell

public Cell getCell(Address address)
Description copied from interface: Spreadsheet
Returns the cell at the given address.

Specified by:
getCell in interface Spreadsheet
Parameters:
address - the address of the cell
Returns:
the cell at the given address

getCell

public Cell getCell(int column,
                    int row)
Description copied from interface: Spreadsheet
Returns the cell at the given column and row in the spreadsheet.

Specified by:
getCell in interface Spreadsheet
Parameters:
column - the column index of the cell's location
row - the row index of the cell's location
Returns:
the cell at the given column and row in the spreadsheet

getCells

public SortedSet<Cell> getCells(Address address1,
                                Address address2)
Description copied from interface: Spreadsheet
Returns the cells in the range between the given addresses.

Specified by:
getCells in interface Spreadsheet
Parameters:
address1 - the address of the cell in one end of the range
address2 - the address of the cell in the other end of the range
Returns:
a sorted set of the cells in the range

getColumn

public Cell[] getColumn(int index)
Description copied from interface: Spreadsheet
Returns the cells in the given column.

Specified by:
getColumn in interface Spreadsheet
Parameters:
index - the index of the column
Returns:
an array of the cells in the column

getRow

public Cell[] getRow(int index)
Description copied from interface: Spreadsheet
Returns the cells in the given row.

Specified by:
getRow in interface Spreadsheet
Parameters:
index - the index of the row
Returns:
an array of the cells in the row

iterator

public Iterator<Cell> iterator()
Specified by:
iterator in interface Iterable<Cell>

addCellListener

public void addCellListener(CellListener listener)
Description copied from interface: Spreadsheet
Registers the given listener to receive events from all cells in the spreadsheet.

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

removeCellListener

public void removeCellListener(CellListener listener)
Description copied from interface: Spreadsheet
Deregisters the given listener from receiving events from all cells in the spreadsheet.

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

getCellListeners

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

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

getExtension

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

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