table.model
Class Grouper

java.lang.Object
  |
  +--table.model.Grouper

public class Grouper
extends java.lang.Object

Perform table's data grouping.

Version:
1.0
Author:
Stanislav Lapitsky

Field Summary
protected  java.util.ArrayList[] groupChildren
          It's used as container for group children.
protected  int[] groupColumnIndexes
          Group columns.
protected  boolean[] groupOrders
          Sort orders for each column from groupColumnIndexes.
protected  java.util.ArrayList groupResults
          Grouped rows data.
protected  Sorter sorter
          Performs preliminary data sorting.
protected  int[] sortResults
          An auxiliary array for saving sortings.
protected  javax.swing.table.TableModel sourceModel
          Original TableModel.
 
Constructor Summary
Grouper()
          Creates new instance.
Grouper(javax.swing.table.TableModel source)
          Constructs grouper with specified TableModel.
Grouper(javax.swing.table.TableModel source, int[] groupColumnIndexes)
          Constructs grouper with specified TableModel and group indexes.
 
Method Summary
protected  void addRowToGroup(RowContainer row)
          Adds a row to a group.
protected  void fillGroup()
          Creates group list.
protected  java.util.ArrayList getGroupChildren(int groupLevel)
          Gets the children ogf specified group level.
 java.util.ArrayList group()
          Performs grouping.
 void setGroup(int[] groupColumnIndexes)
          Sets grouping functions.
 void setGroup(int[] groupColumnIndexes, boolean[] groupOrders)
          Sets grouping functions.
 void setSourceTableModel(javax.swing.table.TableModel source)
          Sets original TableModel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceModel

protected javax.swing.table.TableModel sourceModel
Original TableModel.


groupColumnIndexes

protected int[] groupColumnIndexes
Group columns.


groupOrders

protected boolean[] groupOrders
Sort orders for each column from groupColumnIndexes.


groupResults

protected java.util.ArrayList groupResults
Grouped rows data.


sortResults

protected int[] sortResults
An auxiliary array for saving sortings.


sorter

protected Sorter sorter
Performs preliminary data sorting.


groupChildren

protected java.util.ArrayList[] groupChildren
It's used as container for group children.

Constructor Detail

Grouper

public Grouper()
Creates new instance.


Grouper

public Grouper(javax.swing.table.TableModel source)
Constructs grouper with specified TableModel.

Parameters:
source - original TableModel.

Grouper

public Grouper(javax.swing.table.TableModel source,
               int[] groupColumnIndexes)
Constructs grouper with specified TableModel and group indexes.

Parameters:
source - original TableModel.
groupColumnIndexes - group indexes.
Method Detail

setSourceTableModel

public void setSourceTableModel(javax.swing.table.TableModel source)
Sets original TableModel.

Parameters:
source - original TableModel.

setGroup

public void setGroup(int[] groupColumnIndexes)
              throws java.lang.Exception
Sets grouping functions.

Parameters:
groupColumnIndexes - group columns.
Throws:
java.lang.Exception

setGroup

public void setGroup(int[] groupColumnIndexes,
                     boolean[] groupOrders)
              throws GroupException
Sets grouping functions.

Parameters:
groupColumnIndexes - group columns.
groupOrders - orders of grouped columns.
Throws:
GroupException

group

public java.util.ArrayList group()
                          throws GroupException
Performs grouping.

Returns:
list of rows.
Throws:
GroupException

fillGroup

protected void fillGroup()
Creates group list.


addRowToGroup

protected void addRowToGroup(RowContainer row)
Adds a row to a group.

Parameters:
row -

getGroupChildren

protected java.util.ArrayList getGroupChildren(int groupLevel)
Gets the children ogf specified group level.

Parameters:
groupLevel - group level
Returns:
list of rows.