KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > xml > JRTextFieldFactory


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.xml;
29
30 import java.util.Collection JavaDoc;
31
32 import net.sf.jasperreports.engine.JRExpression;
33 import net.sf.jasperreports.engine.design.JRDesignGroup;
34 import net.sf.jasperreports.engine.design.JRDesignTextField;
35 import net.sf.jasperreports.engine.design.JasperDesign;
36
37 import org.xml.sax.Attributes JavaDoc;
38
39
40 /**
41  * @author Teodor Danciu (teodord@users.sourceforge.net)
42  * @version $Id: JRTextFieldFactory.java 1355 2006-08-04 17:31:54 +0300 (Fri, 04 Aug 2006) lucianc $
43  */

44 public class JRTextFieldFactory extends JRBaseFactory
45 {
46
47
48     /**
49      *
50      */

51     private static final String JavaDoc ATTRIBUTE_isStretchWithOverflow = "isStretchWithOverflow";
52     private static final String JavaDoc ATTRIBUTE_evaluationTime = "evaluationTime";
53     private static final String JavaDoc ATTRIBUTE_evaluationGroup = "evaluationGroup";
54     private static final String JavaDoc ATTRIBUTE_pattern = "pattern";
55     private static final String JavaDoc ATTRIBUTE_isBlankWhenNull = "isBlankWhenNull";
56     private static final String JavaDoc ATTRIBUTE_hyperlinkType = "hyperlinkType";
57     private static final String JavaDoc ATTRIBUTE_hyperlinkTarget = "hyperlinkTarget";
58     private static final String JavaDoc ATTRIBUTE_bookmarkLevel = "bookmarkLevel";
59
60
61     /**
62      *
63      */

64     public Object JavaDoc createObject(Attributes JavaDoc atts)
65     {
66         JRXmlLoader xmlLoader = (JRXmlLoader)digester.peek(digester.getCount() - 1);
67         Collection JavaDoc groupEvaluatedTextFields = xmlLoader.getGroupEvaluatedTextFields();
68         JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);
69
70         JRDesignTextField textField = new JRDesignTextField(jasperDesign);
71
72         String JavaDoc isStretchWithOverflow = atts.getValue(ATTRIBUTE_isStretchWithOverflow);
73         if (isStretchWithOverflow != null && isStretchWithOverflow.length() > 0)
74         {
75             textField.setStretchWithOverflow(Boolean.valueOf(isStretchWithOverflow).booleanValue());
76         }
77
78         Byte JavaDoc evaluationTime = (Byte JavaDoc)JRXmlConstants.getEvaluationTimeMap().get(atts.getValue(ATTRIBUTE_evaluationTime));
79         if (evaluationTime != null)
80         {
81             textField.setEvaluationTime(evaluationTime.byteValue());
82         }
83         if (textField.getEvaluationTime() == JRExpression.EVALUATION_TIME_GROUP)
84         {
85             groupEvaluatedTextFields.add(textField);
86             
87             String JavaDoc groupName = atts.getValue(ATTRIBUTE_evaluationGroup);
88             if (groupName != null)
89             {
90                 JRDesignGroup group = new JRDesignGroup();
91                 group.setName(groupName);
92                 textField.setEvaluationGroup(group);
93             }
94         }
95         
96         textField.setPattern(atts.getValue(ATTRIBUTE_pattern));
97
98         String JavaDoc isBlankWhenNull = atts.getValue(ATTRIBUTE_isBlankWhenNull);
99         if (isBlankWhenNull != null && isBlankWhenNull.length() > 0)
100         {
101             textField.setBlankWhenNull(Boolean.valueOf(isBlankWhenNull));
102         }
103
104         String JavaDoc hyperlinkType = atts.getValue(ATTRIBUTE_hyperlinkType);
105         if (hyperlinkType != null)
106         {
107             textField.setLinkType(hyperlinkType);
108         }
109
110         Byte JavaDoc hyperlinkTarget = (Byte JavaDoc)JRXmlConstants.getHyperlinkTargetMap().get(atts.getValue(ATTRIBUTE_hyperlinkTarget));
111         if (hyperlinkTarget != null)
112         {
113             textField.setHyperlinkTarget(hyperlinkTarget.byteValue());
114         }
115         
116         String JavaDoc bookmarkLevelAttr = atts.getValue(ATTRIBUTE_bookmarkLevel);
117         if (bookmarkLevelAttr != null)
118         {
119             textField.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr));
120         }
121
122         return textField;
123     }
124     
125
126 }
127
Popular Tags