org.springframework.extensions.webscripts
Class ScriptableWrappedMap

java.lang.Object
  extended by 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

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
ScriptableWrappedMap(Map map)
          Construct
ScriptableWrappedMap(org.mozilla.javascript.Scriptable scope, Map map)
          Construct
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 void delete(int index)
           
 void delete(String name)
           
 Set entrySet()
           
 Object get(int index, org.mozilla.javascript.Scriptable start)
           
 Object get(Object key)
           
 Object get(String name, org.mozilla.javascript.Scriptable start)
           
 String getClassName()
           
 Object getDefaultValue(Class hint)
           
 Object[] getIds()
           
 org.mozilla.javascript.Scriptable getParentScope()
           
 org.mozilla.javascript.Scriptable getPrototype()
           
 boolean has(int index, org.mozilla.javascript.Scriptable start)
           
 boolean has(String name, org.mozilla.javascript.Scriptable start)
           
 boolean hasInstance(org.mozilla.javascript.Scriptable value)
           
 boolean isEmpty()
           
 Set keySet()
           
 void put(int index, org.mozilla.javascript.Scriptable start, Object value)
           
 Object put(Object key, Object value)
           
 void put(String name, org.mozilla.javascript.Scriptable start, Object value)
           
 void putAll(Map t)
           
 Object remove(Object key)
           
 void setParentScope(org.mozilla.javascript.Scriptable parent)
           
 void setPrototype(org.mozilla.javascript.Scriptable prototype)
           
 int size()
           
 Object unwrap()
           
 Collection values()
           
static ScriptableWrappedMap wrap(org.mozilla.javascript.Scriptable scope, Map<Object,Object> map)
          Construction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

ScriptableWrappedMap

public ScriptableWrappedMap(Map map)
Construct

Parameters:
map -

ScriptableWrappedMap

public ScriptableWrappedMap(org.mozilla.javascript.Scriptable scope,
                            Map map)
Construct

Parameters:
scope -
map -
Method Detail

wrap

public static ScriptableWrappedMap wrap(org.mozilla.javascript.Scriptable scope,
                                        Map<Object,Object> map)
Construction

Parameters:
scope -
map -
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


Copyright © 2009 SpringSource, Inc. All Rights Reserved.