01: /*
02: * Copyright 2006, 2007 Odysseus Software GmbH
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 de.odysseus.el.tree.impl.ast;
17:
18: import javax.el.ELContext;
19: import javax.el.MethodInfo;
20:
21: import de.odysseus.el.tree.Bindings;
22:
23: public final class AstEval extends AstNode {
24: private final AstNode child;
25: private final boolean deferred;
26:
27: public AstEval(AstNode child, boolean deferred) {
28: this .child = child;
29: this .deferred = deferred;
30: }
31:
32: public boolean isDeferred() {
33: return deferred;
34: }
35:
36: public boolean isLeftValue() {
37: return getChild(0).isLeftValue();
38: }
39:
40: @Override
41: public Object eval(Bindings bindings, ELContext context) {
42: return child.eval(bindings, context);
43: }
44:
45: @Override
46: public String toString() {
47: return (deferred ? "#" : "$") + "{...}";
48: }
49:
50: @Override
51: public void appendStructure(StringBuilder b, Bindings bindings) {
52: b.append(deferred ? "#{" : "${");
53: child.appendStructure(b, bindings);
54: b.append("}");
55: }
56:
57: public MethodInfo getMethodInfo(Bindings bindings,
58: ELContext context, Class returnType, Class[] paramTypes) {
59: return child.getMethodInfo(bindings, context, returnType,
60: paramTypes);
61: }
62:
63: public Object invoke(Bindings bindings, ELContext context,
64: Class<?> returnType, Class<?>[] paramTypes,
65: Object[] paramValues) {
66: return child.invoke(bindings, context, returnType, paramTypes,
67: paramValues);
68: }
69:
70: public Class<?> getType(Bindings bindings, ELContext context) {
71: return child.getType(bindings, context);
72: }
73:
74: public boolean isLiteralText() {
75: return child.isLiteralText();
76: }
77:
78: public boolean isReadOnly(Bindings bindings, ELContext context) {
79: return child.isReadOnly(bindings, context);
80: }
81:
82: public void setValue(Bindings bindings, ELContext context,
83: Object value) {
84: child.setValue(bindings, context, value);
85: }
86:
87: public int getCardinality() {
88: return 1;
89: }
90:
91: public AstNode getChild(int i) {
92: return i == 0 ? child : null;
93: }
94: }
|