Package adams.data.spreadsheet
Class DenseDataRow
- java.lang.Object
-
- adams.data.spreadsheet.DenseDataRow
-
- All Implemented Interfaces:
Mergeable<Row>,DataRow,Row,SpreadSheetColumnInsertionListener,Serializable
- Direct Known Subclasses:
DenseFloatDataRow
public class DenseDataRow extends Object implements DataRow
A row for dense data representation.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Cell[]m_Cellsthe cells of the row.protected SpreadSheetm_Ownerthe owner.
-
Constructor Summary
Constructors Constructor Description DenseDataRow()Default constructor for GOE only.DenseDataRow(SpreadSheet owner)Constructor that ties row to spreadsheet.
-
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.CellgetCell(int columnIndex)Returns the cell with the given index, null if not found.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.DataRowgetClone(SpreadSheet owner)Creates a copy of itself.StringgetContent(int columnIndex)Returns the cell content with the given index.SpreadSheetgetOwner()Returns the spreadsheet this row belongs to.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(Cell cell)Returns the column this particular cell is in (must belong to this row!).booleanisEmpty(int columnIndex)Returns whether the row has a non-empty/non-missing cell at the specified location.booleanisEmpty(String cellKey)Returns whether the row has a non-empty/non-missing cell with the given key.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(int columnIndex)Removes the cell at the specified index.CellremoveCell(String cellKey)Removes the cell at the specified index.booleanremoveMissing()Does nothing as the underlying data structure is fixed.voidsetOwner(SpreadSheet owner)Sets the spreadsheet this row belongs to.voidspreadSheetColumnInserted(SpreadSheetColumnInsertionEvent e)A column got inserted.StringtoString()Returns the internal array of cells as string.
-
-
-
Field Detail
-
m_Owner
protected SpreadSheet m_Owner
the owner.
-
m_Cells
protected Cell[] m_Cells
the cells of the row.
-
-
Constructor Detail
-
DenseDataRow
public DenseDataRow()
Default constructor for GOE only.
-
DenseDataRow
public DenseDataRow(SpreadSheet owner)
Constructor that ties row to spreadsheet.- Parameters:
owner- the spreadsheet this row belongs to
-
-
Method Detail
-
setOwner
public void setOwner(SpreadSheet owner)
Sets the spreadsheet this row belongs to.
Clears the cells if the number of columns differ.
-
getOwner
public SpreadSheet getOwner()
Returns the spreadsheet this row belongs to.
-
getClone
public DataRow getClone(SpreadSheet owner)
Creates a copy of itself.
-
assign
public void assign(Row row)
Obtains copies of the cells from the other row, but not the owner.
-
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.
-
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:
removeCellin interfaceRow- 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:
removeCellin interfaceRow- 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.
-
getCell
public Cell getCell(int columnIndex)
Returns the cell with the given index, null if not found.
-
isEmpty
public boolean isEmpty(int columnIndex)
Returns whether the row has a non-empty/non-missing cell at the specified location.
-
isEmpty
public boolean isEmpty(String cellKey)
Returns whether the row has a non-empty/non-missing cell with the given key.
-
getContent
public String getContent(int columnIndex)
Returns the cell content with the given index.- Specified by:
getContentin interfaceRow- 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 interfaceRow- 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:
getCellCountin interfaceRow- Returns:
- the number of cells - constant0
-
removeMissing
public boolean removeMissing()
Does nothing as the underlying data structure is fixed.- Specified by:
removeMissingin interfaceRow- Returns:
- always false
-
indexOf
public int indexOf(Cell cell)
Returns the column this particular cell is in (must belong to this row!).
-
spreadSheetColumnInserted
public void spreadSheetColumnInserted(SpreadSheetColumnInsertionEvent e)
A column got inserted.- Specified by:
spreadSheetColumnInsertedin interfaceDataRow- Specified by:
spreadSheetColumnInsertedin interfaceSpreadSheetColumnInsertionListener- Parameters:
e- the insertion event
-
toString
public String toString()
Returns the internal array of cells as string.
-
mergeWith
public void mergeWith(Row other)
Merges its own data with the one provided by the specified row.
Assumes that this sheet's header has already been updated.
-
-