01: package nl.knowlogy.validation.utils;
02:
03: import org.apache.commons.beanutils.PropertyUtils;
04:
05: /**
06: *
07: *
08: * @author roho
09: *
10: */
11: public class ExpressionEvaluator {
12:
13: private Object outerObject;
14: private String propertyName;
15:
16: public ExpressionEvaluator(Object object, String propertyExpression)
17: throws Exception {
18: outerObject = object;
19: propertyName = propertyExpression;
20:
21: int indexOfPoint = propertyName.indexOf('.');
22: while (indexOfPoint != -1) {
23:
24: String objectPart = propertyName.substring(0, indexOfPoint);
25: propertyName = propertyName.substring(indexOfPoint + 1,
26: propertyName.length());
27:
28: outerObject = PropertyUtils.getSimpleProperty(outerObject,
29: objectPart);
30: indexOfPoint = propertyName.indexOf('.');
31: }
32: }
33:
34: public String getPropertyName() {
35: return propertyName;
36: }
37:
38: public Object getOuterObject() {
39: return outerObject;
40: }
41:
42: }
|