Class ScriptableWrappedMap

java.lang.Object
org.springframework.extensions.webscripts.ScriptableWrappedMap
All Implemented Interfaces:
Map, org.mozilla.javascript.Scriptable, org.mozilla.javascript.Wrapper, ScriptableMap

public class ScriptableWrappedMap extends Object implements ScriptableMap, org.mozilla.javascript.Wrapper
Implementation of a Scriptable Map. This is the best choice where you want values to be persisted directly to an underlying map supplied on construction. The class automatically wraps/unwraps JS objects as they enter/leave the underlying map via the Scriptable interface methods - objects are untouched if accessed via the usual Map interface methods. Access should be by string key only - not integer index - unless you are sure the wrapped map will maintain insertion order of the elements.
Author:
Kevin Roast
  • Constructor Details

    • ScriptableWrappedMap

      public ScriptableWrappedMap(Map map)
      Construct
      Parameters:
      map - Map
    • ScriptableWrappedMap

      public ScriptableWrappedMap(org.mozilla.javascript.Scriptable scope, Map map)
      Construct
      Parameters:
      scope - Scriptable
      map - Map
  • Method Details

    • wrap

      public static ScriptableWrappedMap wrap(org.mozilla.javascript.Scriptable scope, Map<Object,Object> map)
      Construction
      Parameters:
      scope - Scriptable
      map - Map<Object, Object>
      Returns:
      scriptable wrapped map
    • unwrap

      public Object unwrap()
      Specified by:
      unwrap in interface org.mozilla.javascript.Wrapper
    • getClassName

      public String getClassName()
      Specified by:
      getClassName in interface org.mozilla.javascript.Scriptable
    • get

      public Object get(String name, org.mozilla.javascript.Scriptable start)
      Specified by:
      get in interface org.mozilla.javascript.Scriptable
    • get

      public Object get(int index, org.mozilla.javascript.Scriptable start)
      Specified by:
      get in interface org.mozilla.javascript.Scriptable
    • has

      public boolean has(String name, org.mozilla.javascript.Scriptable start)
      Specified by:
      has in interface org.mozilla.javascript.Scriptable
    • has

      public boolean has(int index, org.mozilla.javascript.Scriptable start)
      Specified by:
      has in interface org.mozilla.javascript.Scriptable
    • put

      public void put(String name, org.mozilla.javascript.Scriptable start, Object value)
      Specified by:
      put in interface org.mozilla.javascript.Scriptable
    • put

      public void put(int index, org.mozilla.javascript.Scriptable start, Object value)
      Specified by:
      put in interface org.mozilla.javascript.Scriptable
    • delete

      public void delete(String name)
      Specified by:
      delete in interface org.mozilla.javascript.Scriptable
    • delete

      public void delete(int index)
      Specified by:
      delete in interface org.mozilla.javascript.Scriptable
    • getPrototype

      public org.mozilla.javascript.Scriptable getPrototype()
      Specified by:
      getPrototype in interface org.mozilla.javascript.Scriptable
    • setPrototype

      public void setPrototype(org.mozilla.javascript.Scriptable prototype)
      Specified by:
      setPrototype in interface org.mozilla.javascript.Scriptable
    • getParentScope

      public org.mozilla.javascript.Scriptable getParentScope()
      Specified by:
      getParentScope in interface org.mozilla.javascript.Scriptable
    • setParentScope

      public void setParentScope(org.mozilla.javascript.Scriptable parent)
      Specified by:
      setParentScope in interface org.mozilla.javascript.Scriptable
    • getIds

      public Object[] getIds()
      Specified by:
      getIds in interface org.mozilla.javascript.Scriptable
    • getDefaultValue

      public Object getDefaultValue(Class hint)
      Specified by:
      getDefaultValue in interface org.mozilla.javascript.Scriptable
    • hasInstance

      public boolean hasInstance(org.mozilla.javascript.Scriptable value)
      Specified by:
      hasInstance in interface org.mozilla.javascript.Scriptable
    • clear

      public void clear()
      Specified by:
      clear in interface Map
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map
    • entrySet

      public Set entrySet()
      Specified by:
      entrySet in interface Map
    • get

      public Object get(Object key)
      Specified by:
      get in interface Map
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map
    • keySet

      public Set keySet()
      Specified by:
      keySet in interface Map
    • put

      public Object put(Object key, Object value)
      Specified by:
      put in interface Map
    • putAll

      public void putAll(Map t)
      Specified by:
      putAll in interface Map
    • remove

      public Object remove(Object key)
      Specified by:
      remove in interface Map
    • size

      public int size()
      Specified by:
      size in interface Map
    • values

      public Collection values()
      Specified by:
      values in interface Map
    • toString

      public String toString()
      Overrides:
      toString in class Object