org.jfree.report
Class Group

java.lang.Object
  extended byorg.jfree.report.Group
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

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

A report group. Reports can contain any number of (nested) groups. The order of the fields is important. If the group does not contain any fields, the group spans the whole report from the first to the last row.

The group's field list should not be modified after the group was added to the group list, or the results are undefined.

Author:
David Gilbert, Thomas Morgner
See Also:
GroupList, Serialized Form

Field Summary
static java.lang.String ANONYMOUS_GROUP_PREFIX
          The internal constant to mark anonymous group names.
 
Constructor Summary
Group()
          Constructs a group with no fields, and an empty header and footer.
 
Method Summary
 void addField(java.lang.String name)
          Adds a field to the group.
 java.lang.Object clone()
          Clones this Element.
 int compareTo(java.lang.Object o)
          Compares two objects (required to be instances of the Group class).
 java.util.List getFields()
          Returns the list of fields for this group.
 java.lang.String[] getFieldsArray()
          Returns the group fields as array.
 GroupFooter getFooter()
          Returns the group footer.
 GroupHeader getHeader()
          Returns the group header.
 java.lang.String getName()
          Returns the name of the group.
 StyleSheetCollection getStyleSheetCollection()
          Returns the stylesheet collection which is assigned with this group and all stylesheets of this group.
 void registerStyleSheetCollection(StyleSheetCollection styleSheetCollection)
          Registers the given StyleSheet collection with this group.
 void setFields(java.util.List c)
          Sets the fields for this group.
 void setFooter(GroupFooter footer)
          Sets the footer for the group.
 void setHeader(GroupHeader header)
          Sets the header for the group.
 void setName(java.lang.String name)
          Defines the name for this group.
 java.lang.String toString()
          Returns a string representation of the group (useful for debugging).
 void unregisterStyleSheetCollection(StyleSheetCollection styleSheetCollection)
          Unregisters the given stylesheet collection from this group.
 void updateStyleSheetCollection(StyleSheetCollection sc)
          Updates the stylesheet collection for this group and all bands of the group.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANONYMOUS_GROUP_PREFIX

public static final java.lang.String ANONYMOUS_GROUP_PREFIX
The internal constant to mark anonymous group names.

See Also:
Constant Field Values
Constructor Detail

Group

public Group()
Constructs a group with no fields, and an empty header and footer.

Method Detail

setName

public void setName(java.lang.String name)
Defines the name for this group. The name must not be empty and must be unique within the GroupList.

Parameters:
name - the group name (null not permitted).

getName

public java.lang.String getName()
Returns the name of the group.

Returns:
the group name.

getHeader

public GroupHeader getHeader()
Returns the group header.

The group header is a report band that contains elements that should be printed at the start of a group.

Returns:
the group header.

setHeader

public void setHeader(GroupHeader header)
Sets the header for the group.

Parameters:
header - the header (null not permitted).
Throws:
java.lang.NullPointerException - if the given header is null

getFooter

public GroupFooter getFooter()
Returns the group footer.

Returns:
the footer.

setFooter

public void setFooter(GroupFooter footer)
Sets the footer for the group.

Parameters:
footer - the footer (null not permitted).
Throws:
java.lang.NullPointerException - if the given footer is null.

setFields

public void setFields(java.util.List c)
Sets the fields for this group. The given list must contain Strings defining the needed fields from the DataRow. Don't reference Function-Fields here, functions are not supported in th groupfield definition.

Parameters:
c - the list containing strings.
Throws:
java.lang.NullPointerException - if the given list is null or the list contains null-values.

addField

public void addField(java.lang.String name)
Adds a field to the group. The field names must correspond to the column names in the report's TableModel.

Parameters:
name - the field name (null not permitted).
Throws:
java.lang.NullPointerException - if the name is null

getFields

public java.util.List getFields()
Returns the list of fields for this group.

Returns:
a list (unmodifiable) of fields for the group.

getFieldsArray

public java.lang.String[] getFieldsArray()
Returns the group fields as array.

Returns:
the fields as string array.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this Element.

Returns:
a clone of this element.
Throws:
java.lang.CloneNotSupportedException - should never be thrown.

compareTo

public int compareTo(java.lang.Object o)
Compares two objects (required to be instances of the Group class). The group's field lists are compared, order of the fields does not matter.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the to be compared object.
Returns:
an integer indicating the relative ordering of the two groups.

toString

public java.lang.String toString()
Returns a string representation of the group (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. 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. If this stylesheet collection is not registered with this group, this method will throw an InvalidStyleSheetCollectionException

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

updateStyleSheetCollection

public void updateStyleSheetCollection(StyleSheetCollection sc)
                                throws InvalidStyleSheetCollectionException
Updates the stylesheet collection for this group and all bands of the group. This method must be called after the group 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:
sc - 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.