Class AbstractVariableResolver

java.lang.Object
com.blackrook.rookscript.resolvers.variable.AbstractVariableResolver
All Implemented Interfaces:
ScriptVariableResolver
Direct Known Subclasses:
DefaultVariableResolver, ScriptValue.MapType

public class AbstractVariableResolver extends Object implements ScriptVariableResolver
A single, scoped open variable set in which values can be set. All variable names are CASE-INSENSITIVE. The internals are written so that the storage uses few memory allocations/deletions. None of the variables are read-only. This implementation is thread-safe.
Author:
Matthew Tropiano
  • Field Details

  • Constructor Details

    • AbstractVariableResolver

      protected AbstractVariableResolver(int capacity)
      Creates a variable resolver with a default size.
      Parameters:
      capacity - the initial capacity.
  • Method Details

    • get

      protected ScriptValue get(String name)
    • getIndex

      protected int getIndex(String name)
    • removeIndex

      protected void removeIndex(int i)
    • containsValue

      public boolean containsValue(String name)
      Description copied from interface: ScriptVariableResolver
      Checks if this contains a value by its variable name.
      Specified by:
      containsValue in interface ScriptVariableResolver
      Parameters:
      name - the variable name.
      Returns:
      true if so, false if not.
    • getValue

      public boolean getValue(String name, ScriptValue out)
      Description copied from interface: ScriptVariableResolver
      Gets the corresponding value for a variable name. Changing the returned value does not change the value, unless it is a reference type like a map or list.
      Specified by:
      getValue in interface ScriptVariableResolver
      Parameters:
      name - the variable name.
      out - the destination variable for the value.
      Returns:
      true if a corresponding value was fetched into out, false if not. If false, out is set to the null value.
    • setValue

      public void setValue(String name, ScriptValue value)
      Description copied from interface: ScriptVariableResolver
      Sets a key-value pair. This should fail if the provided name corresponds to a read-only variable.
      Specified by:
      setValue in interface ScriptVariableResolver
      Parameters:
      name - the variable name.
      value - the corresponding value.
      See Also:
    • isReadOnly

      public boolean isReadOnly(String name)
      Description copied from interface: ScriptVariableResolver
      Checks if an existing value is read-only.
      Specified by:
      isReadOnly in interface ScriptVariableResolver
      Parameters:
      name - the variable name.
      Returns:
      true if so, false if not.
    • size

      public int size()
      Specified by:
      size in interface ScriptVariableResolver
      Returns:
      the amount of values that this maintains.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ScriptVariableResolver
      Checks if this resolver maintains no values.
      Specified by:
      isEmpty in interface ScriptVariableResolver
      Returns:
      true if so, false if not.
    • toString

      public String toString()
      Overrides:
      toString in class Object