Package adams.ml.data
Class InstancesHeaderRow
- java.lang.Object
-
- adams.data.spreadsheet.AbstractRow
-
- adams.data.spreadsheet.HeaderRow
-
- adams.ml.data.InstancesHeaderRow
-
- All Implemented Interfaces:
Mergeable<Row>
,Row
,Serializable
public class InstancesHeaderRow extends HeaderRow
Header row for anInstances
object.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.core.Instances
m_Data
the underlying data.-
Fields inherited from class adams.data.spreadsheet.HeaderRow
m_CellKeys
-
Fields inherited from class adams.data.spreadsheet.AbstractRow
m_Cells, m_Owner
-
-
Constructor Summary
Constructors Constructor Description InstancesHeaderRow(InstancesView owner)
Initializes the header row.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Cell
addCell(int columnIndex)
Adds a cell with the key of the cell in the header at the specified location.Cell
addCell(String cellKey)
Adds a cell with the given key to the list and returns the created object.void
assign(Row row)
Obtains copies of the cells from the other row, but not the owner.Collection<String>
cellKeys()
Returns a collection of all stored cell keys.protected int
cellKeyToIndex(String cellKey)
Turns the cellKey into a column index.Collection<Cell>
cells()
Returns all cells.void
clear()
Removes all cells.Cell
getCell(int columnIndex)
Returns the cell with the given index, null if not found.Cell
getCell(String cellKey)
Returns the cell with the given key, null if not found.int
getCellCount()
Returns the number of cells stored in the row.String
getCellKey(int columnIndex)
Returns the cell key with the given column index.HeaderRow
getClone(SpreadSheet owner)
Returns a clone of itself.String
getContent(int columnIndex)
Returns the cell content with the given index.weka.core.Instances
getData()
Returns the underlying Instance.boolean
hasCell(int columnIndex)
Returns whether the row alread contains the cell at the specified location.boolean
hasCell(String cellKey)
Returns whether the row alread contains the cell with the given key.int
indexOf(Cell cell)
Returns the column this particular cell is in (must belong to this row!).void
mergeWith(Row other)
Merges its own data with the one provided by the specified row.Cell
newCell(Row owner)
Creates a new instance of a cell.Cell
removeCell(int columnIndex)
Removes the cell at the specified index.Cell
removeCell(String cellKey)
Removes the cell at the specified index.boolean
removeMissing()
Removes all cells marked "missing".void
setOwner(SpreadSheet owner)
Sets the spreadsheet this row belongs to.String
toString()
Simply returns the internal hashtable of cells as string.-
Methods inherited from class adams.data.spreadsheet.HeaderRow
indexOf, indexOfContent, insertCell, uniqueKey
-
Methods inherited from class adams.data.spreadsheet.AbstractRow
getOwner
-
-
-
-
Constructor Detail
-
InstancesHeaderRow
public InstancesHeaderRow(InstancesView owner)
Initializes the header row.- Parameters:
owner
- the owner
-
-
Method Detail
-
getData
public weka.core.Instances getData()
Returns the underlying Instance.- Returns:
- the underlying data
-
cellKeyToIndex
protected int cellKeyToIndex(String cellKey)
Turns the cellKey into a column index.- Parameters:
cellKey
- the cellKey to convert- Returns:
- the column index, -1 if failed to convert
-
setOwner
public void setOwner(SpreadSheet owner)
Sets the spreadsheet this row belongs to.- Specified by:
setOwner
in interfaceRow
- Overrides:
setOwner
in classAbstractRow
- Parameters:
owner
- the owner
-
getClone
public HeaderRow getClone(SpreadSheet owner)
Returns a clone of itself.
-
clear
public void clear()
Removes all cells.
Does nothing.
-
assign
public void assign(Row row)
Obtains copies of the cells from the other row, but not the owner.
Does nothing.
-
hasCell
public boolean hasCell(int columnIndex)
Returns whether the row alread contains the cell at the specified location.
-
hasCell
public boolean hasCell(String cellKey)
Returns whether the row alread contains the cell with the given key.- Specified by:
hasCell
in interfaceRow
- Overrides:
hasCell
in classAbstractRow
- Parameters:
cellKey
- the key to look for- Returns:
- true if the cell already exists
-
addCell
public Cell addCell(int columnIndex)
Adds a cell with the key of the cell in the header at the specified location. If the cell already exists, it returns that instead of creating one.
-
addCell
public Cell addCell(String cellKey)
Adds a cell with the given key to the list and returns the created object. If the cell already exists, then this cell is returned instead and no new object created.
-
removeCell
public Cell removeCell(int columnIndex)
Removes the cell at the specified index.- Specified by:
removeCell
in interfaceRow
- Overrides:
removeCell
in classAbstractRow
- Parameters:
columnIndex
- the index of the column- Returns:
- the removed cell, null if not removed
-
removeCell
public Cell removeCell(String cellKey)
Removes the cell at the specified index.- Specified by:
removeCell
in interfaceRow
- Overrides:
removeCell
in classHeaderRow
- Parameters:
cellKey
- the key of the cell to remove- Returns:
- the removed cell, null if non removed
-
getCell
public Cell getCell(String cellKey)
Returns the cell with the given key, null if not found.- Specified by:
getCell
in interfaceRow
- Overrides:
getCell
in classAbstractRow
- Parameters:
cellKey
- the cell to look for- Returns:
- the cell or null if not found
-
getCell
public Cell getCell(int columnIndex)
Returns the cell with the given index, null if not found.- Specified by:
getCell
in interfaceRow
- Overrides:
getCell
in classAbstractRow
- Parameters:
columnIndex
- the index of the column- Returns:
- the cell or null if not found
-
getContent
public String getContent(int columnIndex)
Returns the cell content with the given index.- Specified by:
getContent
in interfaceRow
- Overrides:
getContent
in classAbstractRow
- Parameters:
columnIndex
- the index of the column- Returns:
- the content or null if not found
-
getCellKey
public String getCellKey(int columnIndex)
Returns the cell key with the given column index.- Specified by:
getCellKey
in interfaceRow
- Overrides:
getCellKey
in classHeaderRow
- Parameters:
columnIndex
- the index of the column- Returns:
- the cell key, null if invalid index
-
cellKeys
public Collection<String> cellKeys()
Returns a collection of all stored cell keys.
-
cells
public Collection<Cell> cells()
Returns all cells.
-
getCellCount
public int getCellCount()
Returns the number of cells stored in the row.- Specified by:
getCellCount
in interfaceRow
- Overrides:
getCellCount
in classAbstractRow
- Returns:
- the number of cells
-
removeMissing
public boolean removeMissing()
Removes all cells marked "missing".- Specified by:
removeMissing
in interfaceRow
- Overrides:
removeMissing
in classAbstractRow
- Returns:
- true if any cell was removed
-
indexOf
public int indexOf(Cell cell)
Returns the column this particular cell is in (must belong to this row!).
-
mergeWith
public void mergeWith(Row other)
Merges its own data with the one provided by the specified row.
Not implemented!
-
toString
public String toString()
Simply returns the internal hashtable of cells as string.- Specified by:
toString
in interfaceRow
- Overrides:
toString
in classAbstractRow
- Returns:
- the values of the row
-
-