01: /*
02: * Created on Oct 22, 2005
03: */
04: package uk.org.ponder.beanutil;
05:
06: /** A slightly slimmer version of the Spring PropertyAccessor interface.
07: * Wraps (probably reflective) operations performed on a single bean. Note that
08: * these methods take the parent object as argument and hence PropertyAccessors
09: * are generally immutable (per class), leading to great economies.
10: * @see BeanWrapperImpl for examples of incredible diseconomies.
11: * @author Antranig Basman (antranig@caret.cam.ac.uk)
12: *
13: */
14: //TODO This is still somewhat odd since all these take property name
15: // as argument, but I guess this is unavoidable if we want a 1st-class
16: // abstraction equivalent to a map. For efficiency, we probably want a
17: // mid-level class delivering AccessMethods so we can avoid the hashtable
18: // hit on each call.
19: public interface PropertyAccessor {
20:
21: public boolean canSet(String name);
22:
23: public void setProperty(Object parent, String name, Object value);
24:
25: public void unlink(Object parent, String name);
26:
27: public boolean canGet(String name);
28:
29: public Object getProperty(Object parent, String name);
30:
31: /**
32: * Returns the type of this property. If it is a collection or other
33: * denumerable type for which we have a mapping or inference, this will be the
34: * contained type of the collection rather than the collection type itself.
35: * In this case, getProperty will return an object some enumerable or denumerable
36: * object rather than one of this type.
37: */
38: public Class getPropertyType(Object parent, String name);
39:
40: public boolean isMultiple(Object parent, String name);
41: }
|