1 package org.apache.commons.ognl.enhance;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.commons.ognl.Node;
23 import org.apache.commons.ognl.OgnlContext;
24
25 /**
26 * Provides pure java expression paths to get/set values from an ognl expression. This is achieved by taking an existing
27 * {@link Node} parsed expression and using bytecode enhancements to do the same work using pure java vs the ognl
28 * interpreter.
29 */
30 public interface ExpressionAccessor
31 {
32
33 /**
34 * Gets the value represented by this expression path, if any.
35 *
36 * @param context The standard ognl context used for variable substitution/etc.
37 * @param target The root object this expression is meant for.
38 * @return The evaluated value, if any.
39 */
40 Object get( OgnlContext context, Object target );
41
42 /**
43 * Sets the value represented by this expression path, if possible.
44 *
45 * @param context The standard ognl context used for variable substitution/etc.
46 * @param target The root object this expression is meant for.
47 * @param value The new value to set if this expression references a settable property.
48 */
49 void set( OgnlContext context, Object target, Object value );
50
51 /**
52 * Used to set the original root expression node on instances where the compiled version has to fall back to
53 * interpreted syntax because of compilation failures.
54 *
55 * @param expression The root expression node used to generate this accessor.
56 */
57 void setExpression( Node expression );
58 }