infovis.column
Class ConstantColumn

java.lang.Object
  extended by infovis.column.ConstantColumn
All Implemented Interfaces:
IntComparator, Column, NumberColumn, Metadata, Constants, RowComparator, Serializable
Direct Known Subclasses:
ColumnOne, IdColumn

public class ConstantColumn
extends Object
implements NumberColumn

Column containing constant values for each rows.

Version:
$Revision: 1.2 $
Author:
Jean-Daniel Fekete
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface infovis.metadata.Constants
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRITION, FORMAT, IDENTIFIER, LANGUAGE, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
Constructor Summary
ConstantColumn()
           
 
Method Summary
 void addChangeListener(ChangeListener listener)
          Adds a listener to the list that's notified each time a change occurs.
 void addValue(String v)
          Appends the element specified in its String representation to the end of this column.
 boolean addValueOrNull(String v)
          Appends the element specified in its String representation to the end of this column or adds an undefined object if the String cannot be parsed.
 int capacity()
          Returns the current capacity of this column.
 void clear()
          Removes all of the elements from this column.
 int compare(int arg0, int arg1)
          
 void disableNotify()
          Disables notification until enableNotify has been called.
 void enableNotify()
          Re enable notifications, triggering eventListeners if modifications occur.
 void ensureCapacity(int minCapacity)
          Increases the capacity of this column, if necessary, to ensure that it can hold at least the number of values specified by the minimum capacity argument.
 String format(double value)
          Returns the specified value formatted according to this column's format.
 MutableAttributeSet getClientProperty()
          Returns a MutableAttributeSet associating keys to values holding user-supplied data.
 double getDoubleAt(int row)
          Returns the value as a double.
 double getDoubleMax()
          Returns the largset value as a double.
 double getDoubleMin()
          Returns the smallest value as a double.
 float getFloatAt(int row)
          Returns the value as a float.
 Format getFormat()
          Returns the format.
 int getIntAt(int row)
          Returns the value as an int.
 long getLongAt(int row)
          Returns the value as a long.
 int getMaxIndex()
          Returns an the index of a row containing the maximum value of this column or -1 if the column has only undefined values or is empty.
 MutableAttributeSet getMetadata()
          Returns the MutableAttributeSet associating keys to values for qualifying the data contained in the instance of this interface.
 int getMinIndex()
          Returns an the index of a row containing the minimum value of this column or -1 if the column has only undefined values or is empty.
 String getName()
          Returns the column name.
 String getValueAt(int index)
          Returns the String representation of the element at the specified position in this column or null if the element is undefined.
 Class getValueClass()
          Returns the class of the elements.
 boolean hasUndefinedValue()
          Returns true if the columns contains undefined values, false otherwise.
 boolean isEmpty()
          Returns true if this column contains no elements.
 boolean isInternal()
          Returns true if the column name starts with a '#'.
 boolean isValueUndefined(int i)
          Returns true if the ith value is undefined.
 RowIterator iterator()
          Returns a RowIterator over all the valid rows of this column.
 void removeChangeListener(ChangeListener listener)
          Removes a listener from the list that's notified each time a change occurs.
 double round(double value)
          Returns the rounded value according to the semantics of this number value.
 void setDoubleAt(int row, double v)
          Sets the value as a double.
 void setFloatAt(int row, float v)
          Sets the value as a float.
 void setFormat(Format format)
          Sets the format.
 void setIntAt(int row, int v)
          Sets the value as an int.
 void setLongAt(int row, long v)
          Sets the value as a long.
 void setName(String name)
          Sets the column name.
 void setSize(int newSize)
          Sets the size of this column.
 void setValueAt(int index, String element)
          Replaces the element at the specified position in this column with the element specified in its String representation or sets if undefined if the element is null It will be read and translated using the Format.
 boolean setValueOrNullAt(int index, String v)
          Replaces the element at the specified position in this column with the element specified in its String representation or set it undefined if the String cannot be parsed.
 void setValueUndefined(int i, boolean undef)
          Sets the ith element to have an undefined value.
 int size()
          Returns the number of elements in this column.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cern.colt.function.IntComparator
equals
 

Constructor Detail

ConstantColumn

public ConstantColumn()
Method Detail

getIntAt

public int getIntAt(int row)
Returns the value as an int.

Specified by:
getIntAt in interface NumberColumn
Parameters:
row - the row
Returns:
the value as an int

getFloatAt

public float getFloatAt(int row)
Returns the value as a float.

Specified by:
getFloatAt in interface NumberColumn
Parameters:
row - the row
Returns:
the value as a float

getLongAt

public long getLongAt(int row)
Returns the value as a long.

Specified by:
getLongAt in interface NumberColumn
Parameters:
row - the row
Returns:
the value as a long

getDoubleAt

public double getDoubleAt(int row)
Returns the value as a double.

Specified by:
getDoubleAt in interface NumberColumn
Parameters:
row - the row
Returns:
the value as a double

setIntAt

public void setIntAt(int row,
                     int v)
Sets the value as an int.

Specified by:
setIntAt in interface NumberColumn
Parameters:
row - the row
v - the value as an int

setFloatAt

public void setFloatAt(int row,
                       float v)
Sets the value as a float.

Specified by:
setFloatAt in interface NumberColumn
Parameters:
row - the row
v - the value as a float

setLongAt

public void setLongAt(int row,
                      long v)
Sets the value as a long.

Specified by:
setLongAt in interface NumberColumn
Parameters:
row - the row
v - the value as a long

setDoubleAt

public void setDoubleAt(int row,
                        double v)
Sets the value as a double.

Specified by:
setDoubleAt in interface NumberColumn
Parameters:
row - the row
v - the value as a double

getDoubleMin

public double getDoubleMin()
Returns the smallest value as a double.

Specified by:
getDoubleMin in interface NumberColumn
Returns:
the smallest value as a double.

getDoubleMax

public double getDoubleMax()
Returns the largset value as a double.

Specified by:
getDoubleMax in interface NumberColumn
Returns:
the largset value as a double.

round

public double round(double value)
Returns the rounded value according to the semantics of this number value.

Specified by:
round in interface NumberColumn
Parameters:
value - the value to round
Returns:
the rounded value according to the semantics of this number value.

format

public String format(double value)
Returns the specified value formatted according to this column's format.

Specified by:
format in interface NumberColumn
Parameters:
value - the value to format
Returns:
the string formatted according to this column's format.

getName

public String getName()
Returns the column name.

Specified by:
getName in interface Column
Returns:
the column name.

setName

public void setName(String name)
Sets the column name.

Specified by:
setName in interface Column
Parameters:
name - The name to set

isInternal

public boolean isInternal()
Returns true if the column name starts with a '#'.

Specified by:
isInternal in interface Column
Returns:
true if the column name starts with a '#'.

isValueUndefined

public boolean isValueUndefined(int i)
Returns true if the ith value is undefined.

Specified by:
isValueUndefined in interface Column
Specified by:
isValueUndefined in interface RowComparator
Parameters:
i - the index
Returns:
true if the ith value is undefined.

setValueUndefined

public void setValueUndefined(int i,
                              boolean undef)
Sets the ith element to have an undefined value.

Specified by:
setValueUndefined in interface Column
Parameters:
i - the index
undef - true if the value should be undefined, false otherwise.

hasUndefinedValue

public boolean hasUndefinedValue()
Returns true if the columns contains undefined values, false otherwise.

Specified by:
hasUndefinedValue in interface Column
Returns:
true if the columns contains undefined values, false otherwise.

getFormat

public Format getFormat()
Returns the format.

Specified by:
getFormat in interface Column
Returns:
Format

setFormat

public void setFormat(Format format)
Sets the format.

Specified by:
setFormat in interface Column
Parameters:
format - The format to set

isEmpty

public boolean isEmpty()
Returns true if this column contains no elements.

Specified by:
isEmpty in interface Column
Returns:
true if this column contains no elements.

size

public int size()
Returns the number of elements in this column.

Specified by:
size in interface Column
Returns:
the number of elements in this column.

setSize

public void setSize(int newSize)
Sets the size of this column.

Some column will ignore this request.

Specified by:
setSize in interface Column
Parameters:
newSize - the new size.

clear

public void clear()
Removes all of the elements from this column. The Column will be empty after this call returns. WARNING: if there is an associated format that maintains a status, such as a CategoricalFormat, it is not cleared so results may not be what you expected. The CategoricalFormat can be cleared explicitely if needed.

Specified by:
clear in interface Column

ensureCapacity

public void ensureCapacity(int minCapacity)
Increases the capacity of this column, if necessary, to ensure that it can hold at least the number of values specified by the minimum capacity argument.

Specified by:
ensureCapacity in interface Column
Parameters:
minCapacity - the desired minimum capacity.

capacity

public int capacity()
Returns the current capacity of this column.

Specified by:
capacity in interface Column
Returns:
the current capacity .

getValueAt

public String getValueAt(int index)
Returns the String representation of the element at the specified position in this column or null if the element is undefined. The representation is generated by the current format.

Specified by:
getValueAt in interface Column
Parameters:
index - index of element representation to return.
Returns:
the String representation of element at the specified position in this column or null if the element is undefined.

setValueAt

public void setValueAt(int index,
                       String element)
                throws ParseException
Replaces the element at the specified position in this column with the element specified in its String representation or sets if undefined if the element is null It will be read and translated using the Format. A null value sets the value to undefined. The column is extended if needed.

Specified by:
setValueAt in interface Column
Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Throws:
ParseException - if the specified string cannot be parsed.

setValueOrNullAt

public boolean setValueOrNullAt(int index,
                                String v)
Replaces the element at the specified position in this column with the element specified in its String representation or set it undefined if the String cannot be parsed.

Specified by:
setValueOrNullAt in interface Column
Parameters:
index - index of element to set
v - element to be appended to this column.
Returns:
true if the element has been set, false if it has been set undefined.

addValue

public void addValue(String v)
              throws ParseException
Appends the element specified in its String representation to the end of this column.

col.addValue(a) is equivalent to col.setValueAt(col.size(), a).

Specified by:
addValue in interface Column
Parameters:
v - element to be appended to this column.
Throws:
ParseException - if the specified string cannot be parsed.

addValueOrNull

public boolean addValueOrNull(String v)
Appends the element specified in its String representation to the end of this column or adds an undefined object if the String cannot be parsed.

col.addValueOrNull(a) is equivalent to col.setValueAtOrNull(col.size(), a).

Specified by:
addValueOrNull in interface Column
Parameters:
v - element to be appended to this column.
Returns:
true if the value has been defined, false otherwise.

getMinIndex

public int getMinIndex()
Returns an the index of a row containing the minimum value of this column or -1 if the column has only undefined values or is empty.

Specified by:
getMinIndex in interface Column
Returns:
the index of a row containing the minium value of this column.

getMaxIndex

public int getMaxIndex()
Returns an the index of a row containing the maximum value of this column or -1 if the column has only undefined values or is empty.

Specified by:
getMaxIndex in interface Column
Returns:
the index of a row containing the maximum value of this column.

getValueClass

public Class getValueClass()
Returns the class of the elements.

Specified by:
getValueClass in interface Column
Returns:
the class of the elements.

disableNotify

public void disableNotify()
Disables notification until enableNotify has been called.

This method is useful if a large number of modifications is going to happen on the column and notifying each time would be too time consuming. The notification will be deferred until enableNotify is called.

Calls to disableNotify can be nested

Specified by:
disableNotify in interface Column
See Also:
Column.enableNotify()

enableNotify

public void enableNotify()
Re enable notifications, triggering eventListeners if modifications occur.

Specified by:
enableNotify in interface Column
See Also:
Column.disableNotify()

addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener to the list that's notified each time a change occurs.

Specified by:
addChangeListener in interface Column
Parameters:
listener - the listener

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Removes a listener from the list that's notified each time a change occurs.

Specified by:
removeChangeListener in interface Column
Parameters:
listener - the listener

iterator

public RowIterator iterator()
Returns a RowIterator over all the valid rows of this column.

Specified by:
iterator in interface Column
Returns:
a RowIterator over all the valid rows of this column.

getMetadata

public MutableAttributeSet getMetadata()
Returns the MutableAttributeSet associating keys to values for qualifying the data contained in the instance of this interface.

Specified by:
getMetadata in interface Metadata
Returns:
the AttributeSet associating metadate keys to values.

getClientProperty

public MutableAttributeSet getClientProperty()
Returns a MutableAttributeSet associating keys to values holding user-supplied data.

Specified by:
getClientProperty in interface Metadata
Returns:
an AttributeSet holding user-supplied keys/values.

compare

public int compare(int arg0,
                   int arg1)

Specified by:
compare in interface IntComparator


Copyright © 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.