001 /******************************************************************************* 002 * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian 003 * Thomschke. 004 * 005 * All Rights Reserved. This program and the accompanying materials 006 * are made available under the terms of the Eclipse Public License v1.0 007 * which accompanies this distribution, and is available at 008 * http://www.eclipse.org/legal/epl-v10.html 009 * 010 * Contributors: 011 * Sebastian Thomschke - initial implementation. 012 *******************************************************************************/ 013 package net.sf.oval.expression; 014 015 import java.util.Map; 016 017 import net.sf.oval.exception.ExpressionEvaluationException; 018 019 /** 020 * @author Sebastian Thomschke 021 * 022 */ 023 public interface ExpressionLanguage 024 { 025 /** 026 * Evaluates the given expression. 027 * @param expression the expression to evaluate 028 * @param values context values passed to the interpreter 029 * @return the result of the expression evaluation 030 * @throws ExpressionEvaluationException in case of an invalid expression 031 */ 032 Object evaluate(String expression, Map<String, ? > values) throws ExpressionEvaluationException; 033 034 /** 035 * Evaluates the given expression and expects it to return a boolean. 036 * @param expression the expression to evaluate 037 * @param values context values passed to the interpreter 038 * @return the result of the expression evaluation 039 * @throws ExpressionEvaluationException If an error during evaluation occurs or if the return value is not a boolean value. 040 */ 041 boolean evaluateAsBoolean(String expression, Map<String, ? > values) throws ExpressionEvaluationException; 042 }