001// Copyright 2004, 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry.services;
016
017/**
018 * Wrapper around the OGNL library.
019 * 
020 * @author Howard M. Lewis Ship
021 * @since 4.0
022 */
023public interface ExpressionEvaluator
024{
025    /**
026     * Reads a property of the target, defined by the expression.
027     * 
028     * @throws org.apache.hivemind.ApplicationRuntimeException
029     *             if the expression can not be parsed, or if some other error occurs during
030     *             evaluation of the expression.
031     */
032    public Object read(Object target, String expression);
033
034    /**
035     * Reads a property of the target, defined by the (previously compiled) expression.
036     * 
037     * @throws org.apache.hivemind.ApplicationRuntimeException
038     *             if some other error occurs during evaluation of the expression.
039     */
040    public Object readCompiled(Object target, Object expression);
041
042    /**
043     * Updates a property of the target, defined by the expression.
044     * 
045     * @throws org.apache.hivemind.ApplicationRuntimeException
046     *             if the expression can not be parsed, or if some other error occurs during
047     *             evaluation of the expression.
048     */
049    public void write(Object target, String expression, Object value);
050
051    /**
052     * Updates a property of the target, defined by the (previously compiled) expression.
053     * 
054     * @throws org.apache.hivemind.ApplicationRuntimeException
055     *             if some other error occurs during evaluation of the expression.
056     */
057    public void writeCompiled(Object target, Object expression, Object value);
058
059    /**
060     * Returns true if the expression evaluates to a constant or other literal value.
061     * 
062     * @throws org.apache.hivemind.ApplicationRuntimeException
063     *             if the expression is not valid
064     */
065    public boolean isConstant(String expression);
066}