01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.directwebremoting.extend;
17:
18: import java.beans.PropertyDescriptor;
19: import java.lang.reflect.Member;
20: import java.lang.reflect.Method;
21:
22: /**
23: * It would be nice if {@link PropertyDescriptor}, and the various reflection
24: * types like {@link Member} had a common supertype, but they don't. This is it.
25: * @author Joe Walker [joe at getahead dot ltd dot uk]
26: */
27: public interface Property {
28: /**
29: * Gets the name of this property
30: * @return The property name
31: */
32: public String getName();
33:
34: /**
35: * What type does this property
36: * @return The type of object that will be returned by {@link #getValue(Object)}
37: */
38: public Class<?> getPropertyType();
39:
40: /**
41: * Get the value of this property of the passed in java bean
42: * @param bean The bean to introspect
43: * @return The value assigned to this property of the passed in bean
44: * @throws MarshallException If the reflection access fails
45: */
46: public Object getValue(Object bean) throws MarshallException;
47:
48: /**
49: * Set the value of this property of the passed in java bean
50: * @param bean The bean to introspect
51: * @param value The value assigned to this property of the passed in bean
52: * @throws MarshallException If the reflection access fails
53: */
54: public void setValue(Object bean, Object value)
55: throws MarshallException;
56:
57: /**
58: * This is a nasty hack - {@link TypeHintContext} needs a {@link Method}.
59: * If you are implementing this and not proxying to a {@link PropertyDescriptor}
60: * then you can probably return <code>null</code>.
61: * We should probably refactor {@link TypeHintContext} to use {@link Property}
62: * @return A setter method if one is available, or null otherwise
63: */
64: public Method getSetter();
65: }
|