org.formulacompiler.spreadsheet
Interface SpreadsheetBuilder


public interface SpreadsheetBuilder

This interface allows you to build a spreadsheet representation in memory from scratch. Used instead of loading one from a file or other source.

This interface is an API only. Do not implement it yourself.

See the tutorial for details.

Author:
peo
See Also:
SpreadsheetCompiler.newSpreadsheetBuilder()

Nested Class Summary
static interface SpreadsheetBuilder.CellRef
          Opaque handle for a constructed cell in a spreadsheet, used to reference the cell again in the expression of other, calculated cells.
static interface SpreadsheetBuilder.Constant
          Opaque handle for a constant value supported by the spreadsheet builder.
static interface SpreadsheetBuilder.ExprNode
          Opaque handle for an node of an expression tree used to define calculated cells.
static interface SpreadsheetBuilder.Factory
          Factory interface for ImplementationLocator.getInstance(Class).
static interface SpreadsheetBuilder.RangeRef
          Opaque handle for a range in a spreadsheet, used to reference the range again in the expression of other, calculated cells.
 
Method Summary
 SpreadsheetBuilder.Constant cst(boolean _const)
          Returns a boolean constant value.
 SpreadsheetBuilder.Constant cst(java.util.Date _const)
          Returns a date constant value.
 SpreadsheetBuilder.Constant cst(java.lang.Number _const)
          Returns a numeric constant value.
 SpreadsheetBuilder.Constant cst(java.lang.String _const)
          Returns a string constant value.
 SpreadsheetBuilder.CellRef currentCell()
          Returns a reference to the cell created last.
 SpreadsheetBuilder.ExprNode fun(Function _fun, SpreadsheetBuilder.ExprNode... _args)
          Returns an expression tree node which applies a function to the values of its argument nodes.
 Spreadsheet getSpreadsheet()
          Returns the constructed spreadsheet.
 SpreadsheetBuilder nameCell(java.lang.String _name)
          Defines a name for the cell created last.
 SpreadsheetBuilder nameRange(SpreadsheetBuilder.RangeRef _range, java.lang.String _name)
          Defines a name for the given range.
 SpreadsheetBuilder newCell()
          Creates a new, blank cell in the current row.
 SpreadsheetBuilder newCell(SpreadsheetBuilder.Constant _const)
          Creates a new cell in the current row with a constant value.
 SpreadsheetBuilder newCell(SpreadsheetBuilder.ExprNode _expr)
          Creates a new, calculated cell in the current row, with the given expression tree defining its formula.
 SpreadsheetBuilder newRow()
          Terminates the current row and starts a new, empty one in the current sheet.
 SpreadsheetBuilder newSheet()
          Terminates the current sheet and starts a new one, with a new, empty first row.
 SpreadsheetBuilder.ExprNode op(Operator _op, SpreadsheetBuilder.ExprNode... _args)
          Returns an expression tree node which applies an operator to the values of its argument nodes.
 SpreadsheetBuilder.RangeRef range(SpreadsheetBuilder.CellRef _oneCorner, SpreadsheetBuilder.CellRef _otherCorner)
          Returns a range defined by two diagonally opposed corner cells.
 SpreadsheetBuilder.ExprNode ref(SpreadsheetBuilder.CellRef _cell)
          Returns an expression tree node which evaluates to the value of another cell, defined earlier.
 SpreadsheetBuilder.ExprNode ref(SpreadsheetBuilder.Constant _const)
          Returns an expression tree node which always evaluates to the given, constant value.
 SpreadsheetBuilder.ExprNode ref(SpreadsheetBuilder.RangeRef _rng)
          Returns an expression tree node which specifies a range of cells, defined earlier.
 SpreadsheetBuilder styleCell(java.lang.String _styleName)
          Remembers a style name for this cell for use by the SpreadsheetSaver.
 SpreadsheetBuilder styleRow(java.lang.String _styleName)
          Remembers a style name for this row for use by the SpreadsheetSaver.
 

Method Detail

getSpreadsheet

Spreadsheet getSpreadsheet()
Returns the constructed spreadsheet. Must always be called as the last method of instances of this class.


newSheet

SpreadsheetBuilder newSheet()
Terminates the current sheet and starts a new one, with a new, empty first row.

Returns:
this (for call chaining).
See Also:
Spreadsheet.Sheet

newRow

SpreadsheetBuilder newRow()
Terminates the current row and starts a new, empty one in the current sheet.

Returns:
this (for call chaining).
See Also:
Spreadsheet.Row

styleRow

SpreadsheetBuilder styleRow(java.lang.String _styleName)
Remembers a style name for this row for use by the SpreadsheetSaver.

Parameters:
_styleName - is an arbitrary string used by the SpreadsheetSaver.
Returns:
this (for call chaining).

newCell

SpreadsheetBuilder newCell(SpreadsheetBuilder.Constant _const)
Creates a new cell in the current row with a constant value.

Parameters:
_const - is the value of the new cell.
Returns:
this (for call chaining).
See Also:
Spreadsheet.Cell

newCell

SpreadsheetBuilder newCell(SpreadsheetBuilder.ExprNode _expr)
Creates a new, calculated cell in the current row, with the given expression tree defining its formula.

Parameters:
_expr - is the expression tree defining the cell's formula.
Returns:
this (for call chaining).
See Also:
Spreadsheet.Cell

newCell

SpreadsheetBuilder newCell()
Creates a new, blank cell in the current row.

Returns:
this (for call chaining).
See Also:
Spreadsheet.Cell

nameCell

SpreadsheetBuilder nameCell(java.lang.String _name)
Defines a name for the cell created last.

Parameters:
_name - is the name for the cell. Must be unique in the spreadsheet.
Returns:
this (for call chaining).
See Also:
newCell(org.formulacompiler.spreadsheet.SpreadsheetBuilder.Constant), newCell(org.formulacompiler.spreadsheet.SpreadsheetBuilder.ExprNode), Spreadsheet.getCell(String), Spreadsheet.getRange(String)

styleCell

SpreadsheetBuilder styleCell(java.lang.String _styleName)
Remembers a style name for this cell for use by the SpreadsheetSaver.

Parameters:
_styleName - is an arbitrary string used by the SpreadsheetSaver.
Returns:
this (for call chaining).

currentCell

SpreadsheetBuilder.CellRef currentCell()
Returns a reference to the cell created last. Use it to reference the cell in formulas for other, calculated cells.

Returns:
this (for call chaining).
See Also:
ref(org.formulacompiler.spreadsheet.SpreadsheetBuilder.CellRef)

range

SpreadsheetBuilder.RangeRef range(SpreadsheetBuilder.CellRef _oneCorner,
                                  SpreadsheetBuilder.CellRef _otherCorner)
Returns a range defined by two diagonally opposed corner cells.

Parameters:
_oneCorner - is one of the two corners defining the range.
_otherCorner - is the other of the two corners defining the range.

nameRange

SpreadsheetBuilder nameRange(SpreadsheetBuilder.RangeRef _range,
                             java.lang.String _name)
Defines a name for the given range.

Parameters:
_name - is the name for the range. Must be unique in the spreadsheet.
Returns:
this (for call chaining).
See Also:
Spreadsheet.getRange(String)

cst

SpreadsheetBuilder.Constant cst(java.lang.Number _const)
Returns a numeric constant value.


cst

SpreadsheetBuilder.Constant cst(java.lang.String _const)
Returns a string constant value.


cst

SpreadsheetBuilder.Constant cst(java.util.Date _const)
Returns a date constant value.


cst

SpreadsheetBuilder.Constant cst(boolean _const)
Returns a boolean constant value.


ref

SpreadsheetBuilder.ExprNode ref(SpreadsheetBuilder.CellRef _cell)
Returns an expression tree node which evaluates to the value of another cell, defined earlier.

Parameters:
_cell - is the reference to the other cell.
See Also:
currentCell()

ref

SpreadsheetBuilder.ExprNode ref(SpreadsheetBuilder.RangeRef _rng)
Returns an expression tree node which specifies a range of cells, defined earlier.

Parameters:
_rng - is the reference to the range.
See Also:
range(org.formulacompiler.spreadsheet.SpreadsheetBuilder.CellRef, org.formulacompiler.spreadsheet.SpreadsheetBuilder.CellRef)

ref

SpreadsheetBuilder.ExprNode ref(SpreadsheetBuilder.Constant _const)
Returns an expression tree node which always evaluates to the given, constant value.

Parameters:
_const - is the constant.

op

SpreadsheetBuilder.ExprNode op(Operator _op,
                               SpreadsheetBuilder.ExprNode... _args)
Returns an expression tree node which applies an operator to the values of its argument nodes.

Parameters:
_op - is the operator.
_args - is the list of arguments. The number of arguments depends on the operator. Most operators need two arguments.

fun

SpreadsheetBuilder.ExprNode fun(Function _fun,
                                SpreadsheetBuilder.ExprNode... _args)
Returns an expression tree node which applies a function to the values of its argument nodes.

Parameters:
_fun - is the function.
_args - is the list of arguments. The number of arguments depends on the function.