Package adams.ml.data
Class InstancesHeaderRow
- java.lang.Object
-
- adams.data.spreadsheet.AbstractRow
-
- adams.data.spreadsheet.HeaderRow
-
- adams.ml.data.InstancesHeaderRow
-
- All Implemented Interfaces:
adams.core.Mergeable<adams.data.spreadsheet.Row>,adams.data.spreadsheet.Row,Serializable
public class InstancesHeaderRow extends adams.data.spreadsheet.HeaderRowHeader row for anInstancesobject.- 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.Instancesm_Datathe underlying data.
-
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 adams.data.spreadsheet.CelladdCell(int columnIndex)Adds a cell with the key of the cell in the header at the specified location.adams.data.spreadsheet.CelladdCell(String cellKey)Adds a cell with the given key to the list and returns the created object.voidassign(adams.data.spreadsheet.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 intcellKeyToIndex(String cellKey)Turns the cellKey into a column index.Collection<adams.data.spreadsheet.Cell>cells()Returns all cells.voidclear()Removes all cells.adams.data.spreadsheet.CellgetCell(int columnIndex)Returns the cell with the given index, null if not found.adams.data.spreadsheet.CellgetCell(String cellKey)Returns the cell with the given key, null if not found.intgetCellCount()Returns the number of cells stored in the row.StringgetCellKey(int columnIndex)Returns the cell key with the given column index.adams.data.spreadsheet.HeaderRowgetClone(adams.data.spreadsheet.SpreadSheet owner)Returns a clone of itself.StringgetContent(int columnIndex)Returns the cell content with the given index.weka.core.InstancesgetData()Returns the underlying Instance.booleanhasCell(int columnIndex)Returns whether the row alread contains the cell at the specified location.booleanhasCell(String cellKey)Returns whether the row alread contains the cell with the given key.intindexOf(adams.data.spreadsheet.Cell cell)Returns the column this particular cell is in (must belong to this row!).voidmergeWith(adams.data.spreadsheet.Row other)Merges its own data with the one provided by the specified row.adams.data.spreadsheet.CellnewCell(adams.data.spreadsheet.Row owner)Creates a new instance of a cell.adams.data.spreadsheet.CellremoveCell(int columnIndex)Removes the cell at the specified index.adams.data.spreadsheet.CellremoveCell(String cellKey)Removes the cell at the specified index.booleanremoveMissing()Removes all cells marked "missing".voidsetOwner(adams.data.spreadsheet.SpreadSheet owner)Sets the spreadsheet this row belongs to.StringtoString()Simply returns the internal hashtable of cells as string.
-
-
-
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(adams.data.spreadsheet.SpreadSheet owner)
Sets the spreadsheet this row belongs to.- Specified by:
setOwnerin interfaceadams.data.spreadsheet.Row- Overrides:
setOwnerin classadams.data.spreadsheet.AbstractRow- Parameters:
owner- the owner
-
getClone
public adams.data.spreadsheet.HeaderRow getClone(adams.data.spreadsheet.SpreadSheet owner)
Returns a clone of itself.- Specified by:
getClonein interfaceadams.data.spreadsheet.Row- Overrides:
getClonein classadams.data.spreadsheet.HeaderRow- Parameters:
owner- the new owner- Returns:
- the clone
-
clear
public void clear()
Removes all cells.
Does nothing.- Specified by:
clearin interfaceadams.data.spreadsheet.Row- Overrides:
clearin classadams.data.spreadsheet.HeaderRow
-
assign
public void assign(adams.data.spreadsheet.Row row)
Obtains copies of the cells from the other row, but not the owner.
Does nothing.- Specified by:
assignin interfaceadams.data.spreadsheet.Row- Overrides:
assignin classadams.data.spreadsheet.HeaderRow- Parameters:
row- the row to get the cells from
-
newCell
public adams.data.spreadsheet.Cell newCell(adams.data.spreadsheet.Row owner)
Creates a new instance of a cell.- Specified by:
newCellin interfaceadams.data.spreadsheet.Row- Overrides:
newCellin classadams.data.spreadsheet.HeaderRow- Parameters:
owner- the owner- Returns:
- always null
-
hasCell
public boolean hasCell(int columnIndex)
Returns whether the row alread contains the cell at the specified location.- Specified by:
hasCellin interfaceadams.data.spreadsheet.Row- Overrides:
hasCellin classadams.data.spreadsheet.HeaderRow- Parameters:
columnIndex- the column index- Returns:
- true if the cell already exists
-
hasCell
public boolean hasCell(String cellKey)
Returns whether the row alread contains the cell with the given key.- Specified by:
hasCellin interfaceadams.data.spreadsheet.Row- Overrides:
hasCellin classadams.data.spreadsheet.AbstractRow- Parameters:
cellKey- the key to look for- Returns:
- true if the cell already exists
-
addCell
public adams.data.spreadsheet.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.- Specified by:
addCellin interfaceadams.data.spreadsheet.Row- Overrides:
addCellin classadams.data.spreadsheet.HeaderRow- Parameters:
columnIndex- the index of the column to create- Returns:
- the created cell or the already existing cell
-
addCell
public adams.data.spreadsheet.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.- Specified by:
addCellin interfaceadams.data.spreadsheet.Row- Overrides:
addCellin classadams.data.spreadsheet.HeaderRow- Parameters:
cellKey- the key for the cell to create- Returns:
- the created cell or the already existing cell
-
removeCell
public adams.data.spreadsheet.Cell removeCell(int columnIndex)
Removes the cell at the specified index.- Specified by:
removeCellin interfaceadams.data.spreadsheet.Row- Overrides:
removeCellin classadams.data.spreadsheet.AbstractRow- Parameters:
columnIndex- the index of the column- Returns:
- the removed cell, null if not removed
-
removeCell
public adams.data.spreadsheet.Cell removeCell(String cellKey)
Removes the cell at the specified index.- Specified by:
removeCellin interfaceadams.data.spreadsheet.Row- Overrides:
removeCellin classadams.data.spreadsheet.HeaderRow- Parameters:
cellKey- the key of the cell to remove- Returns:
- the removed cell, null if non removed
-
getCell
public adams.data.spreadsheet.Cell getCell(String cellKey)
Returns the cell with the given key, null if not found.- Specified by:
getCellin interfaceadams.data.spreadsheet.Row- Overrides:
getCellin classadams.data.spreadsheet.AbstractRow- Parameters:
cellKey- the cell to look for- Returns:
- the cell or null if not found
-
getCell
public adams.data.spreadsheet.Cell getCell(int columnIndex)
Returns the cell with the given index, null if not found.- Specified by:
getCellin interfaceadams.data.spreadsheet.Row- Overrides:
getCellin classadams.data.spreadsheet.AbstractRow- 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:
getContentin interfaceadams.data.spreadsheet.Row- Overrides:
getContentin classadams.data.spreadsheet.AbstractRow- 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:
getCellKeyin interfaceadams.data.spreadsheet.Row- Overrides:
getCellKeyin classadams.data.spreadsheet.HeaderRow- 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.- Specified by:
cellKeysin interfaceadams.data.spreadsheet.Row- Overrides:
cellKeysin classadams.data.spreadsheet.HeaderRow- Returns:
- all cell keys
-
cells
public Collection<adams.data.spreadsheet.Cell> cells()
Returns all cells.- Specified by:
cellsin interfaceadams.data.spreadsheet.Row- Overrides:
cellsin classadams.data.spreadsheet.HeaderRow- Returns:
- the cells
-
getCellCount
public int getCellCount()
Returns the number of cells stored in the row.- Specified by:
getCellCountin interfaceadams.data.spreadsheet.Row- Overrides:
getCellCountin classadams.data.spreadsheet.AbstractRow- Returns:
- the number of cells
-
removeMissing
public boolean removeMissing()
Removes all cells marked "missing".- Specified by:
removeMissingin interfaceadams.data.spreadsheet.Row- Overrides:
removeMissingin classadams.data.spreadsheet.AbstractRow- Returns:
- true if any cell was removed
-
indexOf
public int indexOf(adams.data.spreadsheet.Cell cell)
Returns the column this particular cell is in (must belong to this row!).- Specified by:
indexOfin interfaceadams.data.spreadsheet.Row- Overrides:
indexOfin classadams.data.spreadsheet.HeaderRow- Parameters:
cell- the cell to get the column index of- Returns:
- the column index, -1 if not found
-
mergeWith
public void mergeWith(adams.data.spreadsheet.Row other)
Merges its own data with the one provided by the specified row.
Not implemented!- Specified by:
mergeWithin interfaceadams.core.Mergeable<adams.data.spreadsheet.Row>- Specified by:
mergeWithin interfaceadams.data.spreadsheet.Row- Overrides:
mergeWithin classadams.data.spreadsheet.HeaderRow- Parameters:
other- the row to merge with
-
toString
public String toString()
Simply returns the internal hashtable of cells as string.- Specified by:
toStringin interfaceadams.data.spreadsheet.Row- Overrides:
toStringin classadams.data.spreadsheet.AbstractRow- Returns:
- the values of the row
-
-