001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    package org.apache.commons.jexl2;
019    
020    
021    /**
022     * Represents a single JEXL expression.
023     * <p>
024     * This simple interface provides access to the underlying expression through
025     * {@link Expression#getExpression()}.
026     * </p>
027     *
028     * <p>
029     * An expression is different than a script - it is simply a reference of
030     * an expression.
031     * </p>
032     *
033     * @since 1.0
034     */
035    public interface Expression {
036        /**
037         * Evaluates the expression with the variables contained in the
038         * supplied {@link JexlContext}.
039         *
040         * @param context A JexlContext containing variables.
041         * @return The result of this evaluation
042         * @throws JexlException on any error
043         */
044        Object evaluate(JexlContext context);
045    
046        /**
047         * Returns the JEXL expression this Expression was created with.
048         *
049         * @return The JEXL expression to be evaluated
050         */
051        String getExpression();
052    
053        /**
054         * Returns the JEXL expression by reconstructing it from the parsed tree.
055         * @return the JEXL expression
056         */
057        String dump();
058    }