001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, 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: * DrawableFieldTemplate.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.filter.templates;
030:
031: import org.jfree.report.filter.DataRowDataSource;
032: import org.jfree.report.function.ExpressionRuntime;
033:
034: /**
035: * An drawable field template. The drawable content will be read from the datarow.
036: *
037: * @author Thomas Morgner
038: */
039: public class DrawableFieldTemplate extends AbstractTemplate {
040: /**
041: * The data row reader.
042: */
043: private DataRowDataSource dataRowDataSource;
044:
045: /**
046: * Creates a new image field template.
047: */
048: public DrawableFieldTemplate() {
049: dataRowDataSource = new DataRowDataSource();
050: }
051:
052: /**
053: * Returns the field name.
054: *
055: * @return The field name.
056: */
057: public String getField() {
058: return dataRowDataSource.getDataSourceColumnName();
059: }
060:
061: /**
062: * Sets the field name.
063: *
064: * @param field the field name.
065: */
066: public void setField(final String field) {
067: dataRowDataSource.setDataSourceColumnName(field);
068: }
069:
070: /**
071: * Returns the formula used to compute the value of the data source.
072: *
073: * @return the formula.
074: */
075: public String getFormula() {
076: return dataRowDataSource.getFormula();
077: }
078:
079: /**
080: * Defines the formula used to compute the value of this data source.
081: *
082: * @param formula the formula for the data source.
083: */
084: public void setFormula(final String formula) {
085: dataRowDataSource.setFormula(formula);
086: }
087:
088: /**
089: * Returns the current value for the data source.
090: *
091: * @param runtime the expression runtime that is used to evaluate formulas and expressions when computing the value of
092: * this filter.
093: * @return the value.
094: */
095: public Object getValue(final ExpressionRuntime runtime) {
096: return dataRowDataSource.getValue(runtime);
097: }
098:
099: /**
100: * Clones the template.
101: *
102: * @return the clone.
103: *
104: * @throws CloneNotSupportedException this should never happen.
105: */
106: public Object clone() throws CloneNotSupportedException {
107: final DrawableFieldTemplate template = (DrawableFieldTemplate) super
108: .clone();
109: template.dataRowDataSource = (DataRowDataSource) template.dataRowDataSource
110: .clone();
111: return template;
112: }
113:
114: /**
115: * Returns the datarow data source used in this template.
116: *
117: * @return the datarow data source.
118: */
119: protected DataRowDataSource getDataRowDataSource() {
120: return dataRowDataSource;
121: }
122: }
|