001: /**
002: * ========================================
003: * JFreeReport : a free Java report library
004: * ========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * $Id: DefaultReportJob.java 3525 2007-10-16 11:43:48Z tmorgner $
027: * ------------
028: * (C) Copyright 2000-2005, by Object Refinery Limited.
029: * (C) Copyright 2005-2007, by Pentaho Corporation.
030: */package org.jfree.report.flow;
031:
032: import java.awt.print.PageFormat;
033:
034: import org.jfree.base.config.HierarchicalConfiguration;
035: import org.jfree.base.config.ModifiableConfiguration;
036: import org.jfree.report.ReportDataFactory;
037: import org.jfree.report.i18n.DefaultResourceBundleFactory;
038: import org.jfree.report.i18n.ResourceBundleFactory;
039: import org.jfree.report.util.ReportParameters;
040:
041: /**
042: * Creation-Date: 22.02.2006, 12:47:53
043: *
044: * @author Thomas Morgner
045: */
046: public class DefaultReportJob implements ReportJob {
047: private ReportStructureRoot report;
048: private ReportDataFactory dataFactory;
049: private ReportParameters parameters;
050: private ModifiableConfiguration configuration;
051: private ResourceBundleFactory resourceBundleFactory;
052: private String name;
053:
054: //private PageFormat pageFormat;
055:
056: public DefaultReportJob(final ReportStructureRoot report) {
057: this .resourceBundleFactory = new DefaultResourceBundleFactory();
058: this .report = report;
059: final ReportDataFactory dataFactory = report.getDataFactory();
060: if (dataFactory != null) {
061: this .dataFactory = dataFactory.derive();
062: }
063: this .parameters = new ReportParameters(report
064: .getInputParameters());
065: this .configuration = new HierarchicalConfiguration(report
066: .getConfiguration());
067: }
068:
069: public ModifiableConfiguration getConfiguration() {
070: return configuration;
071: }
072:
073: public ReportParameters getParameters() {
074: return parameters;
075: }
076:
077: public ReportStructureRoot getReportStructureRoot() {
078: return report;
079: }
080:
081: public ReportDataFactory getDataFactory() {
082: return dataFactory;
083: }
084:
085: public void setDataFactory(final ReportDataFactory dataFactory) {
086: this .dataFactory = dataFactory;
087: }
088:
089: public Object clone() throws CloneNotSupportedException {
090: final DefaultReportJob job = (DefaultReportJob) super .clone();
091: if (dataFactory != null) {
092: job.dataFactory = dataFactory.derive();
093: }
094: job.parameters = (ReportParameters) parameters.clone();
095: job.configuration = (ModifiableConfiguration) configuration
096: .clone();
097: return job;
098: }
099:
100: public ReportJob derive() {
101: try {
102: return (ReportJob) clone();
103: } catch (CloneNotSupportedException e) {
104: throw new IllegalStateException(
105: "A report job should always be cloneable.");
106: }
107: }
108:
109: public synchronized void close() {
110: if (dataFactory != null) {
111: dataFactory.close();
112: }
113: }
114:
115: public ResourceBundleFactory getResourceBundleFactory() {
116: return resourceBundleFactory;
117: }
118:
119: public void setResourceBundleFactory(
120: final ResourceBundleFactory resourceBundleFactory) {
121: this .resourceBundleFactory = resourceBundleFactory;
122: }
123:
124: public String getName() {
125: return name;
126: }
127:
128: public void setName(final String name) {
129: this .name = name;
130: }
131: //
132: // public PageFormat getPageFormat()
133: // {
134: // return pageFormat;
135: // }
136: //
137: // public void setPageFormat(PageFormat pageFormat)
138: // {
139: // this.pageFormat = pageFormat;
140: // }
141: }
|