prefuse.data.column
Class AbstractColumn

java.lang.Object
  extended by prefuse.data.column.AbstractColumn
All Implemented Interfaces:
Column
Direct Known Subclasses:
BooleanColumn, ByteColumn, ConstantColumn, DateColumn, DoubleColumn, ExpressionColumn, FloatColumn, IntColumn, LongColumn, ObjectColumn

public abstract class AbstractColumn
extends java.lang.Object
implements Column

Abstract base class for Column implementations. Provides listener support and default implementations of column methods.

Author:
jeffrey heer

Field Summary
protected  java.lang.Class m_columnType
           
protected  java.lang.Object m_defaultValue
           
protected  CopyOnWriteArrayList m_listeners
           
protected  DataParser m_parser
           
protected  boolean m_readOnly
           
 
Constructor Summary
AbstractColumn()
          Create a new AbstractColumn of type Object.
AbstractColumn(java.lang.Class columnType)
          Create a new AbstractColumn of a given type.
AbstractColumn(java.lang.Class columnType, java.lang.Object defaultValue)
          Create a new AbstractColumn of a given type.
 
Method Summary
 void addColumnListener(ColumnListener listener)
          Adds a listener to be notified when this column changes
 boolean canGet(java.lang.Class type)
          Indicates if the get method can be called without an exception being thrown for the given type.
 boolean canGetBoolean()
          Indicates if convenience get method can be called without an exception being thrown for the boolean type.
 boolean canGetDate()
          Indicates if convenience get method can be called without an exception being thrown for the Date type.
 boolean canGetDouble()
          Indicates if convenience get method can be called without an exception being thrown for the double type.
 boolean canGetFloat()
          Indicates if convenience get method can be called without an exception being thrown for the float type.
 boolean canGetInt()
          Indicates if convenience get method can be called without an exception being thrown for the int type.
 boolean canGetLong()
          Indicates if convenience get method can be called without an exception being thrown for the long type.
 boolean canGetString()
          Indicates if convenience get method can be called without an exception being thrown for the String type.
 boolean canSet(java.lang.Class type)
          Indicates if the set method can be called without an exception being thrown for the given type.
 boolean canSetBoolean()
          Indicates if convenience set method can be called without an exception being thrown for the boolean type.
 boolean canSetDate()
          Indicates if convenience set method can be called without an exception being thrown for the Date type.
 boolean canSetDouble()
          Indicates if convenience set method can be called without an exception being thrown for the double type.
 boolean canSetFloat()
          Indicates if convenience set method can be called without an exception being thrown for the float type.
 boolean canSetInt()
          Indicates if convenience set method can be called without an exception being thrown for the int type.
 boolean canSetLong()
          Indicates if convenience set method can be called without an exception being thrown for the long type.
 boolean canSetString()
          Indicates if convenience set method can be called without an exception being thrown for the String type.
protected  void fireColumnEvent(int idx, boolean prev)
          Notifies all registered listeners of a column UPDATE event
protected  void fireColumnEvent(int idx, double prev)
          Notifies all registered listeners of a column UPDATE event
protected  void fireColumnEvent(int idx, float prev)
          Notifies all registered listeners of a column UPDATE event
protected  void fireColumnEvent(int idx, int prev)
          Notifies all registered listeners of a column UPDATE event
protected  void fireColumnEvent(int type, int start, int end)
          Notifies all registered listeners of a column UPDATE event
protected  void fireColumnEvent(int idx, long prev)
          Notifies all registered listeners of a column UPDATE event
protected  void fireColumnEvent(int idx, java.lang.Object prev)
          Notifies all registered listeners of a column UPDATE event
 boolean getBoolean(int row)
          Get the data value at the specified row as a boolean
 java.lang.Class getColumnType()
          Returns the most specific superclass for the values in the column
 java.util.Date getDate(int row)
          Get the data value at the specified row as a Date
 java.lang.Object getDefaultValue()
          Returns the default value for rows that have not been set explicitly.
 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
 DataParser getParser()
          Get the data parser used to map String values to and from the values stored by this Column.
 java.lang.String getString(int row)
          Get the data value at the specified row as a String
 boolean isCellEditable(int row)
          Indicates if the value at the given row can be edited.
 boolean isReadOnly()
          Indicates if the values in this column are read-only.
 void removeColumnListener(ColumnListener listener)
          Removes a listener, causing it to no longer be notified of changes
 void revertToDefault(int row)
          Reverts the specified row back to the column's default value.
 void setBoolean(boolean val, int row)
          Set the data value at the specified row as a boolean
 void setDate(java.util.Date val, int row)
          Set the data value at the specified row as a Date
 void setDefaultValue(java.lang.Object dflt)
          Sets the default value for this column.
 void setDouble(double val, int row)
          Set the data value at the specified row as a double
 void setFloat(float val, int row)
          Set the data value at the specified row as a float
 void setInt(int val, int row)
          Set the data value at the specified row as an integer
 void setLong(long val, int row)
          Set the data value at the specified row as a long
 void setParser(DataParser parser)
          Set the data parser used to map String values to and from the values stored by this Column.
 void setReadOnly(boolean readOnly)
          Sets if the values in this column are read-only
 void setString(java.lang.String val, int row)
          Set the data value at the specified row as a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface prefuse.data.column.Column
get, getRowCount, set, setMaximumRow
 

Field Detail

m_columnType

protected final java.lang.Class m_columnType

m_parser

protected DataParser m_parser

m_defaultValue

protected java.lang.Object m_defaultValue

m_readOnly

protected boolean m_readOnly

m_listeners

protected CopyOnWriteArrayList m_listeners
Constructor Detail

AbstractColumn

public AbstractColumn()
Create a new AbstractColumn of type Object.


AbstractColumn

public AbstractColumn(java.lang.Class columnType)
Create a new AbstractColumn of a given type.

Parameters:
columnType - the data type stored by this column

AbstractColumn

public AbstractColumn(java.lang.Class columnType,
                      java.lang.Object defaultValue)
Create a new AbstractColumn of a given type.

Parameters:
columnType - the data type stored by this column
defaultValue - the default data value to use
Method Detail

isReadOnly

public boolean isReadOnly()
Indicates if the values in this column are read-only.

Specified by:
isReadOnly in interface Column
Returns:
true if the values can not be edited, false otherwise

setReadOnly

public void setReadOnly(boolean readOnly)
Sets if the values in this column are read-only

Specified by:
setReadOnly in interface Column
Parameters:
readOnly - true to ensure the values can not be edited, false otherwise

isCellEditable

public boolean isCellEditable(int row)
Indicates if the value at the given row can be edited.

Specified by:
isCellEditable in interface Column
Parameters:
row - the row to check
Returns:
true is the value can be modified, false otherwise

getColumnType

public java.lang.Class getColumnType()
Returns the most specific superclass for the values in the column

Specified by:
getColumnType in interface Column
Returns:
the Class of the column's data values

getParser

public DataParser getParser()
Description copied from interface: Column
Get the data parser used to map String values to and from the values stored by this Column.

Specified by:
getParser in interface Column
Returns:
the DataParser used by this Column
See Also:
Column.getParser()

setParser

public void setParser(DataParser parser)
Description copied from interface: Column
Set the data parser used to map String values to and from the values stored by this Column.

Specified by:
setParser in interface Column
Parameters:
parser - the DataParser to use
See Also:
Column.setParser(prefuse.data.parser.DataParser)

addColumnListener

public void addColumnListener(ColumnListener listener)
Adds a listener to be notified when this column changes

Specified by:
addColumnListener in interface Column
Parameters:
listener - the ColumnListener to add

removeColumnListener

public void removeColumnListener(ColumnListener listener)
Removes a listener, causing it to no longer be notified of changes

Specified by:
removeColumnListener in interface Column
Parameters:
listener - the ColumnListener to remove

fireColumnEvent

protected final void fireColumnEvent(int type,
                                     int start,
                                     int end)
Notifies all registered listeners of a column UPDATE event


fireColumnEvent

protected final void fireColumnEvent(int idx,
                                     int prev)
Notifies all registered listeners of a column UPDATE event

Parameters:
idx - the row index of the column that was updated
prev - the previous value at the given index

fireColumnEvent

protected final void fireColumnEvent(int idx,
                                     long prev)
Notifies all registered listeners of a column UPDATE event

Parameters:
idx - the row index of the column that was updated
prev - the previous value at the given index

fireColumnEvent

protected final void fireColumnEvent(int idx,
                                     float prev)
Notifies all registered listeners of a column UPDATE event

Parameters:
idx - the row index of the column that was updated
prev - the previous value at the given index

fireColumnEvent

protected final void fireColumnEvent(int idx,
                                     double prev)
Notifies all registered listeners of a column UPDATE event

Parameters:
idx - the row index of the column that was updated
prev - the previous value at the given index

fireColumnEvent

protected final void fireColumnEvent(int idx,
                                     boolean prev)
Notifies all registered listeners of a column UPDATE event

Parameters:
idx - the row index of the column that was updated
prev - the previous value at the given index

fireColumnEvent

protected final void fireColumnEvent(int idx,
                                     java.lang.Object prev)
Notifies all registered listeners of a column UPDATE event

Parameters:
idx - the row index of the column that was updated
prev - the previous value at the given index

getDefaultValue

public java.lang.Object getDefaultValue()
Returns the default value for rows that have not been set explicitly.

Specified by:
getDefaultValue in interface Column

setDefaultValue

public void setDefaultValue(java.lang.Object dflt)
Sets the default value for this column. Rows previously added under a different default value will not be changed as a result of this method; the new default will apply to newly added rows only.

Parameters:
dflt -

revertToDefault

public void revertToDefault(int row)
Reverts the specified row back to the column's default value.

Specified by:
revertToDefault in interface Column
Parameters:
row -

canGet

public boolean canGet(java.lang.Class type)
Indicates if the get method can be called without an exception being thrown for the given type.

Specified by:
canGet in interface Column
Parameters:
type - the Class of the data type to check
Returns:
true if the type is supported by this column, false otherwise

canSet

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

Specified by:
canSet in interface Column
Parameters:
type - the Class of the data type to check
Returns:
true if the type is supported by this column, false otherwise

canGetInt

public boolean canGetInt()
Indicates if convenience get method can be called without an exception being thrown for the int type.

Specified by:
canGetInt in interface Column
Returns:
true if getInt is supported, false otherwise

canSetInt

public boolean canSetInt()
Indicates if convenience set method can be called without an exception being thrown for the int type.

Specified by:
canSetInt in interface Column
Returns:
true if setInt is supported, false otherwise

getInt

public int getInt(int row)
           throws DataTypeException
Get the data value at the specified row as an integer

Specified by:
getInt in interface Column
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

setInt

public void setInt(int val,
                   int row)
            throws DataTypeException
Set the data value at the specified row as an integer

Specified by:
setInt in interface Column
Parameters:
val - the value to set
row - the row at which to set the value
Throws:
DataTypeException - if this column does not support the integer type

canGetLong

public boolean canGetLong()
Indicates if convenience get method can be called without an exception being thrown for the long type.

Specified by:
canGetLong in interface Column
Returns:
true if getLong is supported, false otherwise

canSetLong

public boolean canSetLong()
Indicates if convenience set method can be called without an exception being thrown for the long type.

Specified by:
canSetLong in interface Column
Returns:
true if setLong is supported, false otherwise

getLong

public long getLong(int row)
             throws DataTypeException
Get the data value at the specified row as a long

Specified by:
getLong in interface Column
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

setLong

public void setLong(long val,
                    int row)
             throws DataTypeException
Set the data value at the specified row as a long

Specified by:
setLong in interface Column
Parameters:
val - the value to set
row - the row at which to set the value
Throws:
DataTypeException - if this column does not support the long type

canGetFloat

public boolean canGetFloat()
Indicates if convenience get method can be called without an exception being thrown for the float type.

Specified by:
canGetFloat in interface Column
Returns:
true if getFloat is supported, false otherwise

canSetFloat

public boolean canSetFloat()
Indicates if convenience set method can be called without an exception being thrown for the float type.

Specified by:
canSetFloat in interface Column
Returns:
true if setFloat is supported, false otherwise

getFloat

public float getFloat(int row)
               throws DataTypeException
Get the data value at the specified row as a float

Specified by:
getFloat in interface Column
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

setFloat

public void setFloat(float val,
                     int row)
              throws DataTypeException
Set the data value at the specified row as a float

Specified by:
setFloat in interface Column
Parameters:
val - the value to set
row - the row at which to set the value
Throws:
DataTypeException - if this column does not support the float type

canGetDouble

public boolean canGetDouble()
Indicates if convenience get method can be called without an exception being thrown for the double type.

Specified by:
canGetDouble in interface Column
Returns:
true if getDouble is supported, false otherwise

canSetDouble

public boolean canSetDouble()
Indicates if convenience set method can be called without an exception being thrown for the double type.

Specified by:
canSetDouble in interface Column
Returns:
true if setDouble is supported, false otherwise

getDouble

public double getDouble(int row)
                 throws DataTypeException
Get the data value at the specified row as a double

Specified by:
getDouble in interface Column
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

setDouble

public void setDouble(double val,
                      int row)
               throws DataTypeException
Set the data value at the specified row as a double

Specified by:
setDouble in interface Column
Parameters:
val - the value to set
row - the row at which to set the value
Throws:
DataTypeException - if this column does not support the double type

canGetBoolean

public boolean canGetBoolean()
Indicates if convenience get method can be called without an exception being thrown for the boolean type.

Specified by:
canGetBoolean in interface Column
Returns:
true if getBoolean is supported, false otherwise

canSetBoolean

public boolean canSetBoolean()
Indicates if convenience set method can be called without an exception being thrown for the boolean type.

Specified by:
canSetBoolean in interface Column
Returns:
true if setBoolean is supported, false otherwise

getBoolean

public boolean getBoolean(int row)
                   throws DataTypeException
Get the data value at the specified row as a boolean

Specified by:
getBoolean in interface Column
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

setBoolean

public void setBoolean(boolean val,
                       int row)
                throws DataTypeException
Set the data value at the specified row as a boolean

Specified by:
setBoolean in interface Column
Parameters:
val - the value to set
row - the row at which to set the value
Throws:
DataTypeException - if this column does not support the boolean type

canGetString

public boolean canGetString()
Indicates if convenience get method can be called without an exception being thrown for the String type.

Specified by:
canGetString in interface Column
Returns:
true if getString is supported, false otherwise

canSetString

public boolean canSetString()
Indicates if convenience set method can be called without an exception being thrown for the String type.

Specified by:
canSetString in interface Column
Returns:
true if setString is supported, false otherwise

getString

public java.lang.String getString(int row)
                           throws DataTypeException
Get the data value at the specified row as a String

Specified by:
getString in interface Column
Parameters:
row - the row from which to retrieve the value
Returns:
the data value as a String
Throws:
DataTypeException - if this column does not support the String type

setString

public void setString(java.lang.String val,
                      int row)
               throws DataTypeException
Set the data value at the specified row as a String

Specified by:
setString in interface Column
Parameters:
val - the value to set
row - the row at which to set the value
Throws:
DataTypeException - if this column does not support the String type

canGetDate

public boolean canGetDate()
Indicates if convenience get method can be called without an exception being thrown for the Date type.

Specified by:
canGetDate in interface Column
Returns:
true if getDate is supported, false otherwise

canSetDate

public boolean canSetDate()
Indicates if convenience set method can be called without an exception being thrown for the Date type.

Specified by:
canSetDate in interface Column
Returns:
true if setDate is supported, false otherwise

getDate

public java.util.Date getDate(int row)
                       throws DataTypeException
Get the data value at the specified row as a Date

Specified by:
getDate in interface Column
Parameters:
row - the row from which to retrieve the value
Returns:
the data value as a Date
Throws:
DataTypeException - if this column does not support the Date type

setDate

public void setDate(java.util.Date val,
                    int row)
             throws DataTypeException
Set the data value at the specified row as a Date

Specified by:
setDate in interface Column
Parameters:
val - the value to set
row - the row at which to set the value
Throws:
DataTypeException - if this column does not support the Date type


Copyright © 2007 Regents of the University of California