Package adams.data.spreadsheet
Class SparseDataRow
- java.lang.Object
-
- adams.data.spreadsheet.AbstractRow
-
- adams.data.spreadsheet.SparseDataRow
-
- All Implemented Interfaces:
Mergeable<Row>
,DataRow
,Row
,SpreadSheetColumnInsertionListener
,Serializable
- Direct Known Subclasses:
SparseFloatDataRow
public class SparseDataRow extends AbstractRow implements DataRow
Represents a data row with sparse data.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.data.spreadsheet.AbstractRow
m_Cells, m_Owner
-
-
Constructor Summary
Constructors Constructor Description SparseDataRow()
Default constructor for GOE only.SparseDataRow(SpreadSheet owner)
Constructor that ties row to spreadsheet.
-
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.Collection<String>
cellKeys()
Returns a collection of all stored cell keys.Collection<Cell>
cells()
Returns all cells.Cell
getCell(int columnIndex)
Returns the cell with the given index, null if not found.String
getCellKey(int columnIndex)
Returns the cell key with the given column index.DataRow
getClone(SpreadSheet owner)
Returns a clone of itself.String
getContent(int columnIndex)
Returns the cell content with the given index.SpreadSheet
getOwner()
Returns the spreadsheet this row belongs to.boolean
hasCell(int columnIndex)
Returns whether the row alread contains the cell at the specified location.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.void
spreadSheetColumnInserted(SpreadSheetColumnInsertionEvent e)
A column got inserted.String
toString()
Returns the internal array of cells as string.-
Methods inherited from class adams.data.spreadsheet.AbstractRow
assign, clear, getCell, getCellCount, hasCell, removeCell, removeCell, removeMissing, setOwner
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.data.spreadsheet.Row
assign, clear, getCell, getCellCount, hasCell, removeCell, removeCell, removeMissing, setOwner
-
-
-
-
Constructor Detail
-
SparseDataRow
public SparseDataRow()
Default constructor for GOE only.
-
SparseDataRow
public SparseDataRow(SpreadSheet owner)
Constructor that ties row to spreadsheet.- Parameters:
owner
- the spreadsheet this row belongs to
-
-
Method Detail
-
getOwner
public SpreadSheet getOwner()
Returns the spreadsheet this row belongs to.- Specified by:
getOwner
in interfaceRow
- Overrides:
getOwner
in classAbstractRow
- Returns:
- the owner
-
getClone
public DataRow getClone(SpreadSheet owner)
Returns a clone of itself.
-
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:
addCell
in interfaceRow
- Specified by:
addCell
in classAbstractRow
- Parameters:
cellKey
- the key for the cell to create- Returns:
- the created cell or the already existing cell
-
hasCell
public boolean hasCell(int columnIndex)
Returns whether the row alread contains the cell at the specified location.
-
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:
addCell
in interfaceRow
- Specified by:
addCell
in classAbstractRow
- Parameters:
columnIndex
- the index of the column to create- Returns:
- the created cell or the already existing cell
-
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
- Specified by:
getCellKey
in 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:
cellKeys
in interfaceRow
- Specified by:
cellKeys
in classAbstractRow
- Returns:
- all cell keys (not sorted)
-
cells
public Collection<Cell> cells()
Returns all cells.
-
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:
spreadSheetColumnInserted
in interfaceDataRow
- Specified by:
spreadSheetColumnInserted
in interfaceSpreadSheetColumnInsertionListener
- Parameters:
e
- the insertion event
-
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.
-
toString
public String toString()
Returns the internal array of cells as string.- Specified by:
toString
in interfaceRow
- Overrides:
toString
in classAbstractRow
- Returns:
- the values of the row
-
-