View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */ 
16  
17  
18  package org.apache.commons.beanutils;
19  
20  
21  
22  
23  
24  /**
25   * <p>A <strong>DynaClass</strong> is a simulation of the functionality of
26   * <code>java.lang.Class</code> for classes implementing the
27   * <code>DynaBean</code> interface.  DynaBean instances that share the same
28   * DynaClass all have the same set of available properties, along with any
29   * associated data types, read-only states, and write-only states.</p>
30   *
31   * @author Craig McClanahan
32   * @author Michael Smith
33   * @author Paulo Gaspar
34   * @version $Revision: 1.12 $ $Date: 2004/02/28 13:18:33 $
35   */
36  
37  public interface DynaClass {
38  
39  
40      /**
41       * Return the name of this DynaClass (analogous to the
42       * <code>getName()</code> method of <code>java.lang.Class</code), which
43       * allows the same <code>DynaClass</code> implementation class to support
44       * different dynamic classes, with different sets of properties.
45       */
46      public String getName();
47  
48  
49      /**
50       * Return a property descriptor for the specified property, if it exists;
51       * otherwise, return <code>null</code>.
52       *
53       * @param name Name of the dynamic property for which a descriptor
54       *  is requested
55       *
56       * @exception IllegalArgumentException if no property name is specified
57       */
58      public DynaProperty getDynaProperty(String name);
59  
60  
61      /**
62       * <p>Return an array of <code>ProperyDescriptors</code> for the properties
63       * currently defined in this DynaClass.  If no properties are defined, a
64       * zero-length array will be returned.</p>
65       *
66       * <p><strong>FIXME</strong> - Should we really be implementing
67       * <code>getBeanInfo()</code> instead, which returns property descriptors
68       * and a bunch of other stuff?</p>
69       */
70      public DynaProperty[] getDynaProperties();
71  
72  
73      /**
74       * Instantiate and return a new DynaBean instance, associated
75       * with this DynaClass.
76       *
77       * @exception IllegalAccessException if the Class or the appropriate
78       *  constructor is not accessible
79       * @exception InstantiationException if this Class represents an abstract
80       *  class, an array class, a primitive type, or void; or if instantiation
81       *  fails for some other reason
82       */
83      public DynaBean newInstance()
84              throws IllegalAccessException, InstantiationException;
85  
86  
87  }