001    /*
002     * Copyright 2001,2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.apache.commons.scaffold.util;
018    
019    
020    import java.util.Map;
021    
022    /**
023     * Simple interface to describe an object that can set and
024     * return its public properties via a Map.
025     * business logic object.
026     * @author Ted Husted
027     * @version $Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $
028     */
029    public interface Mapped {
030    
031    // ------------------------------------------------------- Public Methods
032    
033        /**
034         * Return a Map of this object's public properties.
035         * The values may be of any type, though an implementation
036         * may choose to return only Strings. The keys for the entries
037         * may or may not exactly match the true public properties
038         * of the implementing object, as needed.
039         * @exception Throws Exception on any error. A subclass of
040         * ChainedException is recommended.
041         */
042        public Map getMap() throws Exception;
043    
044    
045        /**
046         * Set this object's public properties via a Map.
047         * The values may be of any type, though a subclass may
048         * choose to expect only Strings. The keys for the entries
049         * may or may not exactly match the true public properties,
050         * of the object, as required.
051         * @exception Throws Exception on any error. A subclass of
052         * ChainedException is recommended.
053         */
054        public void setMap(Map map) throws Exception;
055    
056    
057        /**
058         * Returns the value to which this map maps the specified key
059         * -- the equivalent of <code>Object getMap().get(key).
060         * @exception Throws Exception on any error. A subclass of
061         * ChainedException is recommended.
062         * @param key - key whose associated value is to be returned.
063         */
064        public Object getValue(Object key) throws Exception;
065    
066    
067        /**
068         * Associates the specified value with the specified key in
069         * the property map for this object
070         * -- the equivalent of <code>getMap().put(key,value).
071         * @param key - key with which the specified value is to be associated.
072         * @param value - value to be associated with the specified key.
073         * @exception Throws Exception on any error. A subclass of
074         * ChainedException is recommended.
075         */
076        public Object setValue(Object key, Object value) throws Exception;
077    
078    }