Source for org.jfree.formula.FormulaContext

   1: /**
   2:  * =========================================
   3:  * LibFormula : a free Java formula library
   4:  * =========================================
   5:  *
   6:  * Project Info:  http://reporting.pentaho.org/libformula/
   7:  *
   8:  * (C) Copyright 2006-2007, by Pentaho Corporation and Contributors.
   9:  *
  10:  * This library is free software; you can redistribute it and/or modify it under the terms
  11:  * of the GNU Lesser General Public License as published by the Free Software Foundation;
  12:  * either version 2.1 of the License, or (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  15:  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16:  * See the GNU Lesser General Public License for more details.
  17:  *
  18:  * You should have received a copy of the GNU Lesser General Public License along with this
  19:  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20:  * Boston, MA 02111-1307, USA.
  21:  *
  22:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  23:  * in the United States and other countries.]
  24:  *
  25:  *
  26:  * ------------
  27:  * $Id: FormulaContext.java 3314 2007-09-10 11:35:45Z tmorgner $
  28:  * ------------
  29:  * (C) Copyright 2006-2007, by Pentaho Corporation.
  30:  */
  31: package org.jfree.formula;
  32: 
  33: import org.jfree.formula.function.FunctionRegistry;
  34: import org.jfree.formula.operators.OperatorFactory;
  35: import org.jfree.formula.typing.Type;
  36: import org.jfree.formula.typing.TypeRegistry;
  37: import org.jfree.util.Configuration;
  38: 
  39: /**
  40:  * The formula-context connects the formula functions with the outside world. The context can be used to resolve
  41:  * external references, to query the configuration or to retrieve information about the formula-evaluation system.
  42:  *
  43:  * @author Thomas Morgner
  44:  */
  45: public interface FormulaContext
  46: {
  47:   /**
  48:    * Checks, whether the external object referenced by <code>name</code> has changed.
  49:    *
  50:    * @param name the name that identifies the reference.
  51:    * @return true, if the reference has changed, false otherwise.
  52:    * @throws ContextEvaluationException if an error occurs.
  53:    */
  54:   public boolean isReferenceDirty(Object name) throws ContextEvaluationException;
  55: 
  56:   /**
  57:    * Resolves the given reference. How the name is interpreted by the outside system is an implementation detail.
  58:    *
  59:    * @param name the name that identifies the reference.
  60:    * @return the resolved object.
  61:    * @throws ContextEvaluationException if an error occurs.
  62:    */
  63:   public Object resolveReference(Object name) throws ContextEvaluationException;
  64: 
  65:   /**
  66:    * Queries the type of the given reference. How the name is interpreted by the outside system is an implementation
  67:    * detail. This return a LibFormula type object matching the type of the object that would be returned by
  68:    * resolveReference.
  69:    *
  70:    * @param name the name that identifies the reference.
  71:    * @return the type of the resolved object.
  72:    * @throws ContextEvaluationException if an error occurs.
  73:    */
  74:   public Type resolveReferenceType(Object name) throws ContextEvaluationException;
  75: 
  76:   /**
  77:    * Returns the localization context of this formula. The localization context can be used to query locale specific
  78:    * configuration settings.
  79:    *
  80:    * @return the localization context.
  81:    */
  82:   public LocalizationContext getLocalizationContext();
  83: 
  84:   /**
  85:    * Returns the local configuration of the formula.
  86:    *
  87:    * @return the local configuration.
  88:    */
  89:   public Configuration getConfiguration();
  90: 
  91:   /**
  92:    * Returns the function registry. The function registry grants access to all formula-function implementations.
  93:    *
  94:    * @return the function registry.
  95:    */
  96:   public FunctionRegistry getFunctionRegistry();
  97: 
  98:   /**
  99:    * 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: }