    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     * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
    035     * @version $Id: Expression.java 884175 2009-11-25 16:23:41Z henrib $
    036     */
    037    public interface Expression {
    038        /**
    039         * Evaluates the expression with the variables contained in the
    040         * supplied {@link JexlContext}.
    041         *
    042         * @param context A JexlContext containing variables.
    043         * @return The result of this evaluation
    044         * @throws JexlException on any error
    045         */
    046        Object evaluate(JexlContext context);
    047
    048        /**
    049         * Returns the JEXL expression this Expression was created with.
    050         *
    051         * @return The JEXL expression to be evaluated
    052         */
    053        String getExpression();
    054
    055        /**
    056         * Returns the JEXL expression by reconstructing it from the parsed tree.
    057         * @return the JEXL expression
    058         */
    059        String dump();
    060    }