Package adams.data.spreadsheet
Class DataRowView
- java.lang.Object
-
- adams.data.spreadsheet.DataRowView
-
- All Implemented Interfaces:
Mergeable<Row>
,DataRow
,Row
,SpreadSheetColumnInsertionListener
,Serializable
public class DataRowView extends Object implements DataRow
Provides a view to a data 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 gnu.trove.list.array.TIntArrayList
m_Columns
the column subset (null for all).protected SpreadSheet
m_Owner
the owning spreadsheet.protected DataRow
m_Row
the wrapped row.
-
Constructor Summary
Constructors Constructor Description DataRowView(SpreadSheet owner, DataRow row, int[] columns)
Initializes the view.
-
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.void
assign(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.void
clear()
Removes all cells.protected int
getActualColumn(int columnIndex)
Returns the actual index of the column.protected String
getActualColumn(String cellKey)
Returns the actual key of the column.Cell
getCell(int columnIndex)
Returns the cell with the given index, null if not found.Cell
getCell(String cellKey)
Returns the cell with the given key, null if not found.int
getCellCount()
Returns the number of cells stored in the row.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.DataRow
getDataRow()
Returns the underlying data row.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.boolean
hasCell(String cellKey)
Returns whether the row alread contains the cell with the given key.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.Cell
removeCell(int columnIndex)
Removes the cell at the specified index.Cell
removeCell(String cellKey)
Removes the cell at the specified index.boolean
removeMissing()
Removes all cells marked "missing".void
setOwner(SpreadSheet owner)
Sets the spreadsheet this row belongs to.void
spreadSheetColumnInserted(SpreadSheetColumnInsertionEvent e)
A column got inserted.String
toString()
Returns the internal array of cells as string.
-
-
-
Field Detail
-
m_Owner
protected SpreadSheet m_Owner
the owning spreadsheet.
-
m_Row
protected DataRow m_Row
the wrapped row.
-
m_Columns
protected gnu.trove.list.array.TIntArrayList m_Columns
the column subset (null for all).
-
-
Constructor Detail
-
DataRowView
public DataRowView(SpreadSheet owner, DataRow row, int[] columns)
Initializes the view.- Parameters:
owner
- the owning spreadsheetrow
- the row to wrapcolumns
- the column subset, null for all
-
-
Method Detail
-
getActualColumn
protected int getActualColumn(int columnIndex)
Returns the actual index of the column.- Parameters:
columnIndex
- the index- Returns:
- the actual index
-
getActualColumn
protected String getActualColumn(String cellKey)
Returns the actual key of the column.- Parameters:
cellKey
- the index- Returns:
- the actual key, null if not found
-
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.
Not implemented!
-
removeCell
public Cell removeCell(int columnIndex)
Removes the cell at the specified index.
Not implemented!- Specified by:
removeCell
in 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.
Not implemented!- Specified by:
removeCell
in 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.
-
getContent
public String getContent(int columnIndex)
Returns the cell content with the given index.- Specified by:
getContent
in 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:
getCellKey
in 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:
getCellCount
in interfaceRow
- Returns:
- the number of cells
-
removeMissing
public boolean removeMissing()
Removes all cells marked "missing".
Not implemented!- Specified by:
removeMissing
in interfaceRow
- Returns:
- true if any cell was removed
-
indexOf
public int indexOf(Cell cell)
Returns the column this particular cell is in (must belong to this row!).
-
mergeWith
public void mergeWith(Row other)
Merges its own data with the one provided by the specified row.
Not implemented!
-
setOwner
public void setOwner(SpreadSheet owner)
Sets the spreadsheet this row belongs to.
Not implemented!
-
getOwner
public SpreadSheet getOwner()
Returns the spreadsheet this row belongs to.
-
getClone
public DataRow getClone(SpreadSheet owner)
Returns a clone 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.
Not implemented!
-
spreadSheetColumnInserted
public void spreadSheetColumnInserted(SpreadSheetColumnInsertionEvent e)
A column got inserted.
Does nothing.- Specified by:
spreadSheetColumnInserted
in interfaceDataRow
- Specified by:
spreadSheetColumnInserted
in interfaceSpreadSheetColumnInsertionListener
- Parameters:
e
- the insertion event
-
getDataRow
public DataRow getDataRow()
Returns the underlying data row.- Returns:
- the row
-
-