KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > convert > PlainProperty


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.convert;
17
18 import java.lang.reflect.Method JavaDoc;
19
20 import org.directwebremoting.extend.MarshallException;
21 import org.directwebremoting.extend.Property;
22 import org.directwebremoting.util.Logger;
23
24 /**
25  * An implementation of {@link Property} that simply uses stored values.
26  * @author Joe Walker [joe at getahead dot ltd dot uk]
27  */

28 public class PlainProperty implements Property
29 {
30     /**
31      * @param name The property name
32      * @param value The property value irrespective of the object that we read it on
33      */

34     public PlainProperty(String JavaDoc name, Object JavaDoc value)
35     {
36         this.name = name;
37         this.value = value;
38     }
39
40     /* (non-Javadoc)
41      * @see org.directwebremoting.extend.Property#getName()
42      */

43     public String JavaDoc getName()
44     {
45         return name;
46     }
47
48     /* (non-Javadoc)
49      * @see org.directwebremoting.extend.Property#getPropertyType()
50      */

51     public Class JavaDoc getPropertyType()
52     {
53         return value.getClass();
54     }
55
56     /* (non-Javadoc)
57      * @see org.directwebremoting.extend.Property#getSetter()
58      */

59     public Method JavaDoc getSetter()
60     {
61         return null;
62     }
63
64     /* (non-Javadoc)
65      * @see org.directwebremoting.extend.Property#getValue(java.lang.Object)
66      */

67     public Object JavaDoc getValue(Object JavaDoc bean) throws MarshallException
68     {
69         return value;
70     }
71
72     /* (non-Javadoc)
73      * @see org.directwebremoting.extend.Property#setValue(java.lang.Object, java.lang.Object)
74      */

75     public void setValue(Object JavaDoc bean, Object JavaDoc value) throws MarshallException
76     {
77         log.warn("Attempt to setValue() on plain property.");
78     }
79
80     /**
81      * The name of this property
82      */

83     private String JavaDoc name;
84
85     /**
86      * The property value irrespective of the object that we read it on
87      */

88     private Object JavaDoc value;
89
90     /**
91      * The log stream
92      */

93     private static final Logger log = Logger.getLogger(PlainProperty.class);
94 }
95
Popular Tags