Class AbstractVariable

java.lang.Object
edu.cmu.tetrad.data.AbstractVariable
All Implemented Interfaces:
Variable, Node, TetradSerializable, Serializable, Comparable<Node>
Direct Known Subclasses:
ContinuousVariable, DiscreteVariable

public abstract class AbstractVariable extends Object implements Variable
Base class for variable specifications for DataSet. These objects govern the types of values which may be recorded in a Column of data and provide information about the interpretation of these values. Variables of every type must provide a marker which is recorded in a column of data for that variable when the value is missing; this missing data marker should not be used for other purposes.
Author:
Willie Wheeler 7/99, josephramsey modifications 12/00
See Also:
  • Field Details

    • LAST_ID

      public static int LAST_ID
      The last ID assigned to a variable.
  • Method Details

    • getMissingValueMarker

      public abstract Object getMissingValueMarker()
      Description copied from interface: Variable
      Returns the name of the variable.
      Specified by:
      getMissingValueMarker in interface Variable
      Returns:
      the missing value marker as an Object.
    • isMissingValue

      public abstract boolean isMissingValue(Object value)
      Tests whether the given value is the missing data marker.
      Specified by:
      isMissingValue in interface Variable
      Parameters:
      value - The object value one wants to check as a missing value.
      Returns:
      true iff the given object is equals to getMissingValueMarker().
    • getName

      public final String getName()
      Description copied from interface: Node
      Returns the name of this node.
      Specified by:
      getName in interface Node
      Returns:
      the name of this variable.
    • setName

      public final void setName(String name)
      Sets the name of this variable.
      Specified by:
      setName in interface Node
      Parameters:
      name - the name of this node.
    • checkValue

      public boolean checkValue(Object value)
      Checks to see whether the passed value is an acceptable value for this variable. For AbstractVariable, this method always returns true. Subclasses should override checkValue() in order to provide for subclass-specific value checking. The value should pass the test if it can be converted into an equivalent object of the correct class type (see getValueClass()) for this variable; otherwise, it should fail. In general, checkValue() should not fail a value for simply not being an instance of a particular class. Since this method is not static, subclasses may (but need not) provide for instance-specific value checking.
      Specified by:
      checkValue in interface Variable
      Parameters:
      value - a value
      Returns:
      true if the value is an acceptable value for this variable, and false otherwise
    • toString

      public String toString()
      Description copied from interface: Node
      Returns the intervention type for this node.
      Specified by:
      toString in interface Node
      Overrides:
      toString in class Object
      Returns:
      a String representation of this variable. Specifically, the name of the variable is returned.
    • like

      public abstract Node like(String name)
      Description copied from interface: Node
      Creates a new node of the same type as this one with the given name.
      Specified by:
      like in interface Node
      Parameters:
      name - the name of the new node.
      Returns:
      the new node.