~ubuntu-branches/ubuntu/lucid/libjcommon-java/lucid

« back to all changes in this revision

Viewing changes to source/org/jfree/xml/factory/objects/JavaBaseClassFactory.java

  • Committer: Bazaar Package Importer
  • Author(s): Wolfgang Baer
  • Date: 2006-02-09 15:58:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060209155813-fzi9zwh2rzedbllq
Tags: 1.0.0-1
* New stable upstream release (closes: #328574)
* Move to main - build with kaffe
* Use cdbs build system - added cdbs build-dependency
* Move package to pkg-java-maintainers for comaintenance, 
  added Christian Bayle and myself as uploaders
* Removed unneeded README.Debian
* Added README.Debian-source how the upstream tarball was cleaned
* Move big documentation in an own -doc package
* Register javadoc api with doc-base
* Standards-Version 3.6.2 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;
 
46
import java.awt.Color;
 
47
import java.awt.Dimension;
 
48
import java.awt.geom.Dimension2D;
 
49
import java.awt.geom.Line2D;
 
50
import java.awt.geom.Point2D;
 
51
import java.awt.geom.Rectangle2D;
 
52
import java.text.DateFormat;
 
53
import java.text.DateFormatSymbols;
 
54
import java.text.DecimalFormat;
 
55
import java.text.DecimalFormatSymbols;
 
56
import java.text.Format;
 
57
import java.text.NumberFormat;
 
58
import java.text.SimpleDateFormat;
 
59
import java.util.ArrayList;
 
60
import java.util.Collection;
 
61
import java.util.Date;
 
62
import java.util.HashSet;
 
63
import java.util.List;
 
64
import java.util.Set;
 
65
import java.util.TreeSet;
 
66
import java.util.Vector;
 
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.class, new DimensionObjectDescription());
 
83
        registerClass(Dimension2D.class, new Dimension2DObjectDescription());
 
84
        registerClass(FloatDimension.class, new BeanObjectDescription(FloatDimension.class));
 
85
        registerClass(Date.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.class, new CharacterObjectDescription());
 
95
        registerClass(Boolean.class, new BooleanObjectDescription());
 
96
        registerClass(Byte.class, new ByteObjectDescription());
 
97
        registerClass(Double.class, new DoubleObjectDescription());
 
98
        registerClass(Float.class, new FloatObjectDescription());
 
99
        registerClass(Integer.class, new IntegerObjectDescription());
 
100
        registerClass(Long.class, new LongObjectDescription());
 
101
        registerClass(Short.class, new ShortObjectDescription());
 
102
        registerClass(Line2D.class, new Line2DObjectDescription());
 
103
        registerClass(Point2D.class, new Point2DObjectDescription());
 
104
        registerClass(Rectangle2D.class, new Rectangle2DObjectDescription());
 
105
        registerClass(String.class, new StringObjectDescription());
 
106
        registerClass(Color.class, new ColorObjectDescription());
 
107
        registerClass(BasicStroke.class, new BasicStrokeObjectDescription());
 
108
        registerClass(Object.class, new ClassLoaderObjectDescription());
 
109
 
 
110
        registerClass(Format.class, new ClassLoaderObjectDescription());
 
111
        registerClass(NumberFormat.class, createNumberFormatDescription());
 
112
        registerClass(DecimalFormat.class, new DecimalFormatObjectDescription());
 
113
        registerClass(DecimalFormatSymbols.class, createDecimalFormatSymbols());
 
114
        registerClass(DateFormat.class, new ClassLoaderObjectDescription());
 
115
        registerClass(SimpleDateFormat.class, new SimpleDateFormatObjectDescription());
 
116
        registerClass(DateFormatSymbols.class, new ClassLoaderObjectDescription());
 
117
 
 
118
        registerClass(ArrayList.class, new CollectionObjectDescription(ArrayList.class));
 
119
        registerClass(Vector.class, new CollectionObjectDescription(Vector.class));
 
120
        registerClass(HashSet.class, new CollectionObjectDescription(HashSet.class));
 
121
        registerClass(TreeSet.class, new CollectionObjectDescription(TreeSet.class));
 
122
        registerClass(Set.class, new CollectionObjectDescription(HashSet.class));
 
123
        registerClass(List.class, new CollectionObjectDescription(ArrayList.class));
 
124
        registerClass(Collection.class, new CollectionObjectDescription(ArrayList.class));
 
125
    }
 
126
 
 
127
    private ObjectDescription createNumberFormatDescription () {
 
128
        final BeanObjectDescription nfDesc =
 
129
            new BeanObjectDescription(NumberFormat.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.class, false);
 
142
        dfsDesc.setParameterDefinition("currencySymbol", String.class);
 
143
        dfsDesc.setParameterDefinition("decimalSeparator", Character.TYPE);
 
144
        dfsDesc.setParameterDefinition("digit", Character.TYPE);
 
145
        dfsDesc.setParameterDefinition("groupingSeparator", Character.TYPE);
 
146
        dfsDesc.setParameterDefinition("infinity", String.class);
 
147
        dfsDesc.setParameterDefinition("internationalCurrencySymbol", String.class);
 
148
        dfsDesc.setParameterDefinition("minusSign", Character.TYPE);
 
149
        dfsDesc.setParameterDefinition("monetaryDecimalSeparator", Character.TYPE);
 
150
        dfsDesc.setParameterDefinition("naN", String.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
}