Class VariableCollection

java.lang.Object
org.pipservices3.expressions.calculator.variables.VariableCollection
All Implemented Interfaces:
IVariableCollection

public class VariableCollection extends Object implements IVariableCollection
Implements a variables list.
  • Constructor Details

    • VariableCollection

      public VariableCollection()
  • Method Details

    • add

      public void add(IVariable variable)
      Adds a new variable to the collection.
      Specified by:
      add in interface IVariableCollection
      Parameters:
      variable - a variable to be added.
    • length

      public int length()
      Gets a number of variables stored in the collection.
      Specified by:
      length in interface IVariableCollection
      Returns:
      a number of stored variables.
    • get

      public IVariable get(int index)
      Get a variable by its index.
      Specified by:
      get in interface IVariableCollection
      Parameters:
      index - a variable index.
      Returns:
      a retrieved variable.
    • getAll

      public List<IVariable> getAll()
      Get all variables stores in the collection
      Specified by:
      getAll in interface IVariableCollection
      Returns:
      a list with variables.
    • findIndexByName

      public int findIndexByName(String name)
      Finds variable index in the list by it's name.
      Specified by:
      findIndexByName in interface IVariableCollection
      Parameters:
      name - The variable name to be found.
      Returns:
      Variable index in the list or -1 if variable was not found.
    • findByName

      public IVariable findByName(String name)
      Finds variable in the list by it's name.
      Specified by:
      findByName in interface IVariableCollection
      Parameters:
      name - The variable name to be found.
      Returns:
      A variable or null if function was not found.
    • locate

      public IVariable locate(String name)
      Finds variable in the list or create a new one if variable was not found.
      Specified by:
      locate in interface IVariableCollection
      Parameters:
      name - The variable name to be found.
      Returns:
      Found or created variable.
    • remove

      public void remove(int index)
      Removes a variable by its index.
      Specified by:
      remove in interface IVariableCollection
      Parameters:
      index - a index of the variable to be removed.
    • removeByName

      public void removeByName(String name)
      Removes variable by it's name.
      Specified by:
      removeByName in interface IVariableCollection
      Parameters:
      name - The variable name to be removed.
    • clear

      public void clear()
      Clears the collection.
      Specified by:
      clear in interface IVariableCollection
    • clearValues

      public void clearValues()
      Clears all stored variables (assigns null values).
      Specified by:
      clearValues in interface IVariableCollection