01: /*
02: * Copyright 2004-2007 the original author or authors.
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.springframework.binding.expression;
17:
18: import org.springframework.core.style.ToStringCreator;
19:
20: /**
21: * A simple holder for information about an evaluation attempt.
22: *
23: * @author Keith Donald
24: */
25: public class EvaluationAttempt {
26:
27: /**
28: * The expression that attempted to evaluate.
29: */
30: private Expression expression;
31:
32: /**
33: * The target object being evaluated.
34: */
35: private Object target;
36:
37: /**
38: * The evaluation context.
39: */
40: private EvaluationContext context;
41:
42: /**
43: * Create an evaluation attempt.
44: * @param expression the expression that failed to evaluate
45: * @param target the target of the expression
46: * @param context the context attributes that might have affected evaluation behavior
47: */
48: public EvaluationAttempt(Expression expression, Object target,
49: EvaluationContext context) {
50: this .expression = expression;
51: this .target = target;
52: this .context = context;
53: }
54:
55: /**
56: * Returns the expression that attempted to evaluate.
57: */
58: public Expression getExpression() {
59: return expression;
60: }
61:
62: /**
63: * Returns the target object upon which evaluation was attempted.
64: */
65: public Object getTarget() {
66: return target;
67: }
68:
69: /**
70: * Returns context attributes that may have influenced the evaluation process.
71: */
72: public EvaluationContext getContext() {
73: return context;
74: }
75:
76: public String toString() {
77: return createToString(new ToStringCreator(this )).toString();
78: }
79:
80: protected ToStringCreator createToString(ToStringCreator creator) {
81: return creator.append("expression", expression).append(
82: "target", target).append("context", context);
83: }
84: }
|