Class Scope

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

public class Scope
extends java.lang.Object
implements java.util.Map<java.lang.String,​java.lang.Object>, javax.script.Bindings, java.io.Serializable
See Also:
Serialized Form
  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.Map

    java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int flattenCounter  
    protected java.util.Map<java.lang.String,​java.lang.Object> map  
    protected Scope outer  
  • Constructor Summary

    Constructors 
    Constructor Description
    Scope()  
    Scope​(java.util.Map map)  
    Scope​(java.util.Map map, Scope outer)  
    Scope​(Scope outer)  
  • Method Summary

    Modifier and Type Method Description
    void clear()
    clear
    boolean containsKey​(java.lang.Object key)
    containsKey
    boolean containsValue​(java.lang.Object value)
    containsValue
    java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.Object>> entrySet()
    entrySet
    boolean equals​(java.lang.Object o)
    equals
    java.util.Map<java.lang.String,​java.lang.Object> flatten()  
    protected java.util.Map<java.lang.String,​java.lang.Object> flatten2()  
    java.lang.Object get​(java.lang.Object key)  
    java.util.Map<java.lang.String,​java.lang.Object> getMap()  
    java.lang.String getName()  
    Scope getOuter()  
    java.lang.Object getUnwrapped​(java.lang.Object key)
    For best BeanShell experience we wrap and unwrap possibly primitive data types
    int hashCode()
    Returns the hash code value for this map.
    boolean isEmpty()
    isEmpty
    java.util.Set<java.lang.String> keySet()
    keySet
    Scope name​(java.lang.String name)
    Provide a way to name this scope for debugging purposes
    Scope push​(java.util.Map map)
    Make a new scope where the passed Map is put before (inner) the existing scope This scope is left untouched.
    java.lang.Object put​(java.lang.String key, java.lang.Object value)  
    void putAll​(java.util.Map more)  
    java.lang.Object putNotNull​(java.lang.String key, java.lang.Object value)  
    java.lang.Object remove​(java.lang.Object key)  
    Scope remove​(java.util.Map map)
    Remove map from this scope or any outer scope Return this scope or outer scope if map == this scope
    void setOuter​(Scope outer)  
    int size()
    DOCUMENT ME!
    java.lang.String toString()
    Display Scope hierarchy from this Scope to the root.
    java.util.Collection values()
    values

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Map

    compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
  • Field Details

    • outer

      protected Scope outer
    • map

      protected java.util.Map<java.lang.String,​java.lang.Object> map
    • flattenCounter

      public static int flattenCounter
  • Constructor Details

    • Scope

      public Scope()
    • Scope

      public Scope​(Scope outer)
    • Scope

      public Scope​(java.util.Map map)
    • Scope

      public Scope​(java.util.Map map, Scope outer)
  • Method Details

    • getName

      public java.lang.String getName()
    • name

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

      public java.lang.Object get​(java.lang.Object key)
      Specified by:
      get in interface javax.script.Bindings
      Specified by:
      get in interface java.util.Map<java.lang.String,​java.lang.Object>
    • getUnwrapped

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

      public java.lang.Object put​(java.lang.String key, java.lang.Object value)
      Specified by:
      put in interface javax.script.Bindings
      Specified by:
      put in interface java.util.Map<java.lang.String,​java.lang.Object>
    • putNotNull

      public java.lang.Object putNotNull​(java.lang.String key, java.lang.Object value)
    • putAll

      public void putAll​(java.util.Map more)
      Specified by:
      putAll in interface javax.script.Bindings
      Specified by:
      putAll in interface java.util.Map<java.lang.String,​java.lang.Object>
    • remove

      public java.lang.Object remove​(java.lang.Object key)
      Specified by:
      remove in interface javax.script.Bindings
      Specified by:
      remove in interface java.util.Map<java.lang.String,​java.lang.Object>
    • getOuter

      public Scope getOuter()
    • setOuter

      public void setOuter​(Scope outer)
    • getMap

      public java.util.Map<java.lang.String,​java.lang.Object> getMap()
    • flatten2

      protected java.util.Map<java.lang.String,​java.lang.Object> flatten2()
    • flatten

      public java.util.Map<java.lang.String,​java.lang.Object> flatten()
    • push

      public Scope push​(java.util.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​(java.util.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 java.util.Map<java.lang.String,​java.lang.Object>
      Returns:
      size of this scope + any outer scope(s)
    • isEmpty

      public boolean isEmpty()
      isEmpty
      Specified by:
      isEmpty in interface java.util.Map<java.lang.String,​java.lang.Object>
      Returns:
      boolean
    • containsKey

      public boolean containsKey​(java.lang.Object key)
      containsKey
      Specified by:
      containsKey in interface javax.script.Bindings
      Specified by:
      containsKey in interface java.util.Map<java.lang.String,​java.lang.Object>
      Parameters:
      key - Object
      Returns:
      boolean
    • containsValue

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

      public void clear()
      clear
      Specified by:
      clear in interface java.util.Map<java.lang.String,​java.lang.Object>
    • keySet

      public java.util.Set<java.lang.String> keySet()
      keySet
      Specified by:
      keySet in interface java.util.Map<java.lang.String,​java.lang.Object>
      Returns:
      Set
    • values

      public java.util.Collection values()
      values
      Specified by:
      values in interface java.util.Map<java.lang.String,​java.lang.Object>
      Returns:
      Collection
    • entrySet

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

      public boolean equals​(java.lang.Object o)
      equals
      Specified by:
      equals in interface java.util.Map<java.lang.String,​java.lang.Object>
      Overrides:
      equals in class java.lang.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 java.util.Map<java.lang.String,​java.lang.Object>
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      the hash code value for this map.
      See Also:
      Map.Entry.hashCode(), Object.hashCode(), Object.equals(Object), Set.equals(Object)
    • toString

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