Source for org.jfree.xml.factory.objects.ObjectDescription

   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:  * ObjectDescription.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: ObjectDescription.java,v 1.3 2005/11/14 11:03:12 mungady Exp $
  36:  *
  37:  * Changes (from 19-Feb-2003)
  38:  * -------------------------
  39:  * 19-Feb-2003 : Added standard header and Javadocs (DG);
  40:  * 29-Apr-2003 : Distilled from the JFreeReport project and moved into JCommon
  41:  *
  42:  */
  43: 
  44: package org.jfree.xml.factory.objects;
  45: 
  46: import java.io.Serializable;
  47: import java.util.Iterator;
  48: 
  49: import org.jfree.util.Configuration;
  50: 
  51: /**
  52:  * An interface for object descriptions.
  53:  *
  54:  * @author Thomas Morgner
  55:  */
  56: public interface ObjectDescription extends Serializable {
  57: 
  58:     /**
  59:      * Returns a parameter definition. If the parameter is invalid, this
  60:      * function returns null.
  61:      *
  62:      * @param name  the definition name.
  63:      *
  64:      * @return The parameter class or null, if the parameter is not defined.
  65:      */
  66:     public Class getParameterDefinition(String name);
  67: 
  68:     /**
  69:      * Sets the value of a parameter.
  70:      *
  71:      * @param name  the parameter name.
  72:      * @param value  the parameter value.
  73:      */
  74:     public void setParameter(String name, Object value);
  75: 
  76:     /**
  77:      * Returns the value of a parameter.
  78:      *
  79:      * @param name  the parameter name.
  80:      *
  81:      * @return The value.
  82:      */
  83:     public Object getParameter(String name);
  84: 
  85:     /**
  86:      * Returns an iterator the provides access to the parameter names. This
  87:      * returns all _known_ parameter names, the object description may accept
  88:      * additional parameters.
  89:      *
  90:      * @return The iterator.
  91:      */
  92:     public Iterator getParameterNames();
  93: 
  94:     /**
  95:      * Returns the object class.
  96:      *
  97:      * @return The Class.
  98:      */
  99:     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: }