de.twenty11.skysail.common.grids
Class GridData

java.lang.Object
  extended by de.twenty11.skysail.common.grids.GridData
All Implemented Interfaces:
SkysailData, Serializable

public class GridData
extends Object
implements SkysailData

A grid-like data structure implementing the interface SkysailData. A gridData object contains information about the provided columns (see ColumnInfo), the actual rows (a list of RowData and an optional filter which will decide whether or not a row passed to "addRowData" will actually be added. The columns are created using a columnsBuilder which is passed to the constructor. Adding rows is done one by one, using the addRowData method. If a row is added and matches the filter (if any), the availableRowsCount is increased.

Author:
carsten
See Also:
Serialized Form

Constructor Summary
GridData()
          default constructor.
GridData(ColumnsBuilder builder)
          A constructor expecting a columnsBuilder which is used to create the initial columns.
 
Method Summary
 void addRowData(RowData rowData)
          Adds a row to the rows.
 boolean equals(Object obj)
           
 Integer getAvailableRowsCount()
           
 Integer getColumnId(String key)
          Delegates to columns object, provides the id of the column for the given name.
 Columns getColumns()
           
 Object getGridElement(int row, int col)
           
 List<RowData> getRows()
           
 int getSize()
           
 String getSortingRepresentation()
           
 String getType()
           
 int hashCode()
           
 void removeRow(int j)
          removes the grids row at provided position.
 void setColumns(Columns theColumns)
           
 void setColumns(ColumnsBuilder builder)
           
 void setSize(int size)
          needed for json deserialization.
 void setSortingRepresentation(int sortingRep)
          needed for json deserialization.
 void setType(String type)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridData

public GridData()
default constructor.


GridData

public GridData(ColumnsBuilder builder)
A constructor expecting a columnsBuilder which is used to create the initial columns.

Parameters:
builder - the provided ColumnsBuilder
Method Detail

getType

public String getType()

setType

public void setType(String type)

addRowData

public final void addRowData(RowData rowData)
Adds a row to the rows. Adding a row (which matches the filter) will increase the availableRowsCount, whereas removing a row from the rows will not change it. The use case for this is to create a rows with all rows which match the filter (thus yielding "availableRowsCount" elements) and then remove the elements which don't fit into the pagination (still leaving the availableRowsCount constant.

Parameters:
rowData - the rowData object to be added to the rows

getAvailableRowsCount

public final Integer getAvailableRowsCount()
Returns:
how many rows does the grid have currently?

getColumnId

public final Integer getColumnId(String key)
Delegates to columns object, provides the id of the column for the given name.

Parameters:
key - the name of the column for the given id.
Returns:
id of the column (0 < id < columns.size())

getColumns

public Columns getColumns()

getGridElement

public Object getGridElement(int row,
                             int col)

getRows

public List<RowData> getRows()
Returns:
the rows

getSize

public int getSize()
Specified by:
getSize in interface SkysailData
Returns:
the number of data elements in this data structure

setSize

public void setSize(int size)
needed for json deserialization.

Parameters:
size -

getSortingRepresentation

public final String getSortingRepresentation()
Returns:
a string representation like "s=0|1|2&" (which can be used as parameter) representing the current sorting

setSortingRepresentation

public void setSortingRepresentation(int sortingRep)
needed for json deserialization.


removeRow

public void removeRow(int j)
removes the grids row at provided position. The availableRowsCount is not affected.

Parameters:
j - the position of the row (0 <= j < size)

setColumns

public void setColumns(Columns theColumns)

setColumns

public void setColumns(ColumnsBuilder builder)

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2011-2012. All Rights Reserved.