01: package org.geotools.filter.expression;
02:
03: import org.geotools.util.Converters;
04:
05: /**
06: * Placeholder value for the result of an expression.
07: * <p>
08: * This class holds onto the value of an expression in one form, and converts it on demand
09: * into
10: * </p>
11: *
12: * @author Justin Deoliveira, The Open Planning Project
13: *
14: */
15: public class Value {
16:
17: /**
18: * The "raw" value.
19: */
20: Object value;
21:
22: /**
23: * Creates the placeholder.
24: *
25: * @param value The raw value of the placeholder.
26: */
27: public Value(Object value) {
28: this .value = value;
29: }
30:
31: /**
32: * @return The raw value.
33: */
34: public Object getValue() {
35: return value;
36: }
37:
38: /**
39: * Sets the raw value.
40: */
41: public void setValue(Object value) {
42: this .value = value;
43: }
44:
45: /**
46: * Returns the "raw" value converted into an instance of <param>context</param>.
47: *
48: * @param context The type of the object to be converted to.
49: *
50: * @return The converted object ( an instance of <param>context</param>, or <code>null</code> ).
51: */
52: public Object value(Class context) {
53: if (value == null || context.isAssignableFrom(value.getClass()))
54: return value;
55:
56: return Converters.convert(value, context);
57: }
58: }
|