Class VariableTableObserver

  • All Implemented Interfaces:
    java.util.Observer

    public class VariableTableObserver
    extends java.lang.Object
    implements java.util.Observer
    Base class for observing Variables and the VariableTable. The methods variableValueChanged(), variableAdded(), variableRemoved(), tableCleared() will be called when these events occur. These methods can be overridden to provide appropriate behaviour, the default action is just to print the a message.

    Results are unpredictable if two variable tables are observed using the same object.

    From 3.5 whether variable values are watched can be set

    See Also:
    ObservingTest
    • Constructor Detail

      • VariableTableObserver

        public VariableTableObserver​(VariableTable vt)
        Constructor watching a specified table. Will watch changes in variables.
        Parameters:
        vt -
      • VariableTableObserver

        public VariableTableObserver​(Jep jep)
        Constructor watching the table of the Jep instance
        Parameters:
        jep - Jep instance
      • VariableTableObserver

        public VariableTableObserver​(VariableTable vt,
                                     boolean watchValues)
        Constructor specifying if values should be watched.
        Parameters:
        vt - Table to watch
        watchValues - whether values should be watched
      • VariableTableObserver

        public VariableTableObserver​(Jep jep,
                                     boolean watchValues)
        Constructor which allows the watching of individual variable values to be switchable
        Parameters:
        jep -
        watchValues - whether to watch the change in variable values, setting to false will be a little quicker
    • Method Detail

      • addObserver

        public void addObserver​(java.util.Observable obs)
      • deleteObserver

        public void deleteObserver​(java.util.Observable obs)
      • deleteObservers

        public void deleteObservers()
        Stop observing all variables.
      • update

        public void update​(java.util.Observable o,
                           java.lang.Object arg)
        Called when the Observable.notifyObservers() method is called. This methods calls the variableAdded(), variableValueChanged() etc. methods and maintains the list of variables it is observing.
        Specified by:
        update in interface java.util.Observer
      • variableChanged

        protected void variableChanged​(Variable var)
        Called when a variable value has changed. Intended to be overridden by subclasses.
        Parameters:
        var - the variable which has changed.
      • variableAdded

        protected void variableAdded​(Variable var)
        Called when a variable is added to the table. Intended to be overridden by subclasses.
        Parameters:
        var - the variable which has been added.
      • variableRemoved

        protected void variableRemoved​(Variable var)
        Called when a variable is removed from the table. Intended to be overridden by subclasses.
        Parameters:
        var - the variable which has been removed.
      • tableCleared

        protected void tableCleared​(VariableTable table)
        Called when the variable table has been cleared. Intended to be overridden by subclasses.
        Parameters:
        table - table which has been cleared
      • iterator

        public java.util.Iterator<java.util.Observable> iterator()
        Returns a list of items this class is observing.
        Returns:
        an iterator for the list.
      • isWatchingValues

        public boolean isWatchingValues()
        Whether changes in variable values are watched
        Returns:
        true if changes to variable values are watched
        Since:
        3.5