KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > base > JRBaseTextField


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * 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,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.engine.base;
29
30 import java.io.IOException JavaDoc;
31 import java.io.ObjectInputStream JavaDoc;
32
33 import net.sf.jasperreports.engine.JRAbstractObjectFactory;
34 import net.sf.jasperreports.engine.JRAnchor;
35 import net.sf.jasperreports.engine.JRChild;
36 import net.sf.jasperreports.engine.JRConstants;
37 import net.sf.jasperreports.engine.JRExpression;
38 import net.sf.jasperreports.engine.JRExpressionCollector;
39 import net.sf.jasperreports.engine.JRGroup;
40 import net.sf.jasperreports.engine.JRHyperlink;
41 import net.sf.jasperreports.engine.JRHyperlinkHelper;
42 import net.sf.jasperreports.engine.JRHyperlinkParameter;
43 import net.sf.jasperreports.engine.JRTextField;
44 import net.sf.jasperreports.engine.util.JRStyleResolver;
45 import net.sf.jasperreports.engine.xml.JRXmlWriter;
46
47
48 /**
49  * This class is used for representing a text field.
50  *
51  * @author Teodor Danciu (teodord@users.sourceforge.net)
52  * @version $Id: JRBaseTextField.java 1364 2006-08-31 18:13:20 +0300 (Thu, 31 Aug 2006) lucianc $
53  */

54 public class JRBaseTextField extends JRBaseTextElement implements JRTextField
55 {
56
57
58     /**
59      *
60      */

61     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
62
63     /**
64      *
65      */

66     protected boolean isStretchWithOverflow = false;
67     protected byte evaluationTime = JRExpression.EVALUATION_TIME_NOW;
68     protected String JavaDoc pattern;
69     protected Boolean JavaDoc isBlankWhenNull = null;
70     protected byte hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL;
71     protected String JavaDoc linkType;
72     protected byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF;
73     private JRHyperlinkParameter[] hyperlinkParameters;
74
75     /**
76      *
77      */

78     protected JRGroup evaluationGroup = null;
79     protected JRExpression expression = null;
80     protected JRExpression anchorNameExpression = null;
81     protected JRExpression hyperlinkReferenceExpression = null;
82     protected JRExpression hyperlinkAnchorExpression = null;
83     protected JRExpression hyperlinkPageExpression = null;
84     private JRExpression hyperlinkTooltipExpression;
85
86     /**
87      * The bookmark level for the anchor associated with this field.
88      * @see JRAnchor#getBookmarkLevel()
89      */

90     protected int bookmarkLevel = JRAnchor.NO_BOOKMARK;
91
92     /**
93      * Initializes the text field properties.
94      */

95     protected JRBaseTextField(JRTextField textField, JRBaseObjectFactory factory)
96     {
97         super(textField, factory);
98         
99         isStretchWithOverflow = textField.isStretchWithOverflow();
100         evaluationTime = textField.getEvaluationTime();
101         pattern = textField.getOwnPattern();
102         isBlankWhenNull = textField.isOwnBlankWhenNull();
103         linkType = textField.getLinkType();
104         hyperlinkTarget = textField.getHyperlinkTarget();
105         hyperlinkParameters = JRBaseHyperlink.copyHyperlinkParameters(textField, factory);
106
107         evaluationGroup = factory.getGroup(textField.getEvaluationGroup());
108         expression = factory.getExpression(textField.getExpression());
109         anchorNameExpression = factory.getExpression(textField.getAnchorNameExpression());
110         hyperlinkReferenceExpression = factory.getExpression(textField.getHyperlinkReferenceExpression());
111         hyperlinkAnchorExpression = factory.getExpression(textField.getHyperlinkAnchorExpression());
112         hyperlinkPageExpression = factory.getExpression(textField.getHyperlinkPageExpression());
113         hyperlinkTooltipExpression = factory.getExpression(textField.getHyperlinkTooltipExpression());
114         bookmarkLevel = textField.getBookmarkLevel();
115     }
116         
117
118     /**
119      *
120      */

121     public boolean isStretchWithOverflow()
122     {
123         return this.isStretchWithOverflow;
124     }
125         
126     /**
127      *
128      */

129     public void setStretchWithOverflow(boolean isStretchWithOverflow)
130     {
131         this.isStretchWithOverflow = isStretchWithOverflow;
132     }
133         
134     /**
135      *
136      */

137     public byte getEvaluationTime()
138     {
139         return this.evaluationTime;
140     }
141         
142     /**
143      *
144      */

145     public String JavaDoc getPattern()
146     {
147         return JRStyleResolver.getPattern(this);
148     }
149         
150     public String JavaDoc getOwnPattern()
151     {
152         return this.pattern;
153     }
154
155     /**
156      *
157      */

158     public void setPattern(String JavaDoc pattern)
159     {
160         this.pattern = pattern;
161     }
162         
163     /**
164      *
165      */

166     public boolean isBlankWhenNull()
167     {
168         return JRStyleResolver.isBlankWhenNull(this);
169     }
170
171     /**
172      *
173      */

174     public Boolean JavaDoc isOwnBlankWhenNull()
175     {
176         return isBlankWhenNull;
177     }
178
179     /**
180      *
181      */

182     public void setBlankWhenNull(Boolean JavaDoc isBlank)
183     {
184         this.isBlankWhenNull = isBlank;
185     }
186
187     /**
188      *
189      */

190     public void setBlankWhenNull(boolean isBlank)
191     {
192         this.isBlankWhenNull = isBlank ? Boolean.TRUE : Boolean.FALSE;
193     }
194
195     /**
196      *
197      */

198     public byte getHyperlinkType()
199     {
200         return JRHyperlinkHelper.getHyperlinkType(this);
201     }
202         
203     /**
204      *
205      */

206     public byte getHyperlinkTarget()
207     {
208         return this.hyperlinkTarget;
209     }
210         
211     /**
212      *
213      */

214     public JRGroup getEvaluationGroup()
215     {
216         return this.evaluationGroup;
217     }
218         
219     /**
220      *
221      */

222     public JRExpression getExpression()
223     {
224         return this.expression;
225     }
226
227     /**
228      *
229      */

230     public JRExpression getAnchorNameExpression()
231     {
232         return this.anchorNameExpression;
233     }
234
235     /**
236      *
237      */

238     public JRExpression getHyperlinkReferenceExpression()
239     {
240         return this.hyperlinkReferenceExpression;
241     }
242
243     /**
244      *
245      */

246     public JRExpression getHyperlinkAnchorExpression()
247     {
248         return this.hyperlinkAnchorExpression;
249     }
250
251     /**
252      *
253      */

254     public JRExpression getHyperlinkPageExpression()
255     {
256         return this.hyperlinkPageExpression;
257     }
258
259     /**
260      *
261      */

262     public JRChild getCopy(JRAbstractObjectFactory factory)
263     {
264         return factory.getTextField(this);
265     }
266
267     /**
268      *
269      */

270     public void collectExpressions(JRExpressionCollector collector)
271     {
272         collector.collect(this);
273     }
274
275     /**
276      *
277      */

278     public void writeXml(JRXmlWriter xmlWriter) throws IOException JavaDoc
279     {
280         xmlWriter.writeTextField(this);
281     }
282
283
284     public int getBookmarkLevel()
285     {
286         return bookmarkLevel;
287     }
288
289
290     public String JavaDoc getLinkType()
291     {
292         return linkType;
293     }
294
295
296     public JRHyperlinkParameter[] getHyperlinkParameters()
297     {
298         return hyperlinkParameters;
299     }
300     
301     
302     private void readObject(ObjectInputStream JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc
303     {
304         in.defaultReadObject();
305         normalizeLinkType();
306     }
307
308
309     protected void normalizeLinkType()
310     {
311         if (linkType == null)
312         {
313              linkType = JRHyperlinkHelper.getLinkType(hyperlinkType);
314         }
315         hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL;
316     }
317
318     
319     public JRExpression getHyperlinkTooltipExpression()
320     {
321         return hyperlinkTooltipExpression;
322     }
323     
324 }
325
Popular Tags