Class Scope

java.lang.Object
se.datadosen.util.Scope
All Implemented Interfaces:
Serializable, Map<String,Object>, Bindings

public class Scope extends Object implements Map<String,Object>, Bindings, Serializable
See Also:
  • Field Details

    • outer

      protected Scope outer
    • map

      protected Map<String,Object> map
    • flattenCounter

      public static int flattenCounter
  • Constructor Details

    • Scope

      public Scope()
    • Scope

      public Scope(Scope outer)
    • Scope

      public Scope(Map map)
    • Scope

      public Scope(Map map, Scope outer)
  • Method Details

    • getName

      public String getName()
    • name

      public Scope name(String name)
      Provide a way to name this scope for debugging purposes
      Parameters:
      name -
      Returns:
    • get

      public Object get(Object key)
      Specified by:
      get in interface Bindings
      Specified by:
      get in interface Map<String,Object>
    • getUnwrapped

      public Object getUnwrapped(Object key)
      For best BeanShell experience we wrap and unwrap possibly primitive data types
      Parameters:
      key -
      Returns:
    • put

      public Object put(String key, Object value)
      Specified by:
      put in interface Bindings
      Specified by:
      put in interface Map<String,Object>
    • putNotNull

      public Object putNotNull(String key, Object value)
    • putAll

      public void putAll(Map more)
      Specified by:
      putAll in interface Bindings
      Specified by:
      putAll in interface Map<String,Object>
    • remove

      public Object remove(Object key)
      Specified by:
      remove in interface Bindings
      Specified by:
      remove in interface Map<String,Object>
    • getOuter

      public Scope getOuter()
    • setOuter

      public void setOuter(Scope outer)
    • getMap

      public Map<String,Object> getMap()
    • flatten2

      protected Map<String,Object> flatten2()
    • flatten

      public Map<String,Object> flatten()
    • push

      public Scope push(Map map)
      Make a new scope where the passed Map is put before (inner) the existing scope This scope is left untouched.
      Parameters:
      map - Map to be added to the inner scope. If null, the existing scope will be used.
      Returns:
    • remove

      public Scope remove(Map map)
      Remove map from this scope or any outer scope Return this scope or outer scope if map == this scope
      Parameters:
      map -
      Returns:
    • size

      public int size()
      DOCUMENT ME!
      Specified by:
      size in interface Map<String,Object>
      Returns:
      size of this scope + any outer scope(s)
    • isEmpty

      public boolean isEmpty()
      isEmpty
      Specified by:
      isEmpty in interface Map<String,Object>
      Returns:
      boolean
    • containsKey

      public boolean containsKey(Object key)
      containsKey
      Specified by:
      containsKey in interface Bindings
      Specified by:
      containsKey in interface Map<String,Object>
      Parameters:
      key - Object
      Returns:
      boolean
    • containsValue

      public boolean containsValue(Object value)
      containsValue
      Specified by:
      containsValue in interface Map<String,Object>
      Parameters:
      value - Object
      Returns:
      boolean
    • clear

      public void clear()
      clear
      Specified by:
      clear in interface Map<String,Object>
    • keySet

      public Set<String> keySet()
      keySet
      Specified by:
      keySet in interface Map<String,Object>
      Returns:
      Set
    • values

      public Collection values()
      values
      Specified by:
      values in interface Map<String,Object>
      Returns:
      Collection
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      entrySet
      Specified by:
      entrySet in interface Map<String,Object>
      Returns:
      Set
    • equals

      public boolean equals(Object o)
      equals
      Specified by:
      equals in interface Map<String,Object>
      Overrides:
      equals in class Object
      Parameters:
      o - Object
      Returns:
      boolean
    • hashCode

      public int hashCode()
      Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hash codes of each entry in the map's entrySet() view. This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two maps t1 and t2, as required by the general contract of Object.hashCode.

      This implementation iterates over entrySet(), calling hashCode on each element (entry) in the Collection, and adding up the results.

      Specified by:
      hashCode in interface Map<String,Object>
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this map.
      See Also:
    • toString

      public String toString()
      Display Scope hierarchy from this Scope to the root. Format: [Name @ identity: size] -> [Name @ identity: size] ...
      Overrides:
      toString in class Object
      Returns: