    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    package org.apache.commons.beanutils;
    019
    020
    021
    022
    023
    024    /**
    025     * <p>A specialized extension to <code>DynaClass</code> that allows properties
    026     * to be added or removed dynamically.</p>
    027     *
    028     * <p><strong>WARNING</strong> - No guarantees that this will be in the final
    029     * APIs ... it's here primarily to preserve some concepts that were in the
    030     * original proposal for further discussion.</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
    038    public interface MutableDynaClass extends DynaClass {
    039
    040
    041        /**
    042         * Add a new dynamic property with no restrictions on data type,
    043         * readability, or writeability.
    044         *
    045         * @param name Name of the new dynamic property
    046         *
    047         * @exception IllegalArgumentException if name is null
    048         * @exception IllegalStateException if this DynaClass is currently
    049         *  restricted, so no new properties can be added
    050         */
    051        public void add(String name);
    052
    053
    054        /**
    055         * Add a new dynamic property with the specified data type, but with
    056         * no restrictions on readability or writeability.
    057         *
    058         * @param name Name of the new dynamic property
    059         * @param type Data type of the new dynamic property (null for no
    060         *  restrictions)
    061         *
    062         * @exception IllegalArgumentException if name is null
    063         * @exception IllegalStateException if this DynaClass is currently
    064         *  restricted, so no new properties can be added
    065         */
    066        public void add(String name, Class type);
    067
    068
    069        /**
    070         * Add a new dynamic property with the specified data type, readability,
    071         * and writeability.
    072         *
    073         * @param name Name of the new dynamic property
    074         * @param type Data type of the new dynamic property (null for no
    075         *  restrictions)
    076         * @param readable Set to <code>true</code> if this property value
    077         *  should be readable
    078         * @param writeable Set to <code>true</code> if this property value
    079         *  should be writeable
    080         *
    081         * @exception IllegalArgumentException if name is null
    082         * @exception IllegalStateException if this DynaClass is currently
    083         *  restricted, so no new properties can be added
    084         */
    085        public void add(String name, Class type, boolean readable,
    086                        boolean writeable);
    087
    088
    089        /**
    090         * Is this DynaClass currently restricted, if so, no changes to the
    091         * existing registration of property names, data types, readability, or
    092         * writeability are allowed.
    093         *
    094         * @return <code>true</code> if this Mutable {@link DynaClass} is restricted,
    095         * otherwise <code>false</code>
    096         */
    097        public boolean isRestricted();
    098
    099
    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    }