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: * AnchorFieldTemplate.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.AnchorFilter;
032: import org.jfree.report.filter.DataRowDataSource;
033: import org.jfree.report.function.ExpressionRuntime;
034:
035: /**
036: * The anchor-field template provides the default field for assigning anchors
037: * to an location within the document.
038: *
039: * @author Thomas Morgner
040: * @deprecated the Anchor-Field has been deprecated. Use the style-key "anchor" instead.
041: */
042: public class AnchorFieldTemplate extends AbstractTemplate {
043: /**
044: * The data-row data source.
045: */
046: private DataRowDataSource dataRowDataSource;
047:
048: /**
049: * A string filter.
050: */
051: private AnchorFilter anchorFilter;
052:
053: /**
054: * Creates a new string field template.
055: */
056: public AnchorFieldTemplate() {
057: dataRowDataSource = new DataRowDataSource();
058: anchorFilter = new AnchorFilter();
059: anchorFilter.setDataSource(dataRowDataSource);
060: }
061:
062: /**
063: * Returns the field name.
064: *
065: * @return The field name.
066: */
067: public String getField() {
068: return dataRowDataSource.getDataSourceColumnName();
069: }
070:
071: /**
072: * Sets the field name.
073: *
074: * @param field the field name.
075: */
076: public void setField(final String field) {
077: dataRowDataSource.setDataSourceColumnName(field);
078: }
079:
080: /**
081: * Returns the formula used to compute the value of the data source.
082: *
083: * @return the formula.
084: */
085: public String getFormula() {
086: return dataRowDataSource.getFormula();
087: }
088:
089: /**
090: * Defines the formula used to compute the value of this data source.
091: *
092: * @param formula the formula for the data source.
093: */
094: public void setFormula(final String formula) {
095: dataRowDataSource.setFormula(formula);
096: }
097:
098: /**
099: * 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: * @return the value.
104: */
105: public Object getValue(final ExpressionRuntime runtime) {
106: return anchorFilter.getValue(runtime);
107: }
108:
109: /**
110: * Clones the template.
111: *
112: * @return the clone.
113: *
114: * @throws CloneNotSupportedException this should never happen.
115: */
116: public Object clone() throws CloneNotSupportedException {
117: final AnchorFieldTemplate template = (AnchorFieldTemplate) super
118: .clone();
119: template.anchorFilter = (AnchorFilter) anchorFilter.clone();
120: template.dataRowDataSource = (DataRowDataSource) template.anchorFilter
121: .getDataSource();
122: return template;
123: }
124:
125: /**
126: * Returns the datarow data source used in this template.
127: *
128: * @return the datarow data source.
129: */
130: protected DataRowDataSource getDataRowDataSource() {
131: return dataRowDataSource;
132: }
133: }
|