Source for org.jfree.report.flow.DefaultReportJob

   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: DefaultReportJob.java 3525 2007-10-16 11:43:48Z tmorgner $
  27:  * ------------
  28:  * (C) Copyright 2000-2005, by Object Refinery Limited.
  29:  * (C) Copyright 2005-2007, by Pentaho Corporation.
  30:  */
  31: package org.jfree.report.flow;
  32: 
  33: import java.awt.print.PageFormat;
  34: 
  35: import org.jfree.base.config.HierarchicalConfiguration;
  36: import org.jfree.base.config.ModifiableConfiguration;
  37: import org.jfree.report.ReportDataFactory;
  38: import org.jfree.report.i18n.DefaultResourceBundleFactory;
  39: import org.jfree.report.i18n.ResourceBundleFactory;
  40: import org.jfree.report.util.ReportParameters;
  41: 
  42: /**
  43:  * Creation-Date: 22.02.2006, 12:47:53
  44:  *
  45:  * @author Thomas Morgner
  46:  */
  47: public class DefaultReportJob
  48: implements ReportJob
  49: {
  50:   private ReportStructureRoot report;
  51:   private ReportDataFactory dataFactory;
  52:   private ReportParameters parameters;
  53:   private ModifiableConfiguration configuration;
  54:   private ResourceBundleFactory resourceBundleFactory;
  55:   private String name;
  56:   //private PageFormat pageFormat;
  57: 
  58:   public DefaultReportJob(final ReportStructureRoot report)
  59:   {
  60:     this.resourceBundleFactory = new DefaultResourceBundleFactory();
  61:     this.report = report;
  62:     final ReportDataFactory dataFactory = report.getDataFactory();
  63:     if (dataFactory != null)
  64:     {
  65:       this.dataFactory = dataFactory.derive();
  66:     }
  67:     this.parameters = new ReportParameters(report.getInputParameters());
  68:     this.configuration = new HierarchicalConfiguration(report.getConfiguration());
  69:   }
  70: 
  71:   public ModifiableConfiguration getConfiguration()
  72:   {
  73:     return configuration;
  74:   }
  75: 
  76:   public ReportParameters getParameters()
  77:   {
  78:     return parameters;
  79:   }
  80: 
  81:   public ReportStructureRoot getReportStructureRoot()
  82:   {
  83:     return report;
  84:   }
  85: 
  86:   public ReportDataFactory getDataFactory()
  87:   {
  88:     return dataFactory;
  89:   }
  90: 
  91:   public void setDataFactory(final ReportDataFactory dataFactory)
  92:   {
  93:     this.dataFactory = dataFactory;
  94:   }
  95: 
  96:   public Object clone() throws CloneNotSupportedException
  97:   {
  98:     final DefaultReportJob job = (DefaultReportJob) super.clone();
  99:     if (dataFactory != null)
 100:     {
 101:       job.dataFactory = dataFactory.derive();
 102:     }
 103:     job.parameters = (ReportParameters) parameters.clone();
 104:     job.configuration = (ModifiableConfiguration) configuration.clone();
 105:     return job;
 106:   }
 107: 
 108:   public ReportJob derive()
 109:   {
 110:     try
 111:     {
 112:       return (ReportJob) clone();
 113:     }
 114:     catch (CloneNotSupportedException e)
 115:     {
 116:       throw new IllegalStateException
 117:           ("A report job should always be cloneable.");
 118:     }
 119:   }
 120: 
 121:   public synchronized void close()
 122:   {
 123:     if (dataFactory != null)
 124:     {
 125:       dataFactory.close();
 126:     }
 127:   }
 128: 
 129:   public ResourceBundleFactory getResourceBundleFactory()
 130:   {
 131:     return resourceBundleFactory;
 132:   }
 133: 
 134:   public void setResourceBundleFactory(final ResourceBundleFactory resourceBundleFactory)
 135:   {
 136:     this.resourceBundleFactory = resourceBundleFactory;
 137:   }
 138: 
 139:   public String getName()
 140:   {
 141:     return name;
 142:   }
 143: 
 144:   public void setName(final String name)
 145:   {
 146:     this.name = name;
 147:   }
 148: //
 149: //  public PageFormat getPageFormat()
 150: //  {
 151: //    return pageFormat;
 152: //  }
 153: //
 154: //  public void setPageFormat(PageFormat pageFormat)
 155: //  {
 156: //    this.pageFormat = pageFormat;
 157: //  }
 158: }