All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.aviator.Expression Maven / Gradle / Ivy

/**
 * Copyright (C) 2010 dennis zhuang ([email protected])
 *
 * This library is free software; you can redistribute it and/or modify it under the terms of the
 * GNU Lesser General Public License as published by the Free Software Foundation; either version
 * 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 **/
package com.googlecode.aviator;

import java.util.List;
import java.util.Map;


/**
 * A expression
 *
 * @author dennis
 *
 */
public interface Expression {

  /**
   * Execute expression with environment
   *
   * @param env Binding variable environment
   * @return
   */
  Object execute(Map env);


  /**
   * Execute expression with empty environment
   *
   * @return
   */
  Object execute();

  /**
   * Returns the source file name.
   *
   * @since 5.2.3
   * @return the source file name
   */
  public String getSourceFile();


  /**
   * Returns this expression's all uninitialized global variable names in order when using
   * AviatorEvaluator.EVAL mode,else returns empty set
   *
   * @see com.googlecode.aviator.AviatorEvaluator#EVAL
   * @return
   */
  List getVariableNames();


  /**
   * Returns this expression's all uninitialized global variable full names(contains dot) in order
   * when using AviatorEvaluator.EVAL mode,else returns empty set
   *
   * @return
   */
  List getVariableFullNames();

  /**
   * Created a faster env map(compare variable names by reference).The arguments should be a
   * sequence of pair .
   *
   * @param args
   * @return an env map
   */
  Map newEnv(final Object... args);

  /**
   * Adds the specified symbol to the symbol table and returns a reference to the unique symbol. If
   * the symbol already exists, the previous symbol reference is returned instead, in order
   * guarantee that symbol references remain unique.
   *
   * @param name The symbol name.
   */
  String addSymbol(String name);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy