01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.filter.expression;
17:
18: import org.geotools.feature.IllegalAttributeException;
19:
20: /**
21: * Used to get and set object properties based on an xpath expression.
22: *
23: * @author Justin Deoliveira, The Open Planning Project
24: *
25: */
26: public interface PropertyAccessor {
27: /**
28: * Determines if the property accessor can handle the property denoted by <param>xpath</param>.
29: * <p>
30: * Can be used to perform checks against schema to ensure that the propery accessor
31: * will actually work with the provided instance.
32: * </p>
33: *
34: * @param object The target object.
35: * @param xpath An xpath expression denoting a property of the target object.
36: *
37: * @return <code>true</code> if the property can be accessed, otherwise <code>false</code>
38: */
39: boolean canHandle(Object object, String xpath, Class target);
40:
41: /**
42: * Accesses a property of <param>object</param> via xpath expression.
43: * <p>
44: * {@link #canHandle(Object, String)} should be called before calling this method to ensure
45: * that the property can be safely accessed.
46: * </p>
47: * @param object The target object.
48: * @param xpath An xpath expression denoting a property of the target object.
49: * @param target Target context we intend to access (often null or Geometry.class)
50: * @return The property, which might be <code>null</code>
51: *
52: * @throws IllegalArgumentException In the even that xpath is not supported.
53: */
54: Object get(Object object, String xpath, Class target)
55: throws IllegalArgumentException;
56:
57: /**
58: * Sets a property of <param>object</param> via xpath expression.
59: * <p>
60: * {@link #canHandle(Object, String)} should be called before calling this method to ensure
61: * that the property can be safely accessed.
62: * </p>
63: * @param object The target object.
64: * @param xpath An xpath expression denoting a property of the target object.
65: * @param value The new value to set
66: * @param target The target context we intend to update (often null or Geometry.class)
67: *
68: * @throws IllegalAttributeException If the value set is not legal for the target object.
69: * @throws IllegalArgumentException In the even that xpath is not supported.
70: */
71: void set(Object object, String xpath, Object value, Class target)
72: throws IllegalAttributeException, IllegalArgumentException;
73: }
|