01: /**
02: * ========================================
03: * JFreeReport : a free Java report library
04: * ========================================
05: *
06: * Project Info: http://reporting.pentaho.org/
07: *
08: * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
09: *
10: * This library is free software; you can redistribute it and/or modify it under the terms
11: * of the GNU Lesser General Public License as published by the Free Software Foundation;
12: * either version 2.1 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16: * See the GNU Lesser General Public License for more details.
17: *
18: * You should have received a copy of the GNU Lesser General Public License along with this
19: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20: * Boston, MA 02111-1307, USA.
21: *
22: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
23: * in the United States and other countries.]
24: *
25: * ------------
26: * $Id: Group.java 3048 2007-07-28 18:02:42Z tmorgner $
27: * ------------
28: * (C) Copyright 2000-2005, by Object Refinery Limited.
29: * (C) Copyright 2005-2007, by Pentaho Corporation.
30: */package org.jfree.report.structure;
31:
32: import org.jfree.report.expressions.Expression;
33:
34: /**
35: * A report group. A group is a repeated section which is bound to an
36: * expression.
37: * <p/>
38: * <h2>Default Behaviour</h2> Whether a new group should be started is evaluated
39: * by the group's expression. If that expression returns Boolean.TRUE, a new
40: * group instance is started. (That expression answers the Questions: 'Does this
41: * group instance end here?').
42: * <p/>
43: * If the group expression is invalid or there is no group expression at all, a
44: * group will consume all rows until the datasource is no longer advanceable.
45: *
46: * @author David Gilbert
47: * @author Thomas Morgner
48: */
49: public class Group extends Section {
50: private Expression groupingExpression;
51:
52: /**
53: * Constructs a group with no fields, and an empty header and footer.
54: */
55: public Group() {
56: setType("group");
57: setRepeat(true);
58: }
59:
60: /**
61: * Returns a string representation of the group (useful for debugging).
62: *
63: * @return A string.
64: */
65: public String toString() {
66: final StringBuffer b = new StringBuffer();
67: b.append("Group={Name='");
68: b.append(getName());
69: b.append("} ");
70: return b.toString();
71: }
72:
73: public Expression getGroupingExpression() {
74: return groupingExpression;
75: }
76:
77: public void setGroupingExpression(
78: final Expression groupingExpression) {
79: this .groupingExpression = groupingExpression;
80: }
81:
82: public Group getGroup() {
83: return this ;
84: }
85:
86: public Object clone() throws CloneNotSupportedException {
87: final Group group = (Group) super .clone();
88: if (groupingExpression != null) {
89: group.groupingExpression = (Expression) groupingExpression
90: .clone();
91: }
92: return group;
93: }
94: }
|