01: //--------------------------------------------------------------------------
02: // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard
03: // All rights reserved.
04: //
05: // Redistribution and use in source and binary forms, with or without
06: // modification, are permitted provided that the following conditions are
07: // met:
08: //
09: // Redistributions of source code must retain the above copyright notice,
10: // this list of conditions and the following disclaimer.
11: // Redistributions in binary form must reproduce the above copyright
12: // notice, this list of conditions and the following disclaimer in the
13: // documentation and/or other materials provided with the distribution.
14: // Neither the name of the Drew Davidson nor the names of its contributors
15: // may be used to endorse or promote products derived from this software
16: // without specific prior written permission.
17: //
18: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20: // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22: // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24: // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25: // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26: // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27: // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28: // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29: // DAMAGE.
30: //--------------------------------------------------------------------------
31: package ognl;
32:
33: import java.util.Map;
34:
35: /**
36: * This interface defines methods for setting and getting a property from a target object.
37: * A "property" in this case is a named data value that takes the generic form of an
38: * Object---the same definition as is used by beans. But the operational semantics of the
39: * term will vary by implementation of this interface: a bean-style implementation will
40: * get and set properties as beans do, by reflection on the target object's class, but
41: * other implementations are possible, such as one that uses the property name as a key
42: * into a map.
43: *
44: * <p> An implementation of this interface will often require that its target objects all
45: * be of some particular type. For example, the MapPropertyAccessor class requires that
46: * its targets all implement the java.util.Map interface.
47: *
48: * <p> Note that the "name" of a property is represented by a generic Object. Some
49: * implementations may require properties' names to be Strings, while others may allow
50: * them to be other types---for example, ArrayPropertyAccessor treats Number names as
51: * indexes into the target object, which must be an array.
52: * @author Luke Blanshard (blanshlu@netscape.net)
53: * @author Drew Davidson (drew@ognl.org)
54: */
55: public interface PropertyAccessor {
56: /**
57: * Extracts and returns the property of the given name from the given target object.
58: * @param target the object to get the property from
59: * @param name the name of the property to get
60: * @return the current value of the given property in the given object
61: * @exception OgnlException if there is an error locating the property in the given object
62: */
63: Object getProperty(Map context, Object target, Object name)
64: throws OgnlException;
65:
66: /**
67: * Sets the value of the property of the given name in the given target object.
68: * @param target the object to set the property in
69: * @param name the name of the property to set
70: * @param value the new value for the property
71: * @exception OgnlException if there is an error setting the property in the given object
72: */
73: void setProperty(Map context, Object target, Object name,
74: Object value) throws OgnlException;
75: }
|