001: /* ========================================================================
002: * JCommon : a free general purpose class library for the Java(tm) platform
003: * ========================================================================
004: *
005: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jcommon/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * ----------------------
028: * ArrayClassFactory.java
029: * ----------------------
030: * (C)opyright 2003, 2004, by Thomas Morgner and Contributors.
031: *
032: * Original Author: Thomas Morgner;
033: * Contributor(s): David Gilbert (for Object Refinery Limited);
034: *
035: * $Id: ArrayClassFactory.java,v 1.2 2005/10/18 13:31:58 mungady Exp $
036: *
037: * Changes (from 19-Feb-2003)
038: * -------------------------
039: * 06-May-2003 : Initial version
040: */
041: package org.jfree.xml.factory.objects;
042:
043: import java.util.ArrayList;
044: import java.util.Iterator;
045:
046: import org.jfree.util.Configuration;
047:
048: /**
049: * An class that implements the {@link ClassFactory} interface to
050: * create Arrays of objects. The object descriptions are created on
051: * demand.
052: *
053: * @author Thomas Morgner.
054: */
055: public class ArrayClassFactory implements ClassFactory {
056:
057: /**
058: * Default constructor.
059: */
060: public ArrayClassFactory() {
061: super ();
062: }
063:
064: /**
065: * Returns an object description for a class.
066: *
067: * @param c the class.
068: *
069: * @return The object description.
070: */
071: public ObjectDescription getDescriptionForClass(final Class c) {
072: if (!c.isArray()) {
073: return null;
074: } else {
075: return new ArrayObjectDescription(c);
076: }
077: }
078:
079: /**
080: * Returns an object description for the super class of a class.
081: * This method always returns null.
082: *
083: * @param d the class.
084: * @param knownSuperClass the last known super class or null.
085: *
086: * @return The object description.
087: */
088: public ObjectDescription getSuperClassObjectDescription(
089: final Class d, final ObjectDescription knownSuperClass) {
090: return null;
091: }
092:
093: /**
094: * Returns an iterator for the registered classes. This returns a list
095: * of pre-registered classes known to this ClassFactory. A class may be able
096: * to handle more than the registered classes.
097: * <p>
098: * This method exists to support query tools for UI design, do not rely on it
099: * for day to day work.
100: *
101: * @return The iterator.
102: */
103: public Iterator getRegisteredClasses() {
104: final ArrayList l = new ArrayList();
105: l.add(Object[].class);
106: return l.iterator();
107: }
108:
109: /**
110: * Configures this factory. The configuration contains several keys and
111: * their defined values. The given reference to the configuration object
112: * will remain valid until the report parsing or writing ends.
113: * <p>
114: * The configuration contents may change during the reporting.
115: *
116: * @param config the configuration, never null
117: */
118: public void configure(final Configuration config) {
119: // nothing required
120: }
121:
122: /**
123: * ArrayClassFactories are always equal, there is nothing that could
124: * not be equal :)
125: *
126: * @param o the other object.
127: * @return true, if both object factories describe the same objects, false otherwise.
128: */
129: public boolean equals(final Object o) {
130: if (this == o) {
131: return true;
132: }
133: if (!(o instanceof ArrayClassFactory)) {
134: return false;
135: }
136: return true;
137: }
138:
139: /**
140: * Returns a hash code value for the object. This method is
141: * supported for the benefit of hashtables such as those provided by
142: * <code>java.util.Hashtable</code>.
143: *
144: * @return the computed hashcode.
145: */
146: public int hashCode() {
147: return getClass().hashCode();
148: }
149: }
|