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 package org.apache.commons.scaffold.util; 18 19 20 import java.util.Map; 21 22 /** 23 * Simple interface to describe an object that can set and 24 * return its public properties via a Map. 25 * business logic object. 26 * @author Ted Husted 27 * @version $Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $ 28 */ 29 public interface Mapped { 30 31 // ------------------------------------------------------- Public Methods 32 33 /** 34 * Return a Map of this object's public properties. 35 * The values may be of any type, though an implementation 36 * may choose to return only Strings. The keys for the entries 37 * may or may not exactly match the true public properties 38 * of the implementing object, as needed. 39 * @exception Throws Exception on any error. A subclass of 40 * ChainedException is recommended. 41 */ 42 public Map getMap() throws Exception; 43 44 45 /** 46 * Set this object's public properties via a Map. 47 * The values may be of any type, though a subclass may 48 * choose to expect only Strings. The keys for the entries 49 * may or may not exactly match the true public properties, 50 * of the object, as required. 51 * @exception Throws Exception on any error. A subclass of 52 * ChainedException is recommended. 53 */ 54 public void setMap(Map map) throws Exception; 55 56 57 /** 58 * Returns the value to which this map maps the specified key 59 * -- the equivalent of <code>Object getMap().get(key). 60 * @exception Throws Exception on any error. A subclass of 61 * ChainedException is recommended. 62 * @param key - key whose associated value is to be returned. 63 */ 64 public Object getValue(Object key) throws Exception; 65 66 67 /** 68 * Associates the specified value with the specified key in 69 * the property map for this object 70 * -- the equivalent of <code>getMap().put(key,value). 71 * @param key - key with which the specified value is to be associated. 72 * @param value - value to be associated with the specified key. 73 * @exception Throws Exception on any error. A subclass of 74 * ChainedException is recommended. 75 */ 76 public Object setValue(Object key, Object value) throws Exception; 77 78 }