Class ScriptableWrappedMap

  • All Implemented Interfaces:
    java.util.Map, org.mozilla.javascript.Scriptable, org.mozilla.javascript.Wrapper, ScriptableMap

    public class ScriptableWrappedMap
    extends java.lang.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
    • 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 inherited from interface org.mozilla.javascript.Scriptable

        NOT_FOUND
    • Constructor Summary

      Constructors 
      Constructor Description
      ScriptableWrappedMap​(java.util.Map map)
      Construct
      ScriptableWrappedMap​(org.mozilla.javascript.Scriptable scope, java.util.Map map)
      Construct
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object value)  
      void delete​(int index)  
      void delete​(java.lang.String name)  
      java.util.Set entrySet()  
      java.lang.Object get​(int index, org.mozilla.javascript.Scriptable start)  
      java.lang.Object get​(java.lang.Object key)  
      java.lang.Object get​(java.lang.String name, org.mozilla.javascript.Scriptable start)  
      java.lang.String getClassName()  
      java.lang.Object getDefaultValue​(java.lang.Class hint)  
      java.lang.Object[] getIds()  
      org.mozilla.javascript.Scriptable getParentScope()  
      org.mozilla.javascript.Scriptable getPrototype()  
      boolean has​(int index, org.mozilla.javascript.Scriptable start)  
      boolean has​(java.lang.String name, org.mozilla.javascript.Scriptable start)  
      boolean hasInstance​(org.mozilla.javascript.Scriptable value)  
      boolean isEmpty()  
      java.util.Set keySet()  
      void put​(int index, org.mozilla.javascript.Scriptable start, java.lang.Object value)  
      java.lang.Object put​(java.lang.Object key, java.lang.Object value)  
      void put​(java.lang.String name, org.mozilla.javascript.Scriptable start, java.lang.Object value)  
      void putAll​(java.util.Map t)  
      java.lang.Object remove​(java.lang.Object key)  
      void setParentScope​(org.mozilla.javascript.Scriptable parent)  
      void setPrototype​(org.mozilla.javascript.Scriptable prototype)  
      int size()  
      java.lang.String toString()  
      java.lang.Object unwrap()  
      java.util.Collection values()  
      static ScriptableWrappedMap wrap​(org.mozilla.javascript.Scriptable scope, java.util.Map<java.lang.Object,​java.lang.Object> map)
      Construction
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • ScriptableWrappedMap

        public ScriptableWrappedMap​(java.util.Map map)
        Construct
        Parameters:
        map - Map
      • ScriptableWrappedMap

        public ScriptableWrappedMap​(org.mozilla.javascript.Scriptable scope,
                                    java.util.Map map)
        Construct
        Parameters:
        scope - Scriptable
        map - Map
    • Method Detail

      • wrap

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

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

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

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

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

        public boolean has​(java.lang.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​(java.lang.String name,
                        org.mozilla.javascript.Scriptable start,
                        java.lang.Object value)
        Specified by:
        put in interface org.mozilla.javascript.Scriptable
      • put

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

        public void delete​(java.lang.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 java.lang.Object[] getIds()
        Specified by:
        getIds in interface org.mozilla.javascript.Scriptable
      • getDefaultValue

        public java.lang.Object getDefaultValue​(java.lang.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 java.util.Map
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map
      • entrySet

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

        public java.lang.Object get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map
      • isEmpty

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

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

        public java.lang.Object put​(java.lang.Object key,
                                    java.lang.Object value)
        Specified by:
        put in interface java.util.Map
      • putAll

        public void putAll​(java.util.Map t)
        Specified by:
        putAll in interface java.util.Map
      • remove

        public java.lang.Object remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map
      • size

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

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object