JIDE 3.5.15

com.jidesoft.grid
Class ExpressionCalculatedColumn

java.lang.Object
  extended by javax.swing.table.TableColumn
      extended by com.jidesoft.grid.AbstractCalculatedColumn
          extended by com.jidesoft.grid.ExpressionCalculatedColumn
All Implemented Interfaces:
CalculatedColumn, Serializable

public class ExpressionCalculatedColumn
extends AbstractCalculatedColumn

ExpressionCalculatedColumn is a special CalculatedColumn that can accept a string as expression. For example, if your table model has a Quality column and an UnitPrice column, you can write an expression string like "[Quality] * [UnitPrice]" to calculate for this Sales column using ExpressionCalculatedColumn.

For performance consideration, if you know the depending columns beforehand, it is better you call setDependingColumns(int[]) to set it. By doing this, the expression calculation method will not look at other columns.

For details of the expression grammar, please refer to JIDE Pivot Grids Developer Guide "Expression For ExpressionCalculatedColumn" section.

For ExpressionCalculatedColumn, we have to get some related information from the depending columns. So please make sure the table model you passed in as a parameter has the information of the depending columns.

See Also:
Serialized Form

Field Summary
 List<String> _dependingColumnNames
           
 
Fields inherited from class javax.swing.table.TableColumn
CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, COLUMN_WIDTH_PROPERTY, HEADER_RENDERER_PROPERTY, HEADER_VALUE_PROPERTY, headerRenderer, headerValue, identifier, isResizable, maxWidth, minWidth, modelIndex, resizedPostingDisableCount, width
 
Constructor Summary
ExpressionCalculatedColumn(TableModel model, String expressionString)
           
ExpressionCalculatedColumn(TableModel model, String newColumnName, String expressionString)
           
 
Method Summary
 int[] getDependingColumns()
          Gets the depending columns.
 String getExpressionString()
          Gets the expression string.
 Object getValueAt(int rowIndex)
          Gets the value at the cell of the row index.
 void setDependingColumns(int[] columns)
          Sets the depending columns.
 void setExpressionString(String expressionString)
          Sets the expression string.
 
Methods inherited from class com.jidesoft.grid.AbstractCalculatedColumn
getActualModel, getColumnClass, getColumnIdentifier, getColumnName, getConverterContext, getEditorContext, getGroupValue, getObjectGrouper, setColumnClass, setColumnName, setConverterContext, setEditorContext, setObjectGrouper
 
Methods inherited from class javax.swing.table.TableColumn
addPropertyChangeListener, createDefaultHeaderRenderer, disableResizedPosting, enableResizedPosting, getCellEditor, getCellRenderer, getHeaderRenderer, getHeaderValue, getIdentifier, getMaxWidth, getMinWidth, getModelIndex, getPreferredWidth, getPropertyChangeListeners, getResizable, getWidth, removePropertyChangeListener, setCellEditor, setCellRenderer, setHeaderRenderer, setHeaderValue, setIdentifier, setMaxWidth, setMinWidth, setModelIndex, setPreferredWidth, setResizable, setWidth, sizeWidthToFit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dependingColumnNames

public List<String> _dependingColumnNames
Constructor Detail

ExpressionCalculatedColumn

public ExpressionCalculatedColumn(TableModel model,
                                  String expressionString)
                           throws IllegalArgumentException
Throws:
IllegalArgumentException

ExpressionCalculatedColumn

public ExpressionCalculatedColumn(TableModel model,
                                  String newColumnName,
                                  String expressionString)
                           throws IllegalArgumentException
Throws:
IllegalArgumentException
Method Detail

getExpressionString

public String getExpressionString()
Gets the expression string.

Returns:
the expression string.

setExpressionString

public void setExpressionString(String expressionString)
                         throws IllegalArgumentException
Sets the expression string. Please refer to JIDE Pivot Grid Developer Guide "Expression For ExpressionCalculatedColumn" section for more information.

Parameters:
expressionString - the new expression string.
Throws:
IllegalArgumentException - if the expressionString is not a valid expression.

getValueAt

public Object getValueAt(int rowIndex)
Description copied from interface: CalculatedColumn
Gets the value at the cell of the row index.

Returns:
the cell value.

setDependingColumns

public void setDependingColumns(int[] columns)
Sets the depending columns. When you write an expression, it will usually refer to one or several columns in the table model. By referring to those columns, it means the value of this column will depend on the value of those columns. When the value of those columns change, we should recalculate the value of this column. By specifying the depending columns, we will automate this recalculation process.

Please note, you don't have to set the depending columns. If you don't, we will automatically find out based on the expression. If you set, we will use the depending columns you set.

Parameters:
columns - the column int array that this column's expression is referring to.

getDependingColumns

public int[] getDependingColumns()
Gets the depending columns.

Returns:
the depending columns. Default is an empty int array.

JIDE 3.5.15