JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.datasource
Class BaseVirtualColumn

java.lang.Object
  |
  +--com.klg.jclass.datasource.BaseColumn
        |
        +--com.klg.jclass.datasource.BaseVirtualColumn
All Implemented Interfaces:
ColumnModel, Serializable, VirtualColumnModel

public class BaseVirtualColumn
extends BaseColumn
implements VirtualColumnModel

Adds columns to rows which are not retrieved from the data source. This class allows you to add columns which are derived by performing an operation on one or more other columns in the row to arrive at a new value.

The basic supported operations are:

Operations can be performed on one or more columns. Columns are evaluated from left to right. Virutal columns can be used in calculations for other virtual columns in the row.

See Also:
Serialized Form

Field Summary
static int AVERAGE
           
protected  String[] columns
           
static int DIFFERENCE
           
static int MAX
           
static int MIN
           
protected  int operation
           
static int PRODUCT
           
static int QUOTIENT
           
protected  int roundMode
           
protected  int scale
           
static int SUM
           
 
Fields inherited from class com.klg.jclass.datasource.BaseColumn
catalog, columnClassName, displayWidth, identifier, isAutoIncrement, isCaseSensitive, isCurrency, isDefinitelyWritable, isNullable, isReadOnly, isSearchable, isSigned, isWritable, label, metaType, name, NOT_SET, precision, schema, table, type, typeName
 
Constructor Summary
BaseVirtualColumn(String name, int type, int operation, String[] columns)
          Creates a column which is calculated based on one or more data source columns.
 
Method Summary
 String[] getColumns()
          Returns the list of names of the columns used to derive the virtual column.
 int getOperation()
          Returns the operation.
 Object getResultData(com.klg.jclass.datasource.DataTableModel dtm, long bookmark)
          Returns the value calculated by performing operation on columns .
 int getRoundMode()
          Returns the roundMode.
 int getScale(int scale)
          Returns the scale which is used when dividing.
 boolean isReadOnly()
           
 void setReadOnly(boolean isReadOnly)
           
 void setRoundMode(int roundMode)
          Sets the roundMode to be used when dividing.
 void setScale(int scale)
          Sets the scale to be used when dividing.
 
Methods inherited from class com.klg.jclass.datasource.BaseColumn
getCatalogName, getColumnClassName, getColumnDisplaySize, getColumnLabel, getColumnName, getColumnType, getColumnTypeName, getIdentifier, getMetaColumnType, getPrecision, getScale, getSchemaName, getTableName, isAutoIncrement, isCaseSensitive, isCurrency, isDefinitelyWritable, isNullable, isSearchable, isSigned, isTimeDate, isWritable, setAutoIncrement, setCaseSensitive, setCatalogName, setColumnClassName, setColumnDisplaySize, setColumnLabel, setColumnName, setColumnType, setColumnTypeName, setCurrency, setDefinitelyWritable, setIdentifier, setMetaColumnType, setMetaColumnTypeFromSqlType, setNullable, setPrecision, setSchemaName, setSearchable, setSigned, setTableName, setWritable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.klg.jclass.datasource.ColumnModel
getCatalogName, getColumnClassName, getColumnDisplaySize, getColumnLabel, getColumnName, getColumnType, getColumnTypeName, getIdentifier, getMetaColumnType, getPrecision, getScale, getSchemaName, getTableName, isAutoIncrement, isCaseSensitive, isCurrency, isDefinitelyWritable, isNullable, isSearchable, isSigned, isTimeDate, isWritable, setAutoIncrement, setCaseSensitive, setCatalogName, setColumnClassName, setColumnDisplaySize, setColumnLabel, setColumnName, setColumnType, setColumnTypeName, setCurrency, setDefinitelyWritable, setIdentifier, setMetaColumnType, setMetaColumnTypeFromSqlType, setNullable, setPrecision, setSchemaName, setSearchable, setSigned, setTableName, setWritable
 

Field Detail

MIN

public static final int MIN
See Also:
Constant Field Values

MAX

public static final int MAX
See Also:
Constant Field Values

AVERAGE

public static final int AVERAGE
See Also:
Constant Field Values

SUM

public static final int SUM
See Also:
Constant Field Values

DIFFERENCE

public static final int DIFFERENCE
See Also:
Constant Field Values

PRODUCT

public static final int PRODUCT
See Also:
Constant Field Values

QUOTIENT

public static final int QUOTIENT
See Also:
Constant Field Values

operation

protected int operation

columns

protected String[] columns

scale

protected int scale

roundMode

protected int roundMode
Constructor Detail

BaseVirtualColumn

public BaseVirtualColumn(String name,
                         int type,
                         int operation,
                         String[] columns)
Creates a column which is calculated based on one or more data source columns. For example,

     String name = "difference";
     int type = java.sql.Types.INTEGER;
     int operation = BaseVirtualColumn.DIFFERENCE;
     String columns[] = {"colA", "colB", "colC"}
     BaseVirtualColumn bvc = new BaseVirtualColumn(name, type, operation, columns);
 
This example is equivalent to the difference calculation colA - colB - colC.

Parameters:
name - the String name of the column to be displayed.
type - the java.sql.Types type of the column, will be automatically mapped to a MetaDataModel type.
operation - an int constant one of MIN, MAX, AVERAGE, SUM, PRODUCT, QUOTIENT, DIFFERENCE.
columns - an array of column identifiers indicating which columns to use in the operation.
Method Detail

getResultData

public Object getResultData(com.klg.jclass.datasource.DataTableModel dtm,
                            long bookmark)
                     throws DataModelException
Returns the value calculated by performing operation on columns .

Specified by:
getResultData in interface VirtualColumnModel
Parameters:
bookmark - a long which uniquely identifies a row.
Returns:
the value calculated by performing operation on columns.
Throws:
DataModelException - If the operation fails.

setScale

public void setScale(int scale)
Sets the scale to be used when dividing. The default value is 5.

Specified by:
setScale in interface ColumnModel
Overrides:
setScale in class BaseColumn
Parameters:
scale - an int which indicates the scale.
See Also:
getScale(int), BigDecimal

getScale

public int getScale(int scale)
Returns the scale which is used when dividing. The default value is 5.

Returns:
the scale.
See Also:
setScale(int), BigDecimal

setRoundMode

public void setRoundMode(int roundMode)
Sets the roundMode to be used when dividing. The default mode is BigDecimal.ROUND_CEILING.

Parameters:
roundMode - an int on of the java.math.BigDecimal roundMode constants.
See Also:
BigDecimal

getRoundMode

public int getRoundMode()
Returns the roundMode. The default mode is BigDecimal.ROUND_CEILING.

Returns:
the method used to round numbers when dividing.
See Also:
BigDecimal

getOperation

public int getOperation()
Returns the operation.

Returns:
the operation to be performed, one of
  • MIN
  • MAX
  • AVERAGE
  • SUM
  • PRODUCT
  • QUOTIENT
  • DIFFERENCE

getColumns

public String[] getColumns()
Returns the list of names of the columns used to derive the virtual column.

Returns:
a String[] array of the column names.

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface ColumnModel
Overrides:
isReadOnly in class BaseColumn

setReadOnly

public void setReadOnly(boolean isReadOnly)
Specified by:
setReadOnly in interface ColumnModel
Overrides:
setReadOnly in class BaseColumn

Copyright © 2004 Quest Software Inc..
All rights reserved.