Package adams.data.spreadsheet
Class HeaderRow
- java.lang.Object
-
- adams.data.spreadsheet.AbstractRow
-
- adams.data.spreadsheet.HeaderRow
-
- All Implemented Interfaces:
Mergeable<Row>,Row,Serializable
- Direct Known Subclasses:
InstancesHeaderRow
public class HeaderRow extends AbstractRow
Represents a header row.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<String>m_CellKeysthe cell keys of the row.-
Fields inherited from class adams.data.spreadsheet.AbstractRow
m_Cells, m_Owner
-
-
Constructor Summary
Constructors Constructor Description HeaderRow(SpreadSheet owner)default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CelladdCell(int columnIndex)Adds a cell with the key of the cell in the header at the specified location.CelladdCell(String cellKey)Adds a cell with the given key to the list and returns the created object.voidassign(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.Collection<Cell>cells()Returns all cells.voidclear()Removes all cells.StringgetCellKey(int columnIndex)Returns the cell key with the given column index.HeaderRowgetClone(SpreadSheet owner)Returns a clone of itself.booleanhasCell(int columnIndex)Returns whether the row alread contains the cell at the specified location.intindexOf(Cell cell)Returns the column this particular cell is in (must belong to this row!).intindexOf(String cellKey)Returns the index of the specified key.intindexOfContent(String content)Returns the index of the cell that has the specified content.CellinsertCell(int columnIndex)Inserts a cell at the specified location.voidmergeWith(Row other)Merges its own data with the one provided by the specified row.CellnewCell(Row owner)Creates a new instance of a cell.CellremoveCell(String cellKey)Removes the cell at the specified index.protected StringuniqueKey(String key)Ensures that the key is not yet present.-
Methods inherited from class adams.data.spreadsheet.AbstractRow
getCell, getCell, getCellCount, getContent, getOwner, hasCell, isEmpty, isEmpty, removeCell, removeMissing, setOwner, toString
-
-
-
-
Constructor Detail
-
HeaderRow
public HeaderRow(SpreadSheet owner)
default constructor.- Parameters:
owner- the spreadsheet this row belongs to
-
-
Method Detail
-
assign
public void assign(Row row)
Obtains copies of the cells from the other row, but not the owner.- Specified by:
assignin interfaceRow- Overrides:
assignin classAbstractRow- Parameters:
row- the row to get the cells from
-
getClone
public HeaderRow getClone(SpreadSheet owner)
Returns a clone of itself.- Parameters:
owner- the new owner- Returns:
- the clone
-
clear
public void clear()
Removes all cells.- Specified by:
clearin interfaceRow- Overrides:
clearin classAbstractRow
-
newCell
public Cell newCell(Row owner)
Creates a new instance of a cell.- Parameters:
owner- the owner- Returns:
- the cell
-
hasCell
public boolean hasCell(int columnIndex)
Returns whether the row alread contains the cell at the specified location.- Parameters:
columnIndex- the column index- Returns:
- true if the cell already exists
-
indexOf
public int indexOf(String cellKey)
Returns the index of the specified key.- Parameters:
cellKey- the key to look for- Returns:
- the index of the cell, -1 if not found
-
indexOfContent
public int indexOfContent(String content)
Returns the index of the cell that has the specified content.- Parameters:
content- the content to look for- Returns:
- the index of the cell, -1 if not found
-
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.- Specified by:
addCellin interfaceRow- Specified by:
addCellin classAbstractRow- Parameters:
columnIndex- the index of the column to create- Returns:
- the created cell or the already existing cell
-
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.- Specified by:
addCellin interfaceRow- Specified by:
addCellin classAbstractRow- Parameters:
cellKey- the key for the cell to create- Returns:
- the created cell or the already existing cell
-
insertCell
public Cell insertCell(int columnIndex)
Inserts a cell at the specified location.- Parameters:
columnIndex- the location of the new cell- Returns:
- the created cell
-
removeCell
public Cell removeCell(String cellKey)
Removes the cell at the specified index.- Specified by:
removeCellin interfaceRow- Overrides:
removeCellin classAbstractRow- Parameters:
cellKey- the key of the cell to remove- Returns:
- the removed cell, null if non removed
-
getCellKey
public String getCellKey(int columnIndex)
Returns the cell key with the given column index.- Specified by:
getCellKeyin interfaceRow- Specified by:
getCellKeyin classAbstractRow- 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 interfaceRow- Specified by:
cellKeysin classAbstractRow- Returns:
- all cell keys (sorted according to columns)
-
cells
public Collection<Cell> cells()
Returns all cells.- Returns:
- the cells (sorted)
-
indexOf
public int indexOf(Cell cell)
Returns the column this particular cell is in (must belong to this row!).- Parameters:
cell- the cell to get the column index of- Returns:
- the column index, -1 if not found
-
uniqueKey
protected String uniqueKey(String key)
Ensures that the key is not yet present. In case the key is already used it is made unique.- Parameters:
key- the key to check- Returns:
- the potentially updated key
-
mergeWith
public void mergeWith(Row other)
Merges its own data with the one provided by the specified row.- Parameters:
other- the row to merge with
-
-