javax.script
Class SimpleBindings

java.lang.Object
  extended by javax.script.SimpleBindings
All Implemented Interfaces:
Map, Bindings

public class SimpleBindings
extends Object
implements Bindings

A simple implementation of Bindings, backed by a HashMap (or other Map). This class is not synchronized (nor is HashMap). See Javadoc of Java Scripting API


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
SimpleBindings()
          Constructs a SimpleBindings.
SimpleBindings(Map map)
          Constructs a SimpleBindings and initializes it using a specified map.
 
Method Summary
 void clear()
          
 boolean containsKey(Object key)
          Returns true if this map contains a mapping for the specified key.
 boolean containsValue(Object value)
          
 Set entrySet()
          
 Object get(Object key)
          Returns the value to which this map maps the specified key.
 boolean isEmpty()
          
 Set keySet()
          
 Object put(Object key, Object value)
          Deprecated. use put(String, Object) instead
 Object put(String key, Object value)
          Associates the specified value with the specified key in a java.util.Map.
 void putAll(Map toMerge)
          Copies all of the mappings from the specified map to this map.
 Object remove(Object key)
          Removes the mapping for this key from this map if it is present (optional operation).
 int size()
          
 Collection values()
          
 
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

SimpleBindings

public SimpleBindings()
Constructs a SimpleBindings.


SimpleBindings

public SimpleBindings(Map map)
Constructs a SimpleBindings and initializes it using a specified map.

Parameters:
map - a map which is used to initialize the SimpleBindings
Throws:
NullPointerException - if the map is null
Method Detail

put

public Object put(String key,
                  Object value)
Associates the specified value with the specified key in a java.util.Map. If the map previously contained a mapping for this key, the old value is replaced.

Specified by:
put in interface Bindings
Parameters:
key - the String value which uniquely identifies the object
value - the object to be stored.
Returns:
the previous value for the mapping or null if there was none.
Throws:
NullPointerException - if the key is null
IllegalArgumentException - if the key is the empty String

put

public Object put(Object key,
                  Object value)
Deprecated. use put(String, Object) instead

This method is only needed for Java 1.4 compatibility.

Specified by:
put in interface Map

putAll

public void putAll(Map toMerge)
Copies all of the mappings from the specified map to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map.

Specified by:
putAll in interface Map
Specified by:
putAll in interface Bindings
Parameters:
toMerge - mappings to be stored in the map.

size

public int size()

Specified by:
size in interface Map

clear

public void clear()

Specified by:
clear in interface Map

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Map

containsKey

public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key.

Specified by:
containsKey in interface Map
Specified by:
containsKey in interface Bindings
Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.

containsValue

public boolean containsValue(Object value)

Specified by:
containsValue in interface Map

values

public Collection values()

Specified by:
values in interface Map

entrySet

public Set entrySet()

Specified by:
entrySet in interface Map

get

public Object get(Object key)
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Specified by:
get in interface Map
Specified by:
get in interface Bindings
Parameters:
key - key whose presence in this map is to be tested.
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for this key.

keySet

public Set keySet()

Specified by:
keySet in interface Map

remove

public Object remove(Object key)
Removes the mapping for this key from this map if it is present (optional operation). Returns the value to which the map previously associated the key, or null if the map contained no mapping for this key. (A null return can also indicate that the map previously associated null with the specified key if the implementation supports null values.) The map will not contain a mapping for the specified key once the call returns.

Specified by:
remove in interface Map
Specified by:
remove in interface Bindings
Parameters:
key - key of entry to be removed.
Returns:
the previous value associated with the key, or null if the map contained no mapping for this key.


Copyright © 1999-2012 The Apache Software Foundation. All Rights Reserved.