KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ArrayClassFactory.java
29  * ----------------------
30  * (C)opyright 2003, 2004, by Thomas Morgner and Contributors.
31  *
32  * Original Author: Thomas Morgner;
33  * Contributor(s): David Gilbert (for Object Refinery Limited);
34  *
35  * $Id: ArrayClassFactory.java,v 1.2 2005/10/18 13:31:58 mungady Exp $
36  *
37  * Changes (from 19-Feb-2003)
38  * -------------------------
39  * 06-May-2003 : Initial version
40  */

41 package org.jfree.xml.factory.objects;
42
43 import java.util.ArrayList JavaDoc;
44 import java.util.Iterator JavaDoc;
45
46 import org.jfree.util.Configuration;
47
48 /**
49  * An class that implements the {@link ClassFactory} interface to
50  * create Arrays of objects. The object descriptions are created on
51  * demand.
52  *
53  * @author Thomas Morgner.
54  */

55 public class ArrayClassFactory implements ClassFactory {
56
57     /**
58      * Default constructor.
59      */

60     public ArrayClassFactory() {
61         super();
62     }
63
64     /**
65      * Returns an object description for a class.
66      *
67      * @param c the class.
68      *
69      * @return The object description.
70      */

71     public ObjectDescription getDescriptionForClass(final Class JavaDoc c) {
72         if (!c.isArray()) {
73             return null;
74         }
75         else {
76             return new ArrayObjectDescription(c);
77         }
78     }
79
80     /**
81      * Returns an object description for the super class of a class.
82      * This method always returns null.
83      *
84      * @param d the class.
85      * @param knownSuperClass the last known super class or null.
86      *
87      * @return The object description.
88      */

89     public ObjectDescription getSuperClassObjectDescription
90         (final Class JavaDoc d, final ObjectDescription knownSuperClass) {
91         return null;
92     }
93
94     /**
95      * Returns an iterator for the registered classes. This returns a list
96      * of pre-registered classes known to this ClassFactory. A class may be able
97      * to handle more than the registered classes.
98      * <p>
99      * This method exists to support query tools for UI design, do not rely on it
100      * for day to day work.
101      *
102      * @return The iterator.
103      */

104     public Iterator JavaDoc getRegisteredClasses() {
105         final ArrayList JavaDoc l = new ArrayList JavaDoc();
106         l.add(Object JavaDoc[].class);
107         return l.iterator();
108     }
109
110     /**
111      * Configures this factory. The configuration contains several keys and
112      * their defined values. The given reference to the configuration object
113      * will remain valid until the report parsing or writing ends.
114      * <p>
115      * The configuration contents may change during the reporting.
116      *
117      * @param config the configuration, never null
118      */

119     public void configure(final Configuration config) {
120         // nothing required
121
}
122
123     /**
124      * ArrayClassFactories are always equal, there is nothing that could
125      * not be equal :)
126      *
127      * @param o the other object.
128      * @return true, if both object factories describe the same objects, false otherwise.
129      */

130     public boolean equals(final Object JavaDoc o) {
131         if (this == o) {
132             return true;
133         }
134         if (!(o instanceof ArrayClassFactory)) {
135             return false;
136         }
137         return true;
138     }
139
140     /**
141      * Returns a hash code value for the object. This method is
142      * supported for the benefit of hashtables such as those provided by
143      * <code>java.util.Hashtable</code>.
144      *
145      * @return the computed hashcode.
146      */

147     public int hashCode() {
148         return getClass().hashCode();
149     }
150 }
151
Popular Tags