001 /** 002 * ========================================= 003 * LibFormula : a free Java formula library 004 * ========================================= 005 * 006 * Project Info: http://reporting.pentaho.org/libformula/ 007 * 008 * (C) Copyright 2006-2007, by Pentaho Corporation and Contributors. 009 * 010 * This library is free software; you can redistribute it and/or modify it under the terms 011 * of the GNU Lesser General Public License as published by the Free Software Foundation; 012 * either version 2.1 of the License, or (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 015 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 016 * See the GNU Lesser General Public License for more details. 017 * 018 * You should have received a copy of the GNU Lesser General Public License along with this 019 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 020 * Boston, MA 02111-1307, USA. 021 * 022 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 023 * in the United States and other countries.] 024 * 025 * 026 * ------------ 027 * $Id: FormulaContext.java 3314 2007-09-10 11:35:45Z tmorgner $ 028 * ------------ 029 * (C) Copyright 2006-2007, by Pentaho Corporation. 030 */ 031 package org.jfree.formula; 032 033 import org.jfree.formula.function.FunctionRegistry; 034 import org.jfree.formula.operators.OperatorFactory; 035 import org.jfree.formula.typing.Type; 036 import org.jfree.formula.typing.TypeRegistry; 037 import org.jfree.util.Configuration; 038 039 /** 040 * The formula-context connects the formula functions with the outside world. The context can be used to resolve 041 * external references, to query the configuration or to retrieve information about the formula-evaluation system. 042 * 043 * @author Thomas Morgner 044 */ 045 public interface FormulaContext 046 { 047 /** 048 * Checks, whether the external object referenced by <code>name</code> has changed. 049 * 050 * @param name the name that identifies the reference. 051 * @return true, if the reference has changed, false otherwise. 052 * @throws ContextEvaluationException if an error occurs. 053 */ 054 public boolean isReferenceDirty(Object name) throws ContextEvaluationException; 055 056 /** 057 * Resolves the given reference. How the name is interpreted by the outside system is an implementation detail. 058 * 059 * @param name the name that identifies the reference. 060 * @return the resolved object. 061 * @throws ContextEvaluationException if an error occurs. 062 */ 063 public Object resolveReference(Object name) throws ContextEvaluationException; 064 065 /** 066 * Queries the type of the given reference. How the name is interpreted by the outside system is an implementation 067 * detail. This return a LibFormula type object matching the type of the object that would be returned by 068 * resolveReference. 069 * 070 * @param name the name that identifies the reference. 071 * @return the type of the resolved object. 072 * @throws ContextEvaluationException if an error occurs. 073 */ 074 public Type resolveReferenceType(Object name) throws ContextEvaluationException; 075 076 /** 077 * Returns the localization context of this formula. The localization context can be used to query locale specific 078 * configuration settings. 079 * 080 * @return the localization context. 081 */ 082 public LocalizationContext getLocalizationContext(); 083 084 /** 085 * Returns the local configuration of the formula. 086 * 087 * @return the local configuration. 088 */ 089 public Configuration getConfiguration(); 090 091 /** 092 * Returns the function registry. The function registry grants access to all formula-function implementations. 093 * 094 * @return the function registry. 095 */ 096 public FunctionRegistry getFunctionRegistry(); 097 098 /** 099 * Returns the type registry. The type registry contains all type information and allows to convert values between 100 * different types. 101 * 102 * @return the function registry. 103 */ 104 public TypeRegistry getTypeRegistry(); 105 106 /** 107 * Returns the operator registry. The Operator-registry contains all operator-implementations. 108 * 109 * @return the operator registry. 110 */ 111 public OperatorFactory getOperatorFactory(); 112 }