KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > xml > factory > objects > JavaBaseClassFactory


1 /* ========================================================================
2  * JCommon : a free general purpose class library for the Java(tm) platform
3  * ========================================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jcommon/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * -------------------------
28  * JavaBaseClassFactory.java
29  * -------------------------
30  * (C)opyright 2003, 2004, by Thomas Morgner and Contributors.
31  *
32  * Original Author: Thomas Morgner (taquera@sherito.org);
33  * Contributor(s): David Gilbert (for Object Refinery Limited);
34  *
35  * $Id: JavaBaseClassFactory.java,v 1.3 2005/11/14 11:02:34 mungady Exp $
36  *
37  * Changes
38  * -------
39  * 14-Apr-2003 : Initial version
40  * 29-Apr-2003 : Distilled from the JFreeReport project and moved into JCommon
41  * 13-Jan-2004 : Did not handle java.awt.Dimension objects correctly.
42  */

43 package org.jfree.xml.factory.objects;
44
45 import java.awt.BasicStroke JavaDoc;
46 import java.awt.Color JavaDoc;
47 import java.awt.Dimension JavaDoc;
48 import java.awt.geom.Dimension2D JavaDoc;
49 import java.awt.geom.Line2D JavaDoc;
50 import java.awt.geom.Point2D JavaDoc;
51 import java.awt.geom.Rectangle2D JavaDoc;
52 import java.text.DateFormat JavaDoc;
53 import java.text.DateFormatSymbols JavaDoc;
54 import java.text.DecimalFormat JavaDoc;
55 import java.text.DecimalFormatSymbols JavaDoc;
56 import java.text.Format JavaDoc;
57 import java.text.NumberFormat JavaDoc;
58 import java.text.SimpleDateFormat JavaDoc;
59 import java.util.ArrayList JavaDoc;
60 import java.util.Collection JavaDoc;
61 import java.util.Date JavaDoc;
62 import java.util.HashSet JavaDoc;
63 import java.util.List JavaDoc;
64 import java.util.Set JavaDoc;
65 import java.util.TreeSet JavaDoc;
66 import java.util.Vector JavaDoc;
67
68 import org.jfree.ui.FloatDimension;
69
70 /**
71  * A default factory for all commonly used java base classes from java.lang, java.awt
72  * etc.
73  *
74  * @author Thomas Morgner
75  */

76 public class JavaBaseClassFactory extends ClassFactoryImpl {
77
78     /**
79      * DefaultConstructor. Creates the object factory for all java base classes.
80      */

81     public JavaBaseClassFactory() {
82         registerClass(Dimension JavaDoc.class, new DimensionObjectDescription());
83         registerClass(Dimension2D JavaDoc.class, new Dimension2DObjectDescription());
84         registerClass(FloatDimension.class, new BeanObjectDescription(FloatDimension.class));
85         registerClass(Date JavaDoc.class, new DateObjectDescription());
86         registerClass(Boolean.TYPE, new BooleanObjectDescription());
87         registerClass(Byte.TYPE, new ByteObjectDescription());
88         registerClass(Double.TYPE, new DoubleObjectDescription());
89         registerClass(Float.TYPE, new FloatObjectDescription());
90         registerClass(Integer.TYPE, new IntegerObjectDescription());
91         registerClass(Long.TYPE, new LongObjectDescription());
92         registerClass(Short.TYPE, new ShortObjectDescription());
93         registerClass(Character.TYPE, new CharacterObjectDescription());
94         registerClass(Character JavaDoc.class, new CharacterObjectDescription());
95         registerClass(Boolean JavaDoc.class, new BooleanObjectDescription());
96         registerClass(Byte JavaDoc.class, new ByteObjectDescription());
97         registerClass(Double JavaDoc.class, new DoubleObjectDescription());
98         registerClass(Float JavaDoc.class, new FloatObjectDescription());
99         registerClass(Integer JavaDoc.class, new IntegerObjectDescription());
100         registerClass(Long JavaDoc.class, new LongObjectDescription());
101         registerClass(Short JavaDoc.class, new ShortObjectDescription());
102         registerClass(Line2D JavaDoc.class, new Line2DObjectDescription());
103         registerClass(Point2D JavaDoc.class, new Point2DObjectDescription());
104         registerClass(Rectangle2D JavaDoc.class, new Rectangle2DObjectDescription());
105         registerClass(String JavaDoc.class, new StringObjectDescription());
106         registerClass(Color JavaDoc.class, new ColorObjectDescription());
107         registerClass(BasicStroke JavaDoc.class, new BasicStrokeObjectDescription());
108         registerClass(Object JavaDoc.class, new ClassLoaderObjectDescription());
109
110         registerClass(Format JavaDoc.class, new ClassLoaderObjectDescription());
111         registerClass(NumberFormat JavaDoc.class, createNumberFormatDescription());
112         registerClass(DecimalFormat JavaDoc.class, new DecimalFormatObjectDescription());
113         registerClass(DecimalFormatSymbols JavaDoc.class, createDecimalFormatSymbols());
114         registerClass(DateFormat JavaDoc.class, new ClassLoaderObjectDescription());
115         registerClass(SimpleDateFormat JavaDoc.class, new SimpleDateFormatObjectDescription());
116         registerClass(DateFormatSymbols JavaDoc.class, new ClassLoaderObjectDescription());
117
118         registerClass(ArrayList JavaDoc.class, new CollectionObjectDescription(ArrayList JavaDoc.class));
119         registerClass(Vector JavaDoc.class, new CollectionObjectDescription(Vector JavaDoc.class));
120         registerClass(HashSet JavaDoc.class, new CollectionObjectDescription(HashSet JavaDoc.class));
121         registerClass(TreeSet JavaDoc.class, new CollectionObjectDescription(TreeSet JavaDoc.class));
122         registerClass(Set JavaDoc.class, new CollectionObjectDescription(HashSet JavaDoc.class));
123         registerClass(List JavaDoc.class, new CollectionObjectDescription(ArrayList JavaDoc.class));
124         registerClass(Collection JavaDoc.class, new CollectionObjectDescription(ArrayList JavaDoc.class));
125     }
126
127     private ObjectDescription createNumberFormatDescription () {
128         final BeanObjectDescription nfDesc =
129             new BeanObjectDescription(NumberFormat JavaDoc.class, false);
130         nfDesc.setParameterDefinition("groupingUsed", Boolean.TYPE);
131         nfDesc.setParameterDefinition("maximumFractionDigits", Integer.TYPE);
132         nfDesc.setParameterDefinition("minimumFractionDigits", Integer.TYPE);
133         nfDesc.setParameterDefinition("maximumIntegerDigits", Integer.TYPE);
134         nfDesc.setParameterDefinition("minimumIntegerDigits", Integer.TYPE);
135         nfDesc.setParameterDefinition("parseIntegerOnly", Boolean.TYPE);
136         return nfDesc;
137     }
138
139     private ObjectDescription createDecimalFormatSymbols() {
140         final BeanObjectDescription dfsDesc =
141             new BeanObjectDescription(DecimalFormatSymbols JavaDoc.class, false);
142         dfsDesc.setParameterDefinition("currencySymbol", String JavaDoc.class);
143         dfsDesc.setParameterDefinition("decimalSeparator", Character.TYPE);
144         dfsDesc.setParameterDefinition("digit", Character.TYPE);
145         dfsDesc.setParameterDefinition("groupingSeparator", Character.TYPE);
146         dfsDesc.setParameterDefinition("infinity", String JavaDoc.class);
147         dfsDesc.setParameterDefinition("internationalCurrencySymbol", String JavaDoc.class);
148         dfsDesc.setParameterDefinition("minusSign", Character.TYPE);
149         dfsDesc.setParameterDefinition("monetaryDecimalSeparator", Character.TYPE);
150         dfsDesc.setParameterDefinition("naN", String JavaDoc.class);
151         dfsDesc.setParameterDefinition("patternSeparator", Character.TYPE);
152         dfsDesc.setParameterDefinition("perMill", Character.TYPE);
153         dfsDesc.setParameterDefinition("percent", Character.TYPE);
154         dfsDesc.setParameterDefinition("zeroDigit", Character.TYPE);
155         return dfsDesc;
156
157     }
158 }
159
Popular Tags