Bean Sheet defines a number of Bean Shell-style commands. Other commands can be defined as per Bean Shell specification. All commands described below adhere to the following rules:
Commands that work on cell ranges guarantee setting of cell dependencies to the cells in the range by way of either explicitly calling model.requestDependency method or by invoking functions or methods that result in the required dependency.
Cell ranges are represented by Iterator objects that iterate through Point objects, whose x and y fields represent data model column and row indexes respectively.
double avg(Iterator range)
Returns a numerical average of cell values in the range provided.
Iterator condition(Iterator iterator, String expression)
Returns an iterator that iterates through a subset of elements returned by iterator based on evaluation of expression for each element. At the time of evaluation of this expression, a variable is put into the namespace under the key val whose value is the element being tested. If the result of expression evaluation is boolean or Boolean and is true, the element being tested is returned by the resulting iterator. A typical use of this command is for defining subranges based on certain filtering conditions. In such a context, val denotes the coordinate of a cell, rather than its value and so deref should be used to obtain the value itself.
boolean contains(int col, int row, String text, boolean caseInsensitive)
boolean contains(Point coord, int dx, int dy, String text, boolean caseInsensitive)
boolean contains(Point coord, String text, boolean caseInsensitive)
Tests whether the cell indicated by its coordinates contains a value (raw, evaluated, or formatted) that contains specified text. The primary purpose for this function is for condition and highlight expressions.
int count(Iterator iterator)
Returns the number of elements returned by the iterator. Typically used in conjuction with condition.
Object deref(int x, int y)
Object deref(Point coord, int dx, int dy)
Object deref(Point coord)
Returns the value of the cell indicated by its coordinates and sets up a dependency to the current cell (cell at position (col, row)). In the case of using coordinate offsets (dx and dy), the result is deref(coord.x + dx, coord.y + dy).
Iterator highlight(Iterator iterator, String expression, Appearance trueAppearance, Appearance falseAppearance)
Iterator highlight(Iterator iterator, String expression, Color trueBgColor, Color falseBgColor)
Returns an Iterator that iterates through a subset of elements much like condition, except it highlights results of expression evaluation as it steps through underlying iterator object. This function requires that iterator be in compliance with Bean Sheet's range iteration rules.
Object max(Iterator range)
Returns the maximum value from cell range. Values in the range must be either primitive numerical types or implementations of Comparable interface.
Object min(Iterator range)
Returns the minimum value from cell range. Values in the range must be either primitive numerical types or implementations of Comparable interface.
java.util.Date now()
Shorthand for setCell(new java.util.Date()).
Iterator range(String rangeString)
Returns a cell range iterator specified by rangeString. With the current syntax supporting [<col name><row index>:<col name><row index>] range notation, this command rarely needs to be explicitly called.
Object setCell(Object val)
Returns and sets current cell's value to val.
double sum(Iterator range)
Returns a numerical sum of cell values in the range provided.