Debian Codegraph @

source/org/jfree/report/flow/layoutprocessor/StaticTextLayoutController.java

raw
1 /**
2 * ========================================
3 * JFreeReport : a free Java report library
4 * ========================================
5 *
6 * Project Info: http://reporting.pentaho.org/
7 *
8 * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
9 *
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: StaticTextLayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $
27 * ------------
28 * (C) Copyright 2000-2005, by Object Refinery Limited.
29 * (C) Copyright 2005-2007, by Pentaho Corporation.
30 */
31
32 package org.jfree.report.flow.layoutprocessor;
33
34 import org.jfree.report.DataSourceException;
35 import org.jfree.report.ReportDataFactoryException;
36 import org.jfree.report.ReportProcessingException;
37 import org.jfree.report.flow.FlowController;
38 import org.jfree.report.flow.ReportTarget;
39 import org.jfree.report.structure.StaticText;
40
41 /**
42 * Creation-Date: 24.11.2006, 15:06:56
43 *
44 * @author Thomas Morgner
45 */
46 public class StaticTextLayoutController extends AbstractLayoutController
47 {
48 public static final int NOT_STARTED = 0;
49 public static final int FINISHED = 2;
50
51 private int state;
52
53 public StaticTextLayoutController()
54 {
55 }
56
57 /**
58 * Advances the processing position.
59 *
60 * @param target the report target that receives generated events.
61 * @return the new layout controller instance representing the new state.
62 *
63 * @throws DataSourceException if there was a problem reading data from
64 * the datasource.
65 * @throws ReportProcessingException if there was a general problem during
66 * the report processing.
67 * @throws ReportDataFactoryException if a query failed.
68 */
69 public LayoutController advance(final ReportTarget target)
70 throws DataSourceException, ReportDataFactoryException, ReportProcessingException
71 {
72 if (state != StaticTextLayoutController.NOT_STARTED)
73 {
74 throw new IllegalStateException();
75 }
76
77 final StaticText text = (StaticText) getNode();
78 target.processText(text.getText());
79
80 final StaticTextLayoutController derived = (StaticTextLayoutController) clone();
81 derived.state = StaticTextLayoutController.FINISHED;
82 return derived;
83 }
84
85 /**
86 * Joins with a delegated process flow. This is generally called from a child
87 * flow and should *not* (I mean it!) be called from outside. If you do,
88 * you'll suffer.
89 *
90 * @param flowController the flow controller of the parent.
91 * @return the joined layout controller that incorperates all changes from
92 * the delegate.
93 */
94 public LayoutController join(final FlowController flowController)
95 {
96 throw new UnsupportedOperationException("Static text does not have childs.");
97 }
98
99 /**
100 * Checks, whether the layout controller would be advanceable. If this method
101 * returns true, it is generally safe to call the 'advance()' method.
102 *
103 * @return true, if the layout controller is advanceable, false otherwise.
104 */
105 public boolean isAdvanceable()
106 {
107 return state != StaticTextLayoutController.FINISHED;
108 }
109
110 /**
111 * Derives a copy of this controller that is suitable to perform a
112 * precomputation. The returned layout controller must be independent from
113 * the it's anchestor controller.
114 *
115 * @param fc a new flow controller for the precomputation.
116 * @return a copy that is suitable for precomputation.
117 */
118 public LayoutController createPrecomputeInstance(final FlowController fc)
119 {
120 throw new UnsupportedOperationException
121 ("Static Text does not perform any precomputation.");
122 }
123 }