Save This Page
Home » pentaho-reporting-engine-classic-0.8.10 » org » jfree » report » filter » templates » [javadoc | source]
    1   /**
    2    * =========================================================
    3    * Pentaho-Reporting-Classic : a free Java reporting library
    4    * =========================================================
    5    *
    6    * Project Info:  http://reporting.pentaho.org/
    7    *
    8    * (C) Copyright 2001-2007, by Object Refinery Ltd, 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    * DrawableFieldTemplate.java
   27    * ------------
   28    * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
   29    */
   30   
   31   package org.jfree.report.filter.templates;
   32   
   33   import org.jfree.report.Element;
   34   import org.jfree.report.filter.DataRowDataSource;
   35   import org.jfree.report.function.ExpressionRuntime;
   36   
   37   /**
   38    * An drawable field template. The drawable content will be read from the datarow.
   39    *
   40    * @author Thomas Morgner
   41    */
   42   public class DrawableFieldTemplate extends AbstractTemplate
   43   {
   44     /**
   45      * The data row reader.
   46      */
   47     private DataRowDataSource dataRowDataSource;
   48   
   49     /**
   50      * Creates a new image field template.
   51      */
   52     public DrawableFieldTemplate ()
   53     {
   54       dataRowDataSource = new DataRowDataSource();
   55     }
   56   
   57     /**
   58      * Returns the field name.
   59      *
   60      * @return The field name.
   61      */
   62     public String getField ()
   63     {
   64       return dataRowDataSource.getDataSourceColumnName();
   65     }
   66   
   67     /**
   68      * Sets the field name.
   69      *
   70      * @param field the field name.
   71      */
   72     public void setField (final String field)
   73     {
   74       dataRowDataSource.setDataSourceColumnName(field);
   75     }
   76   
   77     /**
   78      * Returns the formula used to compute the value of the data source.
   79      *
   80      * @return the formula.
   81      */
   82     public String getFormula()
   83     {
   84       return dataRowDataSource.getFormula();
   85     }
   86   
   87     /**
   88      * Defines the formula used to compute the value of this data source.
   89      *
   90      * @param formula the formula for the data source.
   91      */
   92     public void setFormula(final String formula)
   93     {
   94       dataRowDataSource.setFormula(formula);
   95     }
   96   
   97   
   98     /**
   99      * Returns the current value for the data source.
  100      *
  101      * @param runtime the expression runtime that is used to evaluate formulas and expressions when computing the value of
  102      *                this filter.
  103      * @param element
  104      * @return the value.
  105      */
  106     public Object getValue(final ExpressionRuntime runtime, final Element element)
  107     {
  108       return dataRowDataSource.getValue(runtime, element);
  109     }
  110   
  111     /**
  112      * Clones the template.
  113      *
  114      * @return the clone.
  115      *
  116      * @throws CloneNotSupportedException this should never happen.
  117      */
  118     public Object clone ()
  119             throws CloneNotSupportedException
  120     {
  121       final DrawableFieldTemplate template = (DrawableFieldTemplate) super.clone();
  122       template.dataRowDataSource = (DataRowDataSource) template.dataRowDataSource.clone();
  123       return template;
  124     }
  125   
  126     /**
  127      * Returns the datarow data source used in this template.
  128      *
  129      * @return the datarow data source.
  130      */
  131     protected DataRowDataSource getDataRowDataSource ()
  132     {
  133       return dataRowDataSource;
  134     }
  135   }

Save This Page
Home » pentaho-reporting-engine-classic-0.8.10 » org » jfree » report » filter » templates » [javadoc | source]