com.jrefinery.report
Class Group

java.lang.Object
  extended bycom.jrefinery.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

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).
 boolean equals(java.lang.Object o)
          Compares this group with an other object.
 java.util.List getFields()
          Returns the list of fields for this group.
 GroupFooter getFooter()
          Returns the group footer.
 GroupHeader getHeader()
          Returns the group header.
 java.lang.String getName()
          Returns the name of the group.
 StyleSheetCollection getStyleSheetCollection()
           
 int hashCode()
          Calculates the hashcode for this group.
 boolean isLastItemInGroup(DataRowBackend currentDataRow, DataRowBackend nextDataRow)
          Returns true if this is the last item in the group, and false otherwise.
 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.
 void setStyleSheetCollection(StyleSheetCollection styleSheetCollection)
           
 java.lang.String toString()
          Returns a string representation of the group (useful for debugging).
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

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).

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.

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.

isLastItemInGroup

public boolean isLastItemInGroup(DataRowBackend currentDataRow,
                                 DataRowBackend nextDataRow)
Returns true if this is the last item in the group, and false otherwise.

Parameters:
currentDataRow - the current data row.
nextDataRow - the next data row, or null, if this is the last datarow.
Returns:
A flag indicating whether or not the current item is the last in its group.

equals

public boolean equals(java.lang.Object o)
Compares this group with an other object.

Parameters:
o - the object which should be compared with this group.
Returns:
true, if the given object is a group with the same name and fields, false otherwise

hashCode

public int hashCode()
Calculates the hashcode for this group.

Returns:
the hashcode.

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()

setStyleSheetCollection

public void setStyleSheetCollection(StyleSheetCollection styleSheetCollection)