csheets.core
Class Workbook

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

public class Workbook
extends Object
implements Iterable<Spreadsheet>, Serializable

A workbook which can contain several spreadsheets.

Author:
Einar Pehrson
See Also:
Serialized Form

Constructor Summary
Workbook()
          Creates a new empty workbook.
Workbook(int sheets)
          Creates a new workbook, which initially contains the given number of blank spreadsheets.
Workbook(String[][]... contents)
          Creates a new workbook, using the given content matrix to create spreadsheets initially.
 
Method Summary
 void addSpreadsheet()
          Adds a blank spreadsheet to the end of the workbook.
 void addSpreadsheet(String[][] content)
          Adds a new spreadsheet to the workbook, in which cells are initialized with data from the given content matrix.
 void addWorkbookListener(WorkbookListener listener)
          Registers the given listener on the workbook.
 Spreadsheet getSpreadsheet(int index)
          Returns the spreadsheet at the given index.
 int getSpreadsheetCount()
          Returns the number of spreadsheets in the the workbook.
 WorkbookListener[] getWorkbookListeners()
          Returns the listeners that have been registered on the workbook.
 Iterator<Spreadsheet> iterator()
          Returns an iterator over the spreadsheets in the workbook.
 void removeSpreadsheet(Spreadsheet spreadsheet)
          Adds a new blank spreadsheet to the workbook.
 void removeWorkbookListener(WorkbookListener listener)
          Removes the given listener from the workbook.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Workbook

public Workbook()
Creates a new empty workbook.


Workbook

public Workbook(int sheets)
Creates a new workbook, which initially contains the given number of blank spreadsheets.

Parameters:
sheets - the number of sheets to create initially

Workbook

public Workbook(String[][]... contents)
Creates a new workbook, using the given content matrix to create spreadsheets initially.

Parameters:
contents - the content matrices to use when creating spreadsheets
Method Detail

addSpreadsheet

public void addSpreadsheet()
Adds a blank spreadsheet to the end of the workbook.


addSpreadsheet

public void addSpreadsheet(String[][] content)
Adds a new spreadsheet to the workbook, in which cells are initialized with data from the given content matrix.

Parameters:
content - the contents of the cells in the spreadsheet

removeSpreadsheet

public void removeSpreadsheet(Spreadsheet spreadsheet)
Adds a new blank spreadsheet to the workbook.


getSpreadsheet

public Spreadsheet getSpreadsheet(int index)
                           throws IndexOutOfBoundsException
Returns the spreadsheet at the given index.

Parameters:
index - the index of the spreadsheet in the workbook
Returns:
the spreadsheet at the given index
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= |spreadsheets|)

getSpreadsheetCount

public int getSpreadsheetCount()
Returns the number of spreadsheets in the the workbook.

Returns:
the number of spreadsheets in the the workbook

iterator

public Iterator<Spreadsheet> iterator()
Returns an iterator over the spreadsheets in the workbook.

Specified by:
iterator in interface Iterable<Spreadsheet>
Returns:
an iterator over the spreadsheets in the workbook

addWorkbookListener

public void addWorkbookListener(WorkbookListener listener)
Registers the given listener on the workbook.

Parameters:
listener - the listener to be added

removeWorkbookListener

public void removeWorkbookListener(WorkbookListener listener)
Removes the given listener from the workbook.

Parameters:
listener - the listener to be removed

getWorkbookListeners

public WorkbookListener[] getWorkbookListeners()
Returns the listeners that have been registered on the workbook.

Returns:
the listeners that have been registered on the workbook