KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > extend > Property


1 /*
2  * Copyright 2005 Joe Walker
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 package org.directwebremoting.extend;
17
18 import java.beans.PropertyDescriptor JavaDoc;
19 import java.lang.reflect.Member JavaDoc;
20 import java.lang.reflect.Method JavaDoc;
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     /**
30      * Gets the name of this property
31      * @return The property name
32      */

33     public String JavaDoc getName();
34
35     /**
36      * What type does this property
37      * @return The type of object that will be returned by {@link #getValue(Object)}
38      */

39     public Class JavaDoc getPropertyType();
40
41     /**
42      * Get the value of this property of the passed in java bean
43      * @param bean The bean to introspect
44      * @return The value assigned to this property of the passed in bean
45      * @throws MarshallException If the reflection access fails
46      */

47     public Object JavaDoc getValue(Object JavaDoc bean) throws MarshallException;
48
49     /**
50      * Set the value of this property of the passed in java bean
51      * @param bean The bean to introspect
52      * @param value The value assigned to this property of the passed in bean
53      * @throws MarshallException If the reflection access fails
54      */

55     public void setValue(Object JavaDoc bean, Object JavaDoc value) 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 JavaDoc getSetter();
65 }
66
Popular Tags