org.jfree.report
Class GroupList

java.lang.Object
  extended byorg.jfree.report.GroupList
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
UnmodifiableGroupList

public class GroupList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

The group list is used to store groups in a ordered way. The less specific groups are guaranteed to be listed before any more specific subgroup.

Groups are ordered by comparing the declared fieldnames for the groups. A subgroup of an group must contain all fields from its parent plus at least one new field.

This implementation is not synchronized.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
GroupList()
          Constructs a new empty group list.
GroupList(GroupList list)
          Creates a new group list and copies the contents of the given grouplist.
 
Method Summary
 void add(Group o)
          Adds a group to the list.
 void addAll(java.util.Collection c)
          Adds all groups of the collection to this group list.
 void clear()
          Clears the list.
 java.lang.Object clone()
          Clones the group list and all contained groups.
 Group get(int i)
          Returns the group at a position in the list.
 Group getGroupByName(java.lang.String name)
          Searches a group by its defined name.
protected  Group[] getGroupCache()
          Returns a direct reference to the group cache.
 StyleSheetCollection getStyleSheetCollection()
          Returns the stylesheet collection which is assigned with this group and all stylesheets of this group.
 java.util.Iterator iterator()
          Returns an iterator for the groups of the list.
 void registerStyleSheetCollection(StyleSheetCollection styleSheetCollection)
          Registers the given StyleSheet collection with this group list.
 boolean remove(Group o)
          Removes an group from the list.
 int size()
          Returns the number of groups in the list.
 java.lang.String toString()
          Returns a string representation of the list (useful for debugging).
 void unregisterStyleSheetCollection(StyleSheetCollection styleSheetCollection)
          Unregisters the given stylesheet collection from this group list.
 void updateStyleSheetCollection(StyleSheetCollection styleSheetCollection)
          Updates the stylesheet collection for this group list and all group in this list.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GroupList

public GroupList()
Constructs a new empty group list.


GroupList

public GroupList(GroupList list)
Creates a new group list and copies the contents of the given grouplist. If the given group list was assigned with an stylesheet collection, then the new group list will share that registration.

Parameters:
list - groups to add to the list.
Method Detail

get

public Group get(int i)
Returns the group at a position in the list.

Parameters:
i - the position index (zero-based).
Returns:
the report group.

remove

public boolean remove(Group o)
Removes an group from the list.

Parameters:
o - the group that should be removed.
Returns:
a boolean indicating whether or not the object was removed.
Throws:
java.lang.NullPointerException - if the given group object is null.

clear

public void clear()
Clears the list.


add

public void add(Group o)
Adds a group to the list.

Parameters:
o - the group object.

addAll

public void addAll(java.util.Collection c)
Adds all groups of the collection to this group list. This method will result in a ClassCastException if the collection does not contain Group objects.

Parameters:
c - the collection that contains the groups.
Throws:
java.lang.NullPointerException - if the given collection is null.
java.lang.ClassCastException - if the collection does not contain groups.

clone

public java.lang.Object clone()
Clones the group list and all contained groups.

Returns:
a clone of this list.

iterator

public java.util.Iterator iterator()
Returns an iterator for the groups of the list.

Returns:
An iterator over all groups of the list.

size

public int size()
Returns the number of groups in the list.

Returns:
The number of groups in the list.

toString

public java.lang.String toString()
Returns a string representation of the list (useful for debugging).

Returns:
A string.

getStyleSheetCollection

public StyleSheetCollection getStyleSheetCollection()
Returns the stylesheet collection which is assigned with this group and all stylesheets of this group.

Returns:
the stylesheet collection or null, if no collection is assigned.

registerStyleSheetCollection

public void registerStyleSheetCollection(StyleSheetCollection styleSheetCollection)
                                  throws InvalidStyleSheetCollectionException
Registers the given StyleSheet collection with this group list. If there is already another stylesheet collection registered, this method will throw an InvalidStyleSheetCollectionException.

Parameters:
styleSheetCollection - the stylesheet collection that should be registered.
Throws:
InvalidStyleSheetCollectionException - if there is already an other stylesheet registered.
java.lang.NullPointerException - if the given stylesheet collection is null.

unregisterStyleSheetCollection

public void unregisterStyleSheetCollection(StyleSheetCollection styleSheetCollection)
                                    throws InvalidStyleSheetCollectionException
Unregisters the given stylesheet collection from this group list. If this stylesheet collection is not registered with this group list, this method will throw an InvalidStyleSheetCollectionException

Parameters:
styleSheetCollection - the stylesheet collection that should be unregistered.
Throws:
InvalidStyleSheetCollectionException - if there is no stylesheet registered.
java.lang.NullPointerException - if the given stylesheet collection is null.

updateStyleSheetCollection

public void updateStyleSheetCollection(StyleSheetCollection styleSheetCollection)
                                throws InvalidStyleSheetCollectionException
Updates the stylesheet collection for this group list and all group in this list. This method must be called after the group list was cloned, to make sure that all stylesheets are registered properly.

If you don't call this function after cloning prepare to be doomed. This method will replace all inherited stylesheets with clones from the stylesheet collection.

Parameters:
styleSheetCollection - the stylesheet collection that contains the updated information and that should be assigned with that element.
Throws:
java.lang.NullPointerException - if the given stylesheet collection is null.
InvalidStyleSheetCollectionException - if there is an other stylesheet collection already registered with that element.

getGroupCache

protected Group[] getGroupCache()
Returns a direct reference to the group cache.

Returns:
the groups of this list as array.

getGroupByName

public Group getGroupByName(java.lang.String name)
Searches a group by its defined name. This method returns null, if the group was not found.

Parameters:
name - the name of the group.
Returns:
the group or null if not found.