View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.beanutils;
19  
20  
21  
22  
23  
24  /***
25   * <p>A specialized extension to <code>DynaClass</code> that allows properties
26   * to be added or removed dynamically.</p>
27   *
28   * <p><strong>WARNING</strong> - No guarantees that this will be in the final
29   * APIs ... it's here primarily to preserve some concepts that were in the
30   * original proposal for further discussion.</p>
31   *
32   * @author Craig McClanahan
33   * @author Michael Smith
34   * @author Paulo Gaspar
35   * @version $Revision: 555824 $ $Date: 2007-07-13 01:27:15 +0100 (Fri, 13 Jul 2007) $
36   */
37  
38  public interface MutableDynaClass extends DynaClass {
39  
40  
41      /***
42       * Add a new dynamic property with no restrictions on data type,
43       * readability, or writeability.
44       *
45       * @param name Name of the new dynamic property
46       *
47       * @exception IllegalArgumentException if name is null
48       * @exception IllegalStateException if this DynaClass is currently
49       *  restricted, so no new properties can be added
50       */
51      public void add(String name);
52  
53  
54      /***
55       * Add a new dynamic property with the specified data type, but with
56       * no restrictions on readability or writeability.
57       *
58       * @param name Name of the new dynamic property
59       * @param type Data type of the new dynamic property (null for no
60       *  restrictions)
61       *
62       * @exception IllegalArgumentException if name is null
63       * @exception IllegalStateException if this DynaClass is currently
64       *  restricted, so no new properties can be added
65       */
66      public void add(String name, Class type);
67  
68  
69      /***
70       * Add a new dynamic property with the specified data type, readability,
71       * and writeability.
72       *
73       * @param name Name of the new dynamic property
74       * @param type Data type of the new dynamic property (null for no
75       *  restrictions)
76       * @param readable Set to <code>true</code> if this property value
77       *  should be readable
78       * @param writeable Set to <code>true</code> if this property value
79       *  should be writeable
80       *
81       * @exception IllegalArgumentException if name is null
82       * @exception IllegalStateException if this DynaClass is currently
83       *  restricted, so no new properties can be added
84       */
85      public void add(String name, Class type, boolean readable,
86                      boolean writeable);
87  
88  
89      /***
90       * Is this DynaClass currently restricted, if so, no changes to the
91       * existing registration of property names, data types, readability, or
92       * writeability are allowed.
93       *
94       * @return <code>true</code> if this Mutable {@link DynaClass} is restricted,
95       * otherwise <code>false</code>
96       */
97      public boolean isRestricted();
98  
99  
100     /***
101      * Remove the specified dynamic property, and any associated data type,
102      * readability, and writeability, from this dynamic class.
103      * <strong>NOTE</strong> - This does <strong>NOT</strong> cause any
104      * corresponding property values to be removed from DynaBean instances
105      * associated with this DynaClass.
106      *
107      * @param name Name of the dynamic property to remove
108      *
109      * @exception IllegalArgumentException if name is null
110      * @exception IllegalStateException if this DynaClass is currently
111      *  restricted, so no properties can be removed
112      */
113     public void remove(String name);
114 
115 
116     /***
117      * Set the restricted state of this DynaClass to the specified value.
118      *
119      * @param restricted The new restricted state
120      */
121     public void setRestricted(boolean restricted);
122 
123 
124 }