//
// FormulaVar.java
//
/*
VisAD system for interactive analysis and visualization of numerical
data. Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
package visad.formula;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.*;
import visad.*;
/** Represents a variable. */
public class FormulaVar extends ActionImpl {
/** for testing purposes */
public static boolean DEBUG = false;
/** constant tag */
public static RealType CONSTANT =
RealType.getRealType("visad/formula/constant");
/** associated FormulaManager object */
private FormulaManager fm;
/** name of this variable */
String name;
/** formula associated with this variable, if any */
private String formula;
/** formula in postfix notation, if it has been converted */
private Postfix postfix;
/** reference of this variable */
private ThingReference tref;
/** list of errors that have occurred during computation, in String form */
private Vector errors = new Vector();
/** for synchronization */
private Object Lock = new Object();
/** whether the formula is currently being computed */
private boolean computing = false;
/** constructor without specified ThingReference */
FormulaVar(String n, FormulaManager f) throws VisADException {
this(n, f, null);
}
/** constructor with specified ThingReference */
FormulaVar(String n, FormulaManager f, ThingReference t)
throws VisADException
{
super(n);
fm = f;
name = n;
tref = (t == null) ? new ThingReferenceImpl(name) : t;
for (int i=0; i= 0) {
throw new FormulaException("variable names cannot contain operators");
}
}
for (int i=0; i= 0) {
throw new FormulaException("variable names cannot contain operators");
}
}
}
/** vector of variables on which this one depends */
private Vector depend = new Vector();
/** vector of variables that require this variable (depend on it) */
private Vector required = new Vector();
/** return whether any other variables depend on this one */
boolean othersDepend() {
return !required.isEmpty();
}
/** return whether this variable depends on v */
boolean isDependentOn(FormulaVar v) {
if (v == this || depend.contains(v)) return true;
for (int i=0; i 0) o = new Object[num];
else o = null;
boolean eflag = false;
for (int j=num-1; j>=0; j--) {
o[j] = popStack(stack);
if (o[j] == null) eflag = true;
}
if (!eflag) {
for (int j=0; j=0; j--) {
o[j] = popStack(stack);
if (o[j] == null) eflag = true;
}
if (!eflag) {
for (int j=0; j
Ads help maintain this website.