infovis.column
Class BasicObjectColumn

java.lang.Object
  extended by infovis.utils.ChangeManager
      extended by infovis.column.AbstractColumn
          extended by infovis.column.BasicColumn
              extended by infovis.column.BasicObjectColumn
All Implemented Interfaces:
IntComparator, Column, Metadata, Constants, RowComparator, Serializable
Direct Known Subclasses:
ColumnColumn, FilterColumn, ObjectColumn, ShapeColumn, StringColumn

public abstract class BasicObjectColumn
extends BasicColumn

Abstract base class for columns containing objects.

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

Field Summary
 
Fields inherited from class infovis.column.AbstractColumn
MODIFIED_ALL, MODIFIED_NONE
 
Fields inherited from interface infovis.metadata.Constants
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRITION, FORMAT, IDENTIFIER, LANGUAGE, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
Constructor Summary
BasicObjectColumn(String name)
          Creates a new StringColumn object.
BasicObjectColumn(String name, int reserve)
          Creates a new ObjectColumn object.
 
Method Summary
 void add(Object element)
          Adds a new element in the column.
 int capacity()
          Returns the current capacity of this column.
 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.
 int compare(int row1, int row2)
          
 int compare(Object s1, Object s2)
          Compare two objects using this object's comparator.
 boolean compareValues(Column c)
          Compare the values of this column and the specified column.
abstract  Object definedValue()
          Returns the instance of a value defined with the right type for this column.
 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.
 void fill(Object val)
          Fills the column with the specified value.
 String format(Object v)
          Returns the string representation of a value according to the current format.
 Object getObjectAt(int index)
          Returns the element at the specified position or null if it is undefined or invalid.
 Comparator getOrder()
          Returns the order used to find the min and max for the strings.
 String getValueAt(int i)
          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.
 ArrayList getValueReference()
          Returns the backing ArrayList for this column (USE WITH CARE).
 boolean hasUndefinedValue()
          Returns true if the columns contains undefined values, false otherwise.
 int indexOf(Object o)
          Returns the index of the specified object in the column.
 boolean isValueUndefined(int index)
          Returns true if the ith value is undefined.
 Object parse(String v)
          Parse a string and return the value for the column.
 void remove(int row)
          Removes the specified row.
 boolean remove(Object o)
          Removes the specified object from the column if it exists.
 void setExtend(int index, Object element)
          Replaces the element at the specified position in this column with the specified element, growing the column if necessary.
 void setObjectAt(int index, Object element)
          Replaces the element at the specified position in this column with the specified element.
 void setOrder(Comparator order)
          Sets the order used to find the min and max for the strings.
 void setSize(int newSize)
          Sets the sizeColumn of this column.
 void setValueAt(int i, String v)
          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.
 void setValueUndefined(int index, 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 infovis.column.BasicColumn
addValue, addValueOrNull, firstValidRow, getClientProperty, getFormat, getMaxIndex, getMetadata, getMinIndex, getName, isEmpty, isInternal, iterator, lastValidRow, setFormat, setName, setValueOrNullAt, toString
 
Methods inherited from class infovis.column.AbstractColumn
addChangeListener, computeValueMap, computeValueMap, equalObj, equals, getLastModifiedRow
 
Methods inherited from class infovis.utils.ChangeManager
disableNotify, enableNotify, getModCount, removeChangeListener
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface infovis.Column
disableNotify, enableNotify, removeChangeListener
 

Constructor Detail

BasicObjectColumn

public BasicObjectColumn(String name)
Creates a new StringColumn object.

Parameters:
name - the column name.

BasicObjectColumn

public BasicObjectColumn(String name,
                         int reserve)
Creates a new ObjectColumn object.

Parameters:
name - the column name.
reserve - the initial capacity.
Method Detail

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
Overrides:
clear in class BasicColumn

compareValues

public boolean compareValues(Column c)
Compare the values of this column and the specified column.

Overrides:
compareValues in class AbstractColumn
Parameters:
c - the column to compare values from
Returns:
true if the values match, false otherwise

getObjectAt

public Object getObjectAt(int index)
Returns the element at the specified position or null if it is undefined or invalid.

Parameters:
index - the index.
Returns:
the element at the specified position or null if it is undefined or invalid.

setObjectAt

public void setObjectAt(int index,
                        Object element)
Replaces the element at the specified position in this column with the specified element.

Parameters:
index - index of element to replace.
element - element to be stored at the specified position.

setValueUndefined

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

Parameters:
index - the index
undef - true if the value should be undefined, false otherwise.

definedValue

public abstract Object definedValue()
Returns the instance of a value defined with the right type for this column.

Returns:
the instance of a value defined with the right type for this column.

isValueUndefined

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

Parameters:
index - the index
Returns:
true if the ith value is undefined.

hasUndefinedValue

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

Returns:
true if the columns contains undefined values, false otherwise.

setExtend

public final void setExtend(int index,
                            Object element)
Replaces the element at the specified position in this column with the specified element, growing the column if necessary.

Parameters:
index - index of element to replace.
element - element to be stored at the specified position.

add

public void add(Object element)
Adds a new element in the column.

Parameters:
element - the element.

remove

public void remove(int row)
Removes the specified row.

Parameters:
row - the row

indexOf

public int indexOf(Object o)
Returns the index of the specified object in the column.

Parameters:
o - the object
Returns:
the index of the specified object in the column.

remove

public boolean remove(Object o)
Removes the specified object from the column if it exists.

Parameters:
o - the object to remove
Returns:
true if the object has been removed, false if it was not in the column.

fill

public void fill(Object val)
Fills the column with the specified value.

Parameters:
val - the value

parse

public Object parse(String v)
             throws ParseException
Parse a string and return the value for the column.

Parameters:
v - the string representation of the value
Returns:
the value
Throws:
ParseException - if the value cannot be parsed

format

public String format(Object v)
Returns the string representation of a value according to the current format.

Parameters:
v - the value
Returns:
the string representation.

getValueAt

public String getValueAt(int i)
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.

Parameters:
i - 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 i,
                       String v)
                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.

Parameters:
i - index of element to replace.
v - element to be stored at the specified position.
Throws:
ParseException - if the specified string cannot be parsed.

compare

public int compare(Object s1,
                   Object s2)
Compare two objects using this object's comparator.

Parameters:
s1 - first object
s2 - second object
Returns:
0 if the objects are equal, a negative value is s1 < s2, a positive value otherwise.

getOrder

public Comparator getOrder()
Returns the order used to find the min and max for the strings.

Returns:
RowComparator

setOrder

public void setOrder(Comparator order)
Sets the order used to find the min and max for the strings.

Parameters:
order - The order to set

getValueClass

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

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

compare

public int compare(int row1,
                   int row2)

Specified by:
compare in interface IntComparator
Overrides:
compare in class BasicColumn

setSize

public void setSize(int newSize)
Sets the sizeColumn of this column. If the new sizeColumn is greater than the current sizeColumn, new 0 items are added to the end of the column. If the new sizeColumn is less than the current sizeColumn, all components at index newSize and greater are discarded.

Specified by:
setSize in interface Column
Specified by:
setSize in class BasicColumn
Parameters:
newSize - the new sizeColumn of this column.

capacity

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

Returns:
the current capacity .

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.

Parameters:
minCapacity - the desired minimum capacity.

size

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

Returns:
the number of elements in this column.

getValueReference

public ArrayList getValueReference()
Returns the backing ArrayList for this column (USE WITH CARE).

Returns:
the backing ArrayList for this column.


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