01: /**
02: * ===========================================
03: * JFreeReport : a free Java reporting library
04: * ===========================================
05: *
06: * Project Info: http://reporting.pentaho.org/
07: *
08: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
09: *
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: * IsExportTypeExpression.java
27: * ------------
28: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
29: */package org.jfree.report.function.sys;
30:
31: import org.jfree.report.function.AbstractExpression;
32:
33: /**
34: * Tests, whether a certain export type is currently used. This matches the given export type with the export type
35: * that is specified by the output-target. The given export type can be a partial pattern, in which case this expression
36: * tests, whether the given export type is a sub-type of the output-target's type.
37: *
38: * To test whether a table-export is used, specifiy the export type as "table" and it will match all table exports.
39: *
40: * @author Thomas Morgner
41: */
42: public class IsExportTypeExpression extends AbstractExpression {
43: /**
44: * The export type for which to test for.
45: */
46: private String exportType;
47:
48: /**
49: * Default constructor.
50: */
51: public IsExportTypeExpression() {
52: }
53:
54: /**
55: * Returns the export type string.
56: *
57: * @return the export type string.
58: */
59: public String getExportType() {
60: return exportType;
61: }
62:
63: /**
64: * Defines the export type.
65: *
66: * @param exportType the export type.
67: */
68: public void setExportType(final String exportType) {
69: this .exportType = exportType;
70: }
71:
72: /**
73: * Return Boolean.TRUE, if the specified export type matches the used export type, Boolean.FALSE otherwise.
74: *
75: * @return the value of the function.
76: */
77: public Object getValue() {
78: if (exportType == null) {
79: return Boolean.FALSE;
80: }
81: if (getRuntime().getExportDescriptor().startsWith(exportType)) {
82: return Boolean.TRUE;
83: }
84: return Boolean.FALSE;
85: }
86: }
|