001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018
019package org.apache.commons.beanutils;
020
021
022
023
024
025/**
026 * <p>A <strong>DynaClass</strong> is a simulation of the functionality of
027 * <code>java.lang.Class</code> for classes implementing the
028 * <code>DynaBean</code> interface.  DynaBean instances that share the same
029 * DynaClass all have the same set of available properties, along with any
030 * associated data types, read-only states, and write-only states.</p>
031 *
032 * @author Craig McClanahan
033 * @author Michael Smith
034 * @author Paulo Gaspar
035 * @version $Revision: 555824 $ $Date: 2007-07-13 01:27:15 +0100 (Fri, 13 Jul 2007) $
036 */
037
038public interface DynaClass {
039
040
041    /**
042     * Return the name of this DynaClass (analogous to the
043     * <code>getName()</code> method of <code>java.lang.Class</code), which
044     * allows the same <code>DynaClass</code> implementation class to support
045     * different dynamic classes, with different sets of properties.
046     *
047     * @return the name of the DynaClass
048     */
049    public String getName();
050
051
052    /**
053     * Return a property descriptor for the specified property, if it exists;
054     * otherwise, return <code>null</code>.
055     *
056     * @param name Name of the dynamic property for which a descriptor
057     *  is requested
058     * @return The descriptor for the specified property
059     *
060     * @exception IllegalArgumentException if no property name is specified
061     */
062    public DynaProperty getDynaProperty(String name);
063
064
065    /**
066     * <p>Return an array of <code>ProperyDescriptors</code> for the properties
067     * currently defined in this DynaClass.  If no properties are defined, a
068     * zero-length array will be returned.</p>
069     *
070     * <p><strong>FIXME</strong> - Should we really be implementing
071     * <code>getBeanInfo()</code> instead, which returns property descriptors
072     * and a bunch of other stuff?</p>
073     *
074     * @return the set of properties for this DynaClass
075     */
076    public DynaProperty[] getDynaProperties();
077
078
079    /**
080     * Instantiate and return a new DynaBean instance, associated
081     * with this DynaClass.
082     *
083     * @return A new <code>DynaBean</code> instance
084     *
085     * @exception IllegalAccessException if the Class or the appropriate
086     *  constructor is not accessible
087     * @exception InstantiationException if this Class represents an abstract
088     *  class, an array class, a primitive type, or void; or if instantiation
089     *  fails for some other reason
090     */
091    public DynaBean newInstance()
092            throws IllegalAccessException, InstantiationException;
093
094
095}