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     * ObjectDescription.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: ObjectDescription.java,v 1.3 2005/11/14 11:03:12 mungady Exp $
036     *
037     * Changes (from 19-Feb-2003)
038     * -------------------------
039     * 19-Feb-2003 : Added standard header and Javadocs (DG);
040     * 29-Apr-2003 : Distilled from the JFreeReport project and moved into JCommon
041     *
042     */
043    
044    package org.jfree.xml.factory.objects;
045    
046    import java.io.Serializable;
047    import java.util.Iterator;
048    
049    import org.jfree.util.Configuration;
050    
051    /**
052     * An interface for object descriptions.
053     *
054     * @author Thomas Morgner
055     */
056    public interface ObjectDescription extends Serializable {
057    
058        /**
059         * Returns a parameter definition. If the parameter is invalid, this
060         * function returns null.
061         *
062         * @param name  the definition name.
063         *
064         * @return The parameter class or null, if the parameter is not defined.
065         */
066        public Class getParameterDefinition(String name);
067    
068        /**
069         * Sets the value of a parameter.
070         *
071         * @param name  the parameter name.
072         * @param value  the parameter value.
073         */
074        public void setParameter(String name, Object value);
075    
076        /**
077         * Returns the value of a parameter.
078         *
079         * @param name  the parameter name.
080         *
081         * @return The value.
082         */
083        public Object getParameter(String name);
084    
085        /**
086         * Returns an iterator the provides access to the parameter names. This
087         * returns all _known_ parameter names, the object description may accept
088         * additional parameters.
089         *
090         * @return The iterator.
091         */
092        public Iterator getParameterNames();
093    
094        /**
095         * Returns the object class.
096         *
097         * @return The Class.
098         */
099        public Class getObjectClass();
100    
101        /**
102         * Creates an object based on the description.
103         *
104         * @return The object.
105         */
106        public Object createObject();
107    
108        /**
109         * Returns a cloned instance of the object description. The contents
110         * of the parameter objects collection are cloned too, so that any
111         * already defined parameter value is copied to the new instance.
112         * <p>
113         * Parameter definitions are not cloned, as they are considered read-only.
114         * <p>
115         * The newly instantiated object description is not configured. If it
116         * need to be configured, then you have to call configure on it.
117         *
118         * @return A cloned instance.
119         */
120        public ObjectDescription getUnconfiguredInstance();
121    
122        /**
123         * Returns a cloned instance of the object description. The contents
124         * of the parameter objects collection are cloned too, so that any
125         * already defined parameter value is copied to the new instance.
126         * <p>
127         * Parameter definitions are not cloned, as they are considered read-only.
128         *
129         * @return A cloned instance.
130         */
131        public ObjectDescription getInstance();
132    
133        /**
134         * Sets the parameters of this description object to match the supplied object.
135         *
136         * @param o  the object.
137         *
138         * @throws ObjectFactoryException if there is a problem while reading the
139         * properties of the given object.
140         */
141        public void setParameterFromObject(Object o) throws ObjectFactoryException;
142    
143    
144        /**
145         * Configures this factory. The configuration contains several keys and
146         * their defined values. The given reference to the configuration object
147         * will remain valid until the report parsing or writing ends.
148         * <p>
149         * The configuration contents may change during the reporting.
150         *
151         * @param config the configuration, never null
152         */
153        public void configure(Configuration config);
154    
155        /**
156         * Compares whether two object descriptions are equal.
157         *
158         * @param o the other object.
159         * @return true, if both object desciptions describe the same object, false otherwise.
160         */
161        public boolean equals (Object o);
162    
163    
164        /**
165         * Computes the hashCode for this ClassFactory. As equals() must be implemented,
166         * a corresponding hashCode() should be implemented as well.
167         *
168         * @return the hashcode.
169         */
170        public int hashCode();
171    
172    }