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.convert;
17:
18: import java.lang.reflect.Method;
19:
20: import org.apache.commons.logging.LogFactory;
21: import org.apache.commons.logging.Log;
22: import org.directwebremoting.extend.MarshallException;
23: import org.directwebremoting.extend.Property;
24:
25: /**
26: * An implementation of {@link Property} that simply uses stored values.
27: * @author Joe Walker [joe at getahead dot ltd dot uk]
28: */
29: public class PlainProperty implements Property {
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 name, Object value) {
35: this .name = name;
36: this .value = value;
37: }
38:
39: /* (non-Javadoc)
40: * @see org.directwebremoting.extend.Property#getName()
41: */
42: public String getName() {
43: return name;
44: }
45:
46: /* (non-Javadoc)
47: * @see org.directwebremoting.extend.Property#getPropertyType()
48: */
49: public Class<?> getPropertyType() {
50: return value.getClass();
51: }
52:
53: /* (non-Javadoc)
54: * @see org.directwebremoting.extend.Property#getSetter()
55: */
56: public Method getSetter() {
57: return null;
58: }
59:
60: /* (non-Javadoc)
61: * @see org.directwebremoting.extend.Property#getValue(java.lang.Object)
62: */
63: public Object getValue(Object bean) throws MarshallException {
64: return value;
65: }
66:
67: /* (non-Javadoc)
68: * @see org.directwebremoting.extend.Property#setValue(java.lang.Object, java.lang.Object)
69: */
70: public void setValue(Object bean, Object value)
71: throws MarshallException {
72: log.warn("Attempt to setValue() on plain property.");
73: }
74:
75: /**
76: * The name of this property
77: */
78: private final String name;
79:
80: /**
81: * The property value irrespective of the object that we read it on
82: */
83: private final Object value;
84:
85: /**
86: * The log stream
87: */
88: private static final Log log = LogFactory
89: .getLog(PlainProperty.class);
90: }
|