KickJava   Java API By Example, From Geeks To Geeks.

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


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 net.sf.jasperreports.engine.design.JasperDesign;
31
32 import org.xml.sax.Attributes JavaDoc;
33
34
35 /**
36  * @author Teodor Danciu (teodord@users.sourceforge.net)
37  * @version $Id: JasperDesignFactory.java 1536 2006-12-22 12:34:40 +0200 (Fri, 22 Dec 2006) teodord $
38  */

39 public class JasperDesignFactory extends JRBaseFactory
40 {
41
42     
43     /**
44      *
45      */

46     public static final String JavaDoc ELEMENT_jasperReport = "jasperReport";
47     public static final String JavaDoc ATTRIBUTE_name = "name";
48     public static final String JavaDoc ATTRIBUTE_language = "language";
49     public static final String JavaDoc ATTRIBUTE_columnCount = "columnCount";
50     public static final String JavaDoc ATTRIBUTE_printOrder = "printOrder";
51     public static final String JavaDoc ATTRIBUTE_pageWidth = "pageWidth";
52     public static final String JavaDoc ATTRIBUTE_pageHeight = "pageHeight";
53     public static final String JavaDoc ATTRIBUTE_orientation = "orientation";
54     public static final String JavaDoc ATTRIBUTE_whenNoDataType = "whenNoDataType";
55     public static final String JavaDoc ATTRIBUTE_columnWidth = "columnWidth";
56     public static final String JavaDoc ATTRIBUTE_columnSpacing = "columnSpacing";
57     public static final String JavaDoc ATTRIBUTE_leftMargin = "leftMargin";
58     public static final String JavaDoc ATTRIBUTE_rightMargin = "rightMargin";
59     public static final String JavaDoc ATTRIBUTE_topMargin = "topMargin";
60     public static final String JavaDoc ATTRIBUTE_bottomMargin = "bottomMargin";
61     public static final String JavaDoc ATTRIBUTE_isTitleNewPage = "isTitleNewPage";
62     public static final String JavaDoc ATTRIBUTE_isSummaryNewPage = "isSummaryNewPage";
63     public static final String JavaDoc ATTRIBUTE_isFloatColumnFooter = "isFloatColumnFooter";
64     public static final String JavaDoc ATTRIBUTE_scriptletClass = "scriptletClass";
65     public static final String JavaDoc ATTRIBUTE_formatFactoryClass = "formatFactoryClass";
66     public static final String JavaDoc ATTRIBUTE_resourceBundle = "resourceBundle";
67     public static final String JavaDoc ATTRIBUTE_whenResourceMissingType = "whenResourceMissingType";
68     public static final String JavaDoc ATTRIBUTE_isIgnorePagination = "isIgnorePagination";
69
70
71     /**
72      *
73      */

74     public Object JavaDoc createObject(Attributes JavaDoc atts)
75     {
76         JasperDesign jasperDesign = new JasperDesign();
77         
78         jasperDesign.setName(atts.getValue(ATTRIBUTE_name));
79
80         jasperDesign.setLanguage(atts.getValue(ATTRIBUTE_language));
81         
82         String JavaDoc columnCount = atts.getValue(ATTRIBUTE_columnCount);
83         if (columnCount != null && columnCount.length() > 0)
84         {
85             jasperDesign.setColumnCount(Integer.parseInt(columnCount));
86         }
87
88         Byte JavaDoc printOrder = (Byte JavaDoc)JRXmlConstants.getPrintOrderMap().get(atts.getValue(ATTRIBUTE_printOrder));
89         if (printOrder != null)
90         {
91             jasperDesign.setPrintOrder(printOrder.byteValue());
92         }
93
94         String JavaDoc pageWidth = atts.getValue(ATTRIBUTE_pageWidth);
95         if (pageWidth != null && pageWidth.length() > 0)
96         {
97             jasperDesign.setPageWidth(Integer.parseInt(pageWidth));
98         }
99         
100         String JavaDoc pageHeight = atts.getValue(ATTRIBUTE_pageHeight);
101         if (pageHeight != null && pageHeight.length() > 0)
102         {
103             jasperDesign.setPageHeight(Integer.parseInt(pageHeight));
104         }
105
106         Byte JavaDoc orientation = (Byte JavaDoc)JRXmlConstants.getOrientationMap().get(atts.getValue(ATTRIBUTE_orientation));
107         if (orientation != null)
108         {
109             jasperDesign.setOrientation(orientation.byteValue());
110         }
111
112         Byte JavaDoc whenNoDataType = (Byte JavaDoc)JRXmlConstants.getWhenNoDataTypeMap().get(atts.getValue(ATTRIBUTE_whenNoDataType));
113         if (whenNoDataType != null)
114         {
115             jasperDesign.setWhenNoDataType(whenNoDataType.byteValue());
116         }
117
118         String JavaDoc columnWidth = atts.getValue(ATTRIBUTE_columnWidth);
119         if (columnWidth != null && columnWidth.length() > 0)
120         {
121             jasperDesign.setColumnWidth(Integer.parseInt(columnWidth));
122         }
123
124         String JavaDoc columnSpacing = atts.getValue(ATTRIBUTE_columnSpacing);
125         if (columnSpacing != null && columnSpacing.length() > 0)
126         {
127             jasperDesign.setColumnSpacing(Integer.parseInt(columnSpacing));
128         }
129
130         String JavaDoc leftMargin = atts.getValue(ATTRIBUTE_leftMargin);
131         if (leftMargin != null && leftMargin.length() > 0)
132         {
133             jasperDesign.setLeftMargin(Integer.parseInt(leftMargin));
134         }
135
136         String JavaDoc rightMargin = atts.getValue(ATTRIBUTE_rightMargin);
137         if (rightMargin != null && rightMargin.length() > 0)
138         {
139             jasperDesign.setRightMargin(Integer.parseInt(rightMargin));
140         }
141
142         String JavaDoc topMargin = atts.getValue(ATTRIBUTE_topMargin);
143         if (topMargin != null && topMargin.length() > 0)
144         {
145             jasperDesign.setTopMargin(Integer.parseInt(topMargin));
146         }
147
148         String JavaDoc bottomMargin = atts.getValue(ATTRIBUTE_bottomMargin);
149         if (bottomMargin != null && bottomMargin.length() > 0)
150         {
151             jasperDesign.setBottomMargin(Integer.parseInt(bottomMargin));
152         }
153
154         String JavaDoc isTitleNewPage = atts.getValue(ATTRIBUTE_isTitleNewPage);
155         if (isTitleNewPage != null && isTitleNewPage.length() > 0)
156         {
157             jasperDesign.setTitleNewPage(Boolean.valueOf(isTitleNewPage).booleanValue());
158         }
159
160         String JavaDoc isSummaryNewPage = atts.getValue(ATTRIBUTE_isSummaryNewPage);
161         if (isSummaryNewPage != null && isSummaryNewPage.length() > 0)
162         {
163             jasperDesign.setSummaryNewPage(Boolean.valueOf(isSummaryNewPage).booleanValue());
164         }
165
166         String JavaDoc isFloatColumnFooter = atts.getValue(ATTRIBUTE_isFloatColumnFooter);
167         if (isFloatColumnFooter != null && isFloatColumnFooter.length() > 0)
168         {
169             jasperDesign.setFloatColumnFooter(Boolean.valueOf(isFloatColumnFooter).booleanValue());
170         }
171
172         jasperDesign.setScriptletClass(atts.getValue(ATTRIBUTE_scriptletClass));
173         jasperDesign.setFormatFactoryClass(atts.getValue(ATTRIBUTE_formatFactoryClass));
174         jasperDesign.setResourceBundle(atts.getValue(ATTRIBUTE_resourceBundle));
175
176         Byte JavaDoc whenResourceMissingType = (Byte JavaDoc)JRXmlConstants.getWhenResourceMissingTypeMap().get(atts.getValue(ATTRIBUTE_whenResourceMissingType));
177         if (whenResourceMissingType != null)
178         {
179             jasperDesign.setWhenResourceMissingType(whenResourceMissingType.byteValue());
180         }
181
182         String JavaDoc isIgnorePagination = atts.getValue(ATTRIBUTE_isIgnorePagination);
183         if (isIgnorePagination != null && isIgnorePagination.length() > 0)
184         {
185             jasperDesign.setIgnorePagination(Boolean.valueOf(isIgnorePagination).booleanValue());
186         }
187
188         return jasperDesign;
189     }
190     
191
192 }
193
Popular Tags