com.rapidminer.datatable
Class SimpleDataTable

java.lang.Object
  extended by com.rapidminer.datatable.AbstractDataTable
      extended by com.rapidminer.datatable.SimpleDataTable
All Implemented Interfaces:
DataTable, Reportable, Tableable, java.io.Serializable, java.lang.Iterable<DataTableRow>

public class SimpleDataTable
extends AbstractDataTable
implements java.io.Serializable

A simple data table implementation which stores the data itself.

Author:
Ingo Mierswa, Simon Fischer
See Also:
Serialized Form

Constructor Summary
SimpleDataTable(java.lang.String name, java.lang.String[] columns)
           
SimpleDataTable(java.lang.String name, java.lang.String[] columns, double[] weights)
           
 
Method Summary
 void add(DataTableRow row)
          Adds the given DataTableRow to the table.
 void cleanMappingTables()
           
 void clear()
           
 int getColumnIndex(java.lang.String name)
          Returns the column index of the column with the given name.
 java.lang.String getColumnName(int i)
          Returns the name of the i-th column.
 java.lang.String[] getColumnNames()
          Returns an array of all column names.
 double getColumnWeight(int column)
          Returns the weight of the column or Double.NaN if no weight is available.
 int getNumberOfColumns()
          Returns the total number of columns.
 int getNumberOfRows()
          Returns the total number of rows.
 int getNumberOfSpecialColumns()
          Returns the total number of special columns.
 int getNumberOfValues(int column)
          Returns the number of different values for the i-th column.
 DataTableRow getRow(int index)
          Returns the data table row with the given index.
 boolean isDate(int index)
          Indicates if the column with the given index is nominal.
 boolean isDateTime(int index)
          Indicates if the column with the given index is nominal.
 boolean isNominal(int column)
          Indicates if the column with the given index is nominal.
 boolean isNumerical(int index)
          Indicates if the column with the given index is nominal.
 boolean isSpecial(int index)
          Returns true if this column is a special column which might usually not be used for some plotters, for example weights or labels.
 boolean isSupportingColumnWeights()
          Returns true if this data table is supporting column weights.
 boolean isTime(int index)
          Indicates if the column with the given index is nominal.
 java.util.Iterator<DataTableRow> iterator()
          Returns an iterator over all DataTableRows.
 java.lang.String mapIndex(int column, int index)
          If a column is nominal, the index value must be mapped to the nominal value by this method.
 int mapString(int column, java.lang.String value)
          If a column is nominal, the nominal value must be mapped to a (new) index by this method.
 void remove(DataTableRow row)
           
 DataTable sample(int newSize)
          Performs a sampling of this data table.
 void setSpecial(int index, boolean special)
           
 java.lang.String toString()
          Dumps the complete table into a string (complete data!).
 
Methods inherited from class com.rapidminer.datatable.AbstractDataTable
addDataTableListener, containsMissingValues, finishReporting, fireEvent, getCell, getColumnNumber, getName, getRowNumber, getSelectionCount, getValueAsString, isDeselected, isFirstColumnHeader, isFirstLineHeader, prepareReporting, removeDataTableListener, setName, setSelection, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleDataTable

public SimpleDataTable(java.lang.String name,
                       java.lang.String[] columns)

SimpleDataTable

public SimpleDataTable(java.lang.String name,
                       java.lang.String[] columns,
                       double[] weights)
Method Detail

getNumberOfSpecialColumns

public int getNumberOfSpecialColumns()
Description copied from interface: DataTable
Returns the total number of special columns. Please note that these columns do not need to be in an ordered sequence. In order to make sure that a column is a special column the method DataTable.isSpecial(int) should be used.

Specified by:
getNumberOfSpecialColumns in interface DataTable

isSpecial

public boolean isSpecial(int index)
Description copied from interface: DataTable
Returns true if this column is a special column which might usually not be used for some plotters, for example weights or labels.

Specified by:
isSpecial in interface DataTable

setSpecial

public void setSpecial(int index,
                       boolean special)

isNominal

public boolean isNominal(int column)
Description copied from interface: DataTable
Indicates if the column with the given index is nominal. For numerical or date columns, the value false should be returned.

Specified by:
isNominal in interface DataTable

isDate

public boolean isDate(int index)
Description copied from interface: DataTable
Indicates if the column with the given index is nominal. For numerical or date columns, the value false should be returned.

Specified by:
isDate in interface DataTable

isTime

public boolean isTime(int index)
Description copied from interface: DataTable
Indicates if the column with the given index is nominal. For numerical or date columns, the value false should be returned.

Specified by:
isTime in interface DataTable

isDateTime

public boolean isDateTime(int index)
Description copied from interface: DataTable
Indicates if the column with the given index is nominal. For numerical or date columns, the value false should be returned.

Specified by:
isDateTime in interface DataTable

isNumerical

public boolean isNumerical(int index)
Description copied from interface: DataTable
Indicates if the column with the given index is nominal. For numerical or date columns, the value false should be returned.

Specified by:
isNumerical in interface DataTable

mapIndex

public java.lang.String mapIndex(int column,
                                 int index)
Description copied from interface: DataTable
If a column is nominal, the index value must be mapped to the nominal value by this method. If the given column is not nominal, this method might throw a NullPointerException.

Specified by:
mapIndex in interface DataTable

mapString

public int mapString(int column,
                     java.lang.String value)
Description copied from interface: DataTable
If a column is nominal, the nominal value must be mapped to a (new) index by this method. If the given column is not nominal, this method might throw a NullPointerException.

Specified by:
mapString in interface DataTable

getNumberOfValues

public int getNumberOfValues(int column)
Description copied from interface: DataTable
Returns the number of different values for the i-th column. Might return -1 or throw an exception if the specific column is not nominal.

Specified by:
getNumberOfValues in interface DataTable

cleanMappingTables

public void cleanMappingTables()

isSupportingColumnWeights

public boolean isSupportingColumnWeights()
Description copied from interface: DataTable
Returns true if this data table is supporting column weights.

Specified by:
isSupportingColumnWeights in interface DataTable

getColumnWeight

public double getColumnWeight(int column)
Description copied from interface: DataTable
Returns the weight of the column or Double.NaN if no weight is available.

Specified by:
getColumnWeight in interface DataTable

getColumnName

public java.lang.String getColumnName(int i)
Description copied from interface: DataTable
Returns the name of the i-th column.

Specified by:
getColumnName in interface DataTable
Specified by:
getColumnName in interface Tableable

getColumnIndex

public int getColumnIndex(java.lang.String name)
Description copied from interface: DataTable
Returns the column index of the column with the given name.

Specified by:
getColumnIndex in interface DataTable

getNumberOfColumns

public int getNumberOfColumns()
Description copied from interface: DataTable
Returns the total number of columns.

Specified by:
getNumberOfColumns in interface DataTable

getColumnNames

public java.lang.String[] getColumnNames()
Description copied from interface: DataTable
Returns an array of all column names.

Specified by:
getColumnNames in interface DataTable
Overrides:
getColumnNames in class AbstractDataTable

add

public void add(DataTableRow row)
Description copied from interface: DataTable
Adds the given DataTableRow to the table.

Specified by:
add in interface DataTable

remove

public void remove(DataTableRow row)

getRow

public DataTableRow getRow(int index)
Description copied from interface: DataTable
Returns the data table row with the given index. Please note that this method is not guaranteed to be efficiently implemented. If you want to scan the complete data table you should use the iterator() method instead.

Specified by:
getRow in interface DataTable

iterator

public java.util.Iterator<DataTableRow> iterator()
Description copied from interface: DataTable
Returns an iterator over all DataTableRows.

Specified by:
iterator in interface DataTable
Specified by:
iterator in interface java.lang.Iterable<DataTableRow>

getNumberOfRows

public int getNumberOfRows()
Description copied from interface: DataTable
Returns the total number of rows.

Specified by:
getNumberOfRows in interface DataTable

clear

public void clear()

sample

public DataTable sample(int newSize)
Description copied from interface: DataTable
Performs a sampling of this data table. Following operations should only work on the sample.

Specified by:
sample in interface DataTable

toString

public java.lang.String toString()
Dumps the complete table into a string (complete data!).

Overrides:
toString in class java.lang.Object


Copyright © 2001-2009 by Rapid-I