prefuse.data.column
Class ExpressionColumn

java.lang.Object
  extended by prefuse.data.column.AbstractColumn
      extended by prefuse.data.column.ExpressionColumn
All Implemented Interfaces:
Column

public class ExpressionColumn
extends AbstractColumn

Column instance that stores values provided by an Expression instance. These expressions can reference other column values within the same table. Values are evaluated when first requested and then cached to increase performance. This column maintains listeners for all referenced columns discovered in the expression and for the expression itself, invalidating all cached entries when an update to either occurs.

WARNING: Infinite recursion, eventually resulting in a StackOverflowError, could occur if an expression refers to its own column, or if two ExpressionColumns have expressions referring to each other. The responsibility for avoiding such situations is left with client programmers. Note that it is fine for one ExpressionColumn to reference another; however, the graph induced by such references must not contain any cycles.

Author:
jeffrey heer
See Also:
prefuse.data.expression

Field Summary
 
Fields inherited from class prefuse.data.column.AbstractColumn
m_columnType, m_defaultValue, m_listeners, m_parser, m_readOnly
 
Constructor Summary
ExpressionColumn(Table table, Expression expr)
          Create a new ExpressionColumn.
 
Method Summary
 boolean canSet(java.lang.Class type)
          Indicates if the set method can be called without an exception being thrown for the given type.
 java.lang.Object get(int row)
          Get the data value at the specified row
 boolean getBoolean(int row)
          Get the data value at the specified row as a boolean
 double getDouble(int row)
          Get the data value at the specified row as a double
 float getFloat(int row)
          Get the data value at the specified row as a float
 int getInt(int row)
          Get the data value at the specified row as an integer
 long getLong(int row)
          Get the data value at the specified row as a long
 int getRowCount()
          Returns the number of rows in this data column
protected  void init()
           
 void invalidateCache(int start, int end)
          Invalidate a range of the cache.
 boolean isCacheValid(int row)
          Check if this ExpressionColumn has a valid cached value at the given row.
 void revertToDefault(int row)
          Has no effect, as all values in this column are derived.
 void set(java.lang.Object val, int row)
          Set the data value at the specified row
 void setMaximumRow(int nrows)
          Sets the number of rows in this data column
 
Methods inherited from class prefuse.data.column.AbstractColumn
addColumnListener, canGet, canGetBoolean, canGetDate, canGetDouble, canGetFloat, canGetInt, canGetLong, canGetString, canSetBoolean, canSetDate, canSetDouble, canSetFloat, canSetInt, canSetLong, canSetString, fireColumnEvent, fireColumnEvent, fireColumnEvent, fireColumnEvent, fireColumnEvent, fireColumnEvent, fireColumnEvent, getColumnType, getDate, getDefaultValue, getParser, getString, isCellEditable, isReadOnly, removeColumnListener, setBoolean, setDate, setDefaultValue, setDouble, setFloat, setInt, setLong, setParser, setReadOnly, setString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionColumn

public ExpressionColumn(Table table,
                        Expression expr)
Create a new ExpressionColumn.

Parameters:
table - the table this column is a member of
expr - the expression used to provide the column values
Method Detail

init

protected void init()

getRowCount

public int getRowCount()
Description copied from interface: Column
Returns the number of rows in this data column

Returns:
the number of rows
See Also:
Column.getRowCount()

setMaximumRow

public void setMaximumRow(int nrows)
Description copied from interface: Column
Sets the number of rows in this data column

Parameters:
nrows - the number of rows
See Also:
Column.setMaximumRow(int)

isCacheValid

public boolean isCacheValid(int row)
Check if this ExpressionColumn has a valid cached value at the given row.

Parameters:
row - the row to check for a valid cache entry
Returns:
true if the cache row is valid, false otherwise

invalidateCache

public void invalidateCache(int start,
                            int end)
Invalidate a range of the cache.

Parameters:
start - the start of the range to invalidate
end - the end of the range to invalidate, inclusive

revertToDefault

public void revertToDefault(int row)
Has no effect, as all values in this column are derived.

Specified by:
revertToDefault in interface Column
Overrides:
revertToDefault in class AbstractColumn
Parameters:
row - the row to revert

canSet

public boolean canSet(java.lang.Class type)
Description copied from class: AbstractColumn
Indicates if the set method can be called without an exception being thrown for the given type.

Specified by:
canSet in interface Column
Overrides:
canSet in class AbstractColumn
Parameters:
type - the Class of the data type to check
Returns:
true if the type is supported by this column, false otherwise
See Also:
AbstractColumn.canSet(java.lang.Class)

get

public java.lang.Object get(int row)
Description copied from interface: Column
Get the data value at the specified row

Parameters:
row - the row from which to retrieve the value
Returns:
the data value
See Also:
Column.get(int)

set

public void set(java.lang.Object val,
                int row)
         throws DataTypeException
Description copied from interface: Column
Set the data value at the specified row

Parameters:
val - the value to set
row - the row at which to set the value
Throws:
DataTypeException
See Also:
Column.set(java.lang.Object, int)

getBoolean

public boolean getBoolean(int row)
                   throws DataTypeException
Description copied from class: AbstractColumn
Get the data value at the specified row as a boolean

Specified by:
getBoolean in interface Column
Overrides:
getBoolean in class AbstractColumn
Parameters:
row - the row from which to retrieve the value
Returns:
the data value as a boolean
Throws:
DataTypeException - if this column does not support the boolean type
See Also:
Column.getBoolean(int)

getInt

public int getInt(int row)
           throws DataTypeException
Description copied from class: AbstractColumn
Get the data value at the specified row as an integer

Specified by:
getInt in interface Column
Overrides:
getInt in class AbstractColumn
Parameters:
row - the row from which to retrieve the value
Returns:
the data value as an integer
Throws:
DataTypeException - if this column does not support the integer type
See Also:
Column.getInt(int)

getDouble

public double getDouble(int row)
                 throws DataTypeException
Description copied from class: AbstractColumn
Get the data value at the specified row as a double

Specified by:
getDouble in interface Column
Overrides:
getDouble in class AbstractColumn
Parameters:
row - the row from which to retrieve the value
Returns:
the data value as a double
Throws:
DataTypeException - if this column does not support the double type
See Also:
Column.getDouble(int)

getFloat

public float getFloat(int row)
               throws DataTypeException
Description copied from class: AbstractColumn
Get the data value at the specified row as a float

Specified by:
getFloat in interface Column
Overrides:
getFloat in class AbstractColumn
Parameters:
row - the row from which to retrieve the value
Returns:
the data value as a float
Throws:
DataTypeException - if this column does not support the float type
See Also:
Column.getFloat(int)

getLong

public long getLong(int row)
             throws DataTypeException
Description copied from class: AbstractColumn
Get the data value at the specified row as a long

Specified by:
getLong in interface Column
Overrides:
getLong in class AbstractColumn
Parameters:
row - the row from which to retrieve the value
Returns:
the data value as a long
Throws:
DataTypeException - if this column does not support the long type
See Also:
Column.getLong(int)


Copyright © 2007 Regents of the University of California