01: /**
02: * MVEL (The MVFLEX Expression Language)
03: *
04: * Copyright (C) 2007 Christopher Brock, MVFLEX/Valhalla Project and the Codehaus
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */package org.mvel.optimizers.impl.refl;
19:
20: import org.mvel.compiler.Accessor;
21: import org.mvel.integration.VariableResolverFactory;
22: import org.mvel.optimizers.AccessorOptimizer;
23: import org.mvel.optimizers.OptimizerFactory;
24:
25: /**
26: * @author Christopher Brock
27: */
28: public class Union implements Accessor {
29: private Accessor accessor;
30:
31: private char[] nextExpr;
32: private Accessor nextAccessor;
33:
34: public Object getValue(Object ctx, Object elCtx,
35: VariableResolverFactory variableFactory) {
36: if (nextAccessor == null) {
37: Object o = accessor.getValue(ctx, elCtx, variableFactory);
38:
39: AccessorOptimizer ao = OptimizerFactory
40: .getDefaultAccessorCompiler();
41: nextAccessor = ao.optimizeAccessor(nextExpr, o, elCtx,
42: variableFactory, false);
43:
44: return ao.getResultOptPass();
45: // return nextAccessor.getValue(o, elCtx, variableFactory);
46: } else {
47: return nextAccessor.getValue(accessor.getValue(ctx, elCtx,
48: variableFactory), elCtx, variableFactory);
49: }
50: }
51:
52: public Union(Accessor accessor, char[] nextAccessor) {
53: this .accessor = accessor;
54: this .nextExpr = nextAccessor;
55: }
56:
57: public Object setValue(Object ctx, Object elCtx,
58: VariableResolverFactory variableFactory, Object value) {
59: return null;
60: }
61: }
|