001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * 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,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.engine.base;
029:
030: import java.io.Serializable;
031:
032: import net.sf.jasperreports.engine.JRConstants;
033: import net.sf.jasperreports.engine.JRExpression;
034: import net.sf.jasperreports.engine.JRParameter;
035: import net.sf.jasperreports.engine.JRPropertiesMap;
036: import net.sf.jasperreports.engine.JRRuntimeException;
037: import net.sf.jasperreports.engine.util.JRClassLoader;
038:
039: /**
040: * @author Teodor Danciu (teodord@users.sourceforge.net)
041: * @version $Id: JRBaseParameter.java 1712 2007-04-30 18:04:51Z teodord $
042: */
043: public class JRBaseParameter implements JRParameter, Serializable {
044:
045: /**
046: *
047: */
048: private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
049:
050: /**
051: *
052: */
053: protected String name = null;
054: protected String description = null;
055: protected String valueClassName = java.lang.String.class.getName();
056: protected String valueClassRealName = null;
057: protected boolean isSystemDefined = false;
058: protected boolean isForPrompting = true;
059:
060: protected transient Class valueClass = null;
061:
062: /**
063: *
064: */
065: protected JRExpression defaultValueExpression = null;
066:
067: protected JRPropertiesMap propertiesMap;
068:
069: /**
070: *
071: */
072: protected JRBaseParameter() {
073: propertiesMap = new JRPropertiesMap();
074: }
075:
076: /**
077: *
078: */
079: protected JRBaseParameter(JRParameter parameter,
080: JRBaseObjectFactory factory) {
081: factory.put(parameter, this );
082:
083: name = parameter.getName();
084: description = parameter.getDescription();
085: valueClassName = parameter.getValueClassName();
086: isSystemDefined = parameter.isSystemDefined();
087: isForPrompting = parameter.isForPrompting();
088:
089: defaultValueExpression = factory.getExpression(parameter
090: .getDefaultValueExpression());
091:
092: propertiesMap = parameter.getPropertiesMap().cloneProperties();
093: }
094:
095: /**
096: *
097: */
098: public String getName() {
099: return this .name;
100: }
101:
102: /**
103: *
104: */
105: public String getDescription() {
106: return this .description;
107: }
108:
109: /**
110: *
111: */
112: public void setDescription(String description) {
113: this .description = description;
114: }
115:
116: /**
117: *
118: */
119: public Class getValueClass() {
120: if (valueClass == null) {
121: String className = getValueClassRealName();
122: if (className != null) {
123: try {
124: valueClass = JRClassLoader
125: .loadClassForName(className);
126: } catch (ClassNotFoundException e) {
127: throw new JRRuntimeException(e);
128: }
129: }
130: }
131:
132: return valueClass;
133: }
134:
135: /**
136: *
137: */
138: public String getValueClassName() {
139: return valueClassName;
140: }
141:
142: /**
143: *
144: */
145: private String getValueClassRealName() {
146: if (valueClassRealName == null) {
147: valueClassRealName = JRClassLoader
148: .getClassRealName(valueClassName);
149: }
150:
151: return valueClassRealName;
152: }
153:
154: /**
155: *
156: */
157: public boolean isSystemDefined() {
158: return this .isSystemDefined;
159: }
160:
161: /**
162: *
163: */
164: public boolean isForPrompting() {
165: return this .isForPrompting;
166: }
167:
168: /**
169: *
170: */
171: public JRExpression getDefaultValueExpression() {
172: return this .defaultValueExpression;
173: }
174:
175: public JRPropertiesMap getPropertiesMap() {
176: return propertiesMap;
177: }
178:
179: }
|