prefuse.data.column
Class ColumnMetadata

java.lang.Object
  extended by prefuse.data.column.ColumnMetadata
All Implemented Interfaces:
java.util.EventListener, ColumnListener

public class ColumnMetadata
extends java.lang.Object
implements ColumnListener

ColumnMetadata stores computed metadata and statistics for a singe column instance. They are created automatically by Table instances and are retrieved using the Table.getMetadata(String) method.

Author:
jeffrey heer

Constructor Summary
ColumnMetadata(Table table, java.lang.String column)
          Creates a new ColumnMetadata instance.
ColumnMetadata(Table table, java.lang.String column, java.util.Comparator cmp, boolean dynamic)
          Creates a new ColumnMetadata instance.
 
Method Summary
 void calculateValues()
          Re-calculates all the metadata and statistics maintained by this object.
 void columnChanged(Column src, int idx, boolean prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, double prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, float prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, int prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int type, int start, int end)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, long prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, java.lang.Object prev)
          Notification that a data column has changed.
 void dispose()
          Dispose of this metadata, freeing any resources and unregistering any listeners.
 java.util.Comparator getComparator()
          Returns the comparator used to determine column values' sort order.
 java.lang.Object getDefaultValue()
          Get the columns' default value.
 double getDeviation()
          Get the standard deviation of numeric values in the column.
 int getMaximumRow()
          Get the row index of the maximum column value.
 double getMean()
          Get the mean value of numeric values in the column.
 int getMedianRow()
          Get the row index of the median column value.
 int getMinimumRow()
          Get the row index of the minimum column value.
 java.lang.Object[] getOrdinalArray()
          Get an array of all unique column values, in sorted order.
 java.util.Map getOrdinalMap()
          Get a map between all unique column values and their integer index in the sort order of those values.
 double getSum()
          Get the sum of numeric values in the column.
 int getUniqueCount()
          Get the number of unique values in the column.
 void setComparator(java.util.Comparator c)
          Sets the comparator used to detemine column values' sort order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnMetadata

public ColumnMetadata(Table table,
                      java.lang.String column)
Creates a new ColumnMetadata instance.

Parameters:
table - the backing table
column - the name of the column to store metadata for

ColumnMetadata

public ColumnMetadata(Table table,
                      java.lang.String column,
                      java.util.Comparator cmp,
                      boolean dynamic)
Creates a new ColumnMetadata instance.

Parameters:
table - the backing table
column - the name of the column to store metadata for
cmp - a Comparator that determines the default sort order for values in the column
dynamic - indicates if this ColumnMetadata should react to changes in the underlying table values. If true, computed values stored in this metadata object will be invalidated when updates to the column data occur.
Method Detail

dispose

public void dispose()
Dispose of this metadata, freeing any resources and unregistering any listeners.


calculateValues

public void calculateValues()
Re-calculates all the metadata and statistics maintained by this object.


getComparator

public java.util.Comparator getComparator()
Returns the comparator used to determine column values' sort order.

Returns:
the Comparator

setComparator

public void setComparator(java.util.Comparator c)
Sets the comparator used to detemine column values' sort order.

Parameters:
c - the Comparator to use

getDefaultValue

public java.lang.Object getDefaultValue()
Get the columns' default value.

Returns:
the column's default value

getMinimumRow

public int getMinimumRow()
Get the row index of the minimum column value. If there are multiple minima, only one is returned.

Returns:
the row index of the minimum column value.

getMaximumRow

public int getMaximumRow()
Get the row index of the maximum column value. If there are multiple maxima, only one is returned.

Returns:
the row index of the maximum column value.

getMedianRow

public int getMedianRow()
Get the row index of the median column value.

Returns:
the row index of the median column value

getUniqueCount

public int getUniqueCount()
Get the number of unique values in the column.

Returns:
the number of unique values in the column

getMean

public double getMean()
Get the mean value of numeric values in the column. If this column does not contain numeric values, this method will result in an exception being thrown.

Returns:
the mean of numeric values in the column

getDeviation

public double getDeviation()
Get the standard deviation of numeric values in the column. If this column does not contain numeric values, this method will result in an exception being thrown.

Returns:
the standard deviation of numeric values in the column

getSum

public double getSum()
Get the sum of numeric values in the column. If this column does not contain numeric values, this method will result in an exception being thrown.

Returns:
the sum of numeric values in the column

getOrdinalArray

public java.lang.Object[] getOrdinalArray()
Get an array of all unique column values, in sorted order.

Returns:
an array of all unique column values, in sorted order.

getOrdinalMap

public java.util.Map getOrdinalMap()
Get a map between all unique column values and their integer index in the sort order of those values. For example, the minimum value maps to 0, the next greater value to 1, etc.

Returns:
a map between all unique column values and their integer index in the values' sort order

columnChanged

public void columnChanged(Column src,
                          int type,
                          int start,
                          int end)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
type - One of EventConstants.INSERT, EventConstants.DELETE, or EventConstants.UPDATE.
start - the first column index that has been changed
end - the last column index that has been changed
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, int, int)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          boolean prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, boolean)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          double prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, double)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          float prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, float)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          int prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, int)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          long prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, long)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          java.lang.Object prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, java.lang.Object)


Copyright © 2007 Regents of the University of California