package causation.lab; import java.util.*; import causation.lab.WBVariable; /** * This class encodes the state attributes of the WBVariables in a * CausalityLab that are relevant to an experiment. Specifically, for * every variable, it encodes whether that variable is on the workbench, * and whether it is randomized, locked (and the value, if it is), or * not manipulated. * * @see Workbench * @see WBVariable * @version 1.0 Aug 30, 1999 * @author David Danks */ public class ExperimentalSetup { /////////////////// Static Class Variables /////////////////// public static final String RANDOMIZED = "*****RANDOMIZED*****"; public static final String NOT_ON_BENCH = "*****NOTONBENCH*****"; public static final String NO_MANIP = "*****NO MANIPULATION*****"; /////////////////// Instance Variables /////////////////// private Hashtable states; /////////////////// Constructors /////////////////// /** * Constructs an ExperimentalSetup object for the experimental setup * currently on the given Workbench. * @param wb The Workbench whose experimental setup is being encoded */ public ExperimentalSetup(Workbench wb) { WBVariable[] vars = wb.getVariables(); states = new Hashtable(); String[] onWorkbench = wb.getOnWorkbenchVariableNames(); for (int i=0; itrue, if the variable names are the same, and * the state of the variable in each ExperimentalSetup is the * same; * false, otherwise. */ public boolean isEquivalentTo(ExperimentalSetup exp) { Hashtable expSt = exp.getStates(); if (expSt.size() != states.size()) return false; Enumeration keys = states.keys(); while (keys.hasMoreElements()) { String key = (String)keys.nextElement(); String value = (String)states.get(key); String eValue = (String)expSt.get(key); if (value == null) { if (eValue != null) return false; } else if (!(value.equals(eValue))) return false; } return true; } }