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 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.Collection<String>cellKeys()Returns a collection of all stored cell keys.Collection<Cell>cells()Returns all cells.CellgetCell(int columnIndex)Returns the cell with the given index, null if not found.StringgetCellKey(int columnIndex)Returns the cell key with the given column index.DataRowgetClone(SpreadSheet owner)Returns a clone 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.intindexOf(Cell cell)Returns the column this particular cell is in (must belong to this row!).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.voidspreadSheetColumnInserted(SpreadSheetColumnInsertionEvent e)A column got inserted.StringtoString()Returns the internal array of cells as string.-
Methods inherited from class adams.data.spreadsheet.AbstractRow
assign, clear, getCell, getCellCount, getOnlyStoreFormulas, hasCell, isEmpty, isEmpty, isQuiet, 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, getOnlyStoreFormulas, hasCell, isEmpty, isEmpty, isQuiet, 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:
getOwnerin interfaceRow- Overrides:
getOwnerin 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:
addCellin interfaceRow- Specified by:
addCellin 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:
addCellin interfaceRow- Specified by:
addCellin 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:
getCellin interfaceRow- Overrides:
getCellin 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:
getContentin interfaceRow- Overrides:
getContentin 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:
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 (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:
spreadSheetColumnInsertedin interfaceDataRow- Specified by:
spreadSheetColumnInsertedin 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:
toStringin interfaceRow- Overrides:
toStringin classAbstractRow- Returns:
- the values of the row
-
-