Class DecoratingVariableTable

java.lang.Object
com.singularsys.jep.VariableTable
com.singularsys.jep.misc.DecoratingVariableTable
All Implemented Interfaces:
JepComponent, Serializable
Direct Known Subclasses:
CaseInsensitiveVariableTable, PublishingVariableTable

public class DecoratingVariableTable extends VariableTable
A VariableTable that can optionally decorate another variable table. This class is only intended to be used by subclasses that require the ability to decorate table request. If the base table is set all methods delegate to that, otherwise super class methods in VariableTable are called.
See Also:
  • Constructor Details

    • DecoratingVariableTable

      protected DecoratingVariableTable()
      Non decorating constructor.
    • DecoratingVariableTable

      protected DecoratingVariableTable(VariableTable tbl)
      Non decorating copy constructor
      Parameters:
      tbl - table to copy variables from
    • DecoratingVariableTable

      protected DecoratingVariableTable(VariableTable tbl, boolean flag)
      Decorator constructor
      Parameters:
      tbl - table to decorate
      flag - unused
  • Method Details

    • addVariable

      public Variable addVariable(String name)
      Adds a new variable with no value specified.
      Overrides:
      addVariable in class VariableTable
      Parameters:
      name - variable name, will be converted to lower case
      Returns:
      the variable
    • addVariable

      public Variable addVariable(String name, Object value) throws JepException
      Adds a new variable with specified value.
      Overrides:
      addVariable in class VariableTable
      Parameters:
      name - variable name, will be converted to lower case
      value - initial value
      Returns:
      the variable
      Throws:
      JepException - if an attempt is made to set the value of a constant variable
    • addConstant

      public Variable addConstant(String name, Object value) throws JepException
      Description copied from class: VariableTable
      Adds a new variable which is marked as a constant. Its value will also be marked as valid, in particular a null value is valid for a constant.
      Overrides:
      addConstant in class VariableTable
      Parameters:
      name - variable name
      value - variable value
      Returns:
      the corresponding Variable object
      Throws:
      JepException - if an attempt is made to set the value of an existing constant variable
    • getVariable

      public Variable getVariable(String name)
      Gets an existing variable, returns null if variable is not found.
      Overrides:
      getVariable in class VariableTable
      Parameters:
      name - variable name, will be converted to lower case
      Returns:
      the variable
    • remove

      public Variable remove(String name)
      Description copied from class: VariableTable
      Remove a variable with a given name from the table.
      Overrides:
      remove in class VariableTable
      Parameters:
      name - name of the variable to remove
      Returns:
      the removed variable or null if the variable does not exist in the table.
    • clear

      public void clear()
      Description copied from class: VariableTable
      Clears all variables from the table.
      Overrides:
      clear in class VariableTable
    • isEmpty

      public boolean isEmpty()
      Description copied from class: VariableTable
      Returns true if the table is empty.
      Overrides:
      isEmpty in class VariableTable
      Returns:
      true if the table is empty
    • getVariables

      public Collection<Variable> getVariables()
      Description copied from class: VariableTable
      Returns a list of all the variables in the table. Just returns a view. Does not do a deep copy so changes to this collection will affect the underlying table.
      Overrides:
      getVariables in class VariableTable
      Returns:
      a collection of all the variables.
    • remove

      public Variable remove(Variable var)
      Description copied from class: VariableTable
      Remove a variable from the table.
      Overrides:
      remove in class VariableTable
      Parameters:
      var - the variable to remove
      Returns:
      the removed variable or null if the variable does not exist in the table.
    • containsKey

      public boolean containsKey(String key)
      Description copied from class: VariableTable
      Returns true if the table contains a variable with the given name.
      Overrides:
      containsKey in class VariableTable
      Parameters:
      key - variable name
      Returns:
      true if the table contains the variable
    • containsVariable

      public boolean containsVariable(Variable vbl)
      Description copied from class: VariableTable
      Returns true if the table contains the given variable.
      Overrides:
      containsVariable in class VariableTable
      Parameters:
      vbl - the variable
      Returns:
      true if the variable is in the table
    • removeNonConstants

      public void removeNonConstants()
      Description copied from class: VariableTable
      Remove all variables from the table which are not constants.
      Overrides:
      removeNonConstants in class VariableTable
    • setVariableFactory

      public void setVariableFactory(VariableFactory vf)
      Overrides:
      setVariableFactory in class VariableTable
    • getVariableFactory

      public VariableFactory getVariableFactory()
      Overrides:
      getVariableFactory in class VariableTable
    • keySet

      public Set<String> keySet()
      Description copied from class: VariableTable
      Returns the names of all the variables.
      Overrides:
      keySet in class VariableTable
      Returns:
      a collection Strings with the variable names.
    • values

      public Collection<Variable> values()
      Description copied from class: VariableTable
      A collection of all the variables. Replace with VariableTable.getVariables()
      Overrides:
      values in class VariableTable
      Returns:
      a collection of all the variables.
    • size

      public int size()
      Description copied from class: VariableTable
      The number of variables in the table.
      Overrides:
      size in class VariableTable
      Returns:
      the number of variables
    • toString

      public String toString()
      Overrides:
      toString in class VariableTable
    • copyConstantsFrom

      public void copyConstantsFrom(VariableTable vt)
      Description copied from class: VariableTable
      Copies all the constants from a variable table into this table. Copies all properties of the variable, including isConstant, validValue flags and all hook keys. If there already is a variable with the same name all properties are copied and pre-existing hooks deleted.
      Overrides:
      copyConstantsFrom in class VariableTable
      Parameters:
      vt - source variable table
    • copyVariablesFrom

      public void copyVariablesFrom(VariableTable vt)
      Description copied from class: VariableTable
      Copies all the variables from a variable table into this table Copies all properties of the variable, including isConstant, validValue flags and all hook keys. If there already is a variable with the same name all properties are copied and pre-existing hooks deleted.
      Overrides:
      copyVariablesFrom in class VariableTable
      Parameters:
      vt - source variable table
    • clearValues

      public void clearValues()
      Description copied from class: VariableTable
      Clears the values of all non-constant variables. This will set the Variable.setValidValue(boolean) to false.
      Overrides:
      clearValues in class VariableTable
    • getBase

      public VariableTable getBase()
      Get the base VariableTable
      Returns:
      either the base table or null
    • getLightWeightInstance

      public JepComponent getLightWeightInstance()
      Description copied from class: VariableTable
      Returns a new empty VariableTable.
      Specified by:
      getLightWeightInstance in interface JepComponent
      Overrides:
      getLightWeightInstance in class VariableTable
      Returns:
      a new VariableTable
      See Also:
    • init

      public void init(Jep j)
      Description copied from interface: JepComponent
      Initialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.
      Specified by:
      init in interface JepComponent
      Overrides:
      init in class VariableTable
      Parameters:
      j - the current Jep instance