nl.liacs.subdisc
Class Column

java.lang.Object
  extended by nl.liacs.subdisc.Column
All Implemented Interfaces:
XMLNodeInterface

public class Column
extends java.lang.Object
implements XMLNodeInterface

A Column contains all data from a column read from a File or database. Its members store some of the important characteristics of the Column. A Column is identified by its [@link Attribute Attribute}. One important member stores the value for data that was missing (having a value of '?') in the original data. See AttributeType for the default values for the various AttributeTypes.


Field Summary
static int DEFAULT_INIT_SIZE
           
 
Constructor Summary
Column(org.w3c.dom.Node theColumnNode)
           
Column(java.lang.String theName, java.lang.String theShort, AttributeType theType, int theIndex, int theNrRows)
           
 
Method Summary
 void add(boolean theBinary)
           
 void add(float theFloat)
           
 void add(java.lang.String theNominal)
           
 void addNodeTo(org.w3c.dom.Node theParentNode)
          Creates an XMLNode representation of this Column.
 Column copy()
           
 java.util.BitSet getBinaries()
           
 boolean getBinary(int theIndex)
           
 int getCardinality()
          Counts the number of distinct values, or cardinality, for this Column.
 java.util.TreeSet<java.lang.String> getDomain()
           
 float getFloat(int theIndex)
           
 boolean getHasMissingValues()
          Returns whether this Column is has missing values or not.
 int getIndex()
           
 boolean getIsEnabled()
          Returns whether this Column is enabled.
 float getMax()
           
 float getMin()
           
 java.util.BitSet getMissing()
          Returns a copy of a BitSet representing the missing values for this Column.
 java.lang.String getMissingValue()
          Retrieves the value currently set for all missing values.
 java.lang.String getName()
           
 java.lang.String getNameAndShort()
           
 java.lang.String getNominal(int theIndex)
           
 java.lang.String getShort()
           
 java.lang.String getString(int theIndex)
           
 AttributeType getType()
           
 boolean hasShort()
           
 boolean isBinaryType()
           
 boolean isNominalType()
           
 boolean isNumericType()
           
 boolean isOrdinalType()
           
 void permute(int[] thePermutation)
           
 void print()
           
 Column select(java.util.BitSet theSet)
          Creates a copy of the current column with some records removed.
 void set(int theIndex, float theValue)
           
 void setIsEnabled(boolean theSetting)
          Set whether this Column is enabled.
 void setMissing(int theIndex)
          Sets the bit at the specified position in the itsMissing BisSet.
 boolean setNewMissingValue(java.lang.String theNewValue)
          Sets the new missing value for this Column.
 boolean setType(AttributeType theAttributeType)
          Sets a new type for this Column.
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INIT_SIZE

public static final int DEFAULT_INIT_SIZE
See Also:
Constant Field Values
Constructor Detail

Column

public Column(java.lang.String theName,
              java.lang.String theShort,
              AttributeType theType,
              int theIndex,
              int theNrRows)

Column

public Column(org.w3c.dom.Node theColumnNode)
Parameters:
theColumnNode -
Method Detail

select

public Column select(java.util.BitSet theSet)
Creates a copy of the current column with some records removed.

Parameters:
theSet -

add

public void add(java.lang.String theNominal)

add

public void add(float theFloat)

add

public void add(boolean theBinary)

set

public void set(int theIndex,
                float theValue)

size

public int size()

getName

public java.lang.String getName()

getShort

public java.lang.String getShort()

hasShort

public boolean hasShort()

getNameAndShort

public java.lang.String getNameAndShort()

getType

public AttributeType getType()

getIndex

public int getIndex()

getNominal

public java.lang.String getNominal(int theIndex)

getFloat

public float getFloat(int theIndex)

getBinary

public boolean getBinary(int theIndex)

getString

public java.lang.String getString(int theIndex)

getBinaries

public java.util.BitSet getBinaries()

isNominalType

public boolean isNominalType()

isNumericType

public boolean isNumericType()

isOrdinalType

public boolean isOrdinalType()

isBinaryType

public boolean isBinaryType()

getMin

public float getMin()

getMax

public float getMax()

permute

public void permute(int[] thePermutation)

print

public void print()

getDomain

public java.util.TreeSet<java.lang.String> getDomain()

setType

public boolean setType(AttributeType theAttributeType)
Sets a new type for this Column. This is done by changing the AttributeType of this Column.

Parameters:
theAttributeType - a valid AttributeType.
Returns:
true if the change was successful, false otherwise.

getIsEnabled

public boolean getIsEnabled()
Returns whether this Column is enabled.

Returns:
true if this Column is enabled, false otherwise.

setIsEnabled

public void setIsEnabled(boolean theSetting)
Set whether this Column is enabled.

Parameters:
theSetting - use true to enable this Column, and false to disable it.

getHasMissingValues

public boolean getHasMissingValues()
Returns whether this Column is has missing values or not.

Returns:
true if this Column has missing values false otherwise.

getMissing

public java.util.BitSet getMissing()
Returns a copy of a BitSet representing the missing values for this Column. Members of this BitSet are set for those values that where '?' in the original data. NOTE: use setMissing to set missing values. Editing on the BitSet retrieved through getMissing has no effect on the original missing values BitSet.

Returns:
a clone of this Columns' itsMissing BitSet.

setMissing

public void setMissing(int theIndex)
Sets the bit at the specified position in the itsMissing BisSet.

Parameters:
theIndex - the bit to set in the itsMissing BitSet.

getMissingValue

public java.lang.String getMissingValue()
Retrieves the value currently set for all missing values.

Returns:
the value currently set for all missing values.

setNewMissingValue

public boolean setNewMissingValue(java.lang.String theNewValue)
Sets the new missing value for this Column. The missing value is used as replacement value for all values that where '?' in the original data.

Parameters:
theNewValue - the value to use as new missing value.
Returns:
true if setting the new missing value is successful, false otherwise.

getCardinality

public int getCardinality()
Counts the number of distinct values, or cardinality, for this Column. It is recommended to run this function after all data is loaded into a Column, as correct counts depend on the unmodified original data.

Returns:
the number of distinct values, 0 when this Column contains no data.

addNodeTo

public void addNodeTo(org.w3c.dom.Node theParentNode)
Creates an XMLNode representation of this Column. Note: the value for missing values is included as missing_value. When data is loaded, '?' values are replaced by missing_value by the appropriate FileLoader.

Specified by:
addNodeTo in interface XMLNodeInterface
Parameters:
theParentNode - the Node of which this Node will be a ChildNode. // * @return a Node that contains all the information of this column.

copy

public Column copy()