Bindings (Java SE 15 & JDK 15) (original) (raw)
All Superinterfaces:
[Map](../../../java.base/java/util/Map.html "interface in java.util")<[String](../../../java.base/java/lang/String.html "class in java.lang"),[Object](../../../java.base/java/lang/Object.html "class in java.lang")>
All Known Implementing Classes:
[SimpleBindings](SimpleBindings.html "class in javax.script")
public interface Bindings extends Map<String,Object>
A mapping of key/value pairs, all of whose keys areStrings
.
Since:
1.6
Nested Class Summary
Nested classes/interfaces declared in interface java.util.Map
[Map.Entry](../../../java.base/java/util/Map.Entry.html "interface in java.util")<[K](../../../java.base/java/util/Map.Entry.html "type parameter in Map.Entry"),[V](../../../java.base/java/util/Map.Entry.html "type parameter in Map.Entry")>
Method Summary
Modifier and Type | Method | Description |
---|---|---|
boolean | containsKey(Object key) | Returns true if this map contains a mapping for the specified key. |
Object | get(Object key) | Returns the value to which this map maps the specified key. |
Object | put(String name,Object value) | Set a named value. |
void | putAll(Map<? extends String,? extends Object> toMerge) | Adds all the mappings in a given Map to this Bindings. |
Object | remove(Object key) | Removes the mapping for this key from this map if it is present (optional operation). |
Methods declared in interface java.util.Map
[clear](../../../java.base/java/util/Map.html#clear%28%29), [compute](../../../java.base/java/util/Map.html#compute%28K,java.util.function.BiFunction%29), [computeIfAbsent](../../../java.base/java/util/Map.html#computeIfAbsent%28K,java.util.function.Function%29), [computeIfPresent](../../../java.base/java/util/Map.html#computeIfPresent%28K,java.util.function.BiFunction%29), [containsValue](../../../java.base/java/util/Map.html#containsValue%28java.lang.Object%29), [entrySet](../../../java.base/java/util/Map.html#entrySet%28%29), [equals](../../../java.base/java/util/Map.html#equals%28java.lang.Object%29), [forEach](../../../java.base/java/util/Map.html#forEach%28java.util.function.BiConsumer%29), [getOrDefault](../../../java.base/java/util/Map.html#getOrDefault%28java.lang.Object,V%29), [hashCode](../../../java.base/java/util/Map.html#hashCode%28%29), [isEmpty](../../../java.base/java/util/Map.html#isEmpty%28%29), [keySet](../../../java.base/java/util/Map.html#keySet%28%29), [merge](../../../java.base/java/util/Map.html#merge%28K,V,java.util.function.BiFunction%29), [putIfAbsent](../../../java.base/java/util/Map.html#putIfAbsent%28K,V%29), [remove](../../../java.base/java/util/Map.html#remove%28java.lang.Object,java.lang.Object%29), [replace](../../../java.base/java/util/Map.html#replace%28K,V%29), [replace](../../../java.base/java/util/Map.html#replace%28K,V,V%29), [replaceAll](../../../java.base/java/util/Map.html#replaceAll%28java.util.function.BiFunction%29), [size](../../../java.base/java/util/Map.html#size%28%29), [values](../../../java.base/java/util/Map.html#values%28%29)
Method Details
put
Set a named value.
Specified by:
[put](../../../java.base/java/util/Map.html#put%28K,V%29)
in interface[Map](../../../java.base/java/util/Map.html "interface in java.util")<[String](../../../java.base/java/lang/String.html "class in java.lang"),[Object](../../../java.base/java/lang/Object.html "class in java.lang")>
Parameters:
name
- The name associated with the value.
value
- The value associated with the name.
Returns:
The value previously associated with the given name. Returns null if no value was previously associated with the name.
Throws:
[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if the name is null.
[IllegalArgumentException](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if the name is empty String.putAll
void putAll(Map<? extends String,? extends Object> toMerge)
Adds all the mappings in a givenMap
to thisBindings
.
Specified by:
[putAll](../../../java.base/java/util/Map.html#putAll%28java.util.Map%29)
in interface[Map](../../../java.base/java/util/Map.html "interface in java.util")<[String](../../../java.base/java/lang/String.html "class in java.lang"),[Object](../../../java.base/java/lang/Object.html "class in java.lang")>
Parameters:
toMerge
- TheMap
to merge with this one.
Throws:
[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if toMerge map is null or if some key in the map is null.
[IllegalArgumentException](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if some key in the map is an empty String.containsKey
boolean containsKey(Object key)
Returnstrue
if this map contains a mapping for the specified key. More formally, returnstrue
if and only if this map contains a mapping for a keyk
such that(key==null ? k==null : key.equals(k))
. (There can be at most one such mapping.)
Specified by:
[containsKey](../../../java.base/java/util/Map.html#containsKey%28java.lang.Object%29)
in interface[Map](../../../java.base/java/util/Map.html "interface in java.util")<[String](../../../java.base/java/lang/String.html "class in java.lang"),[Object](../../../java.base/java/lang/Object.html "class in java.lang")>
Parameters:
key
- key whose presence in this map is to be tested.
Returns:
true
if this map contains a mapping for the specified key.
Throws:
[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key is null
[ClassCastException](../../../java.base/java/lang/ClassCastException.html "class in java.lang")
- if key is not String
[IllegalArgumentException](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if key is empty Stringget
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 ofnull
does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key tonull
. ThecontainsKey
operation may be used to distinguish these two cases.
More formally, if this map contains a mapping from a keyk
to a valuev
such that(key==null ? k==null : key.equals(k))
, then this method returnsv
; otherwise it returnsnull
. (There can be at most one such mapping.)
Specified by:
[get](../../../java.base/java/util/Map.html#get%28java.lang.Object%29)
in interface[Map](../../../java.base/java/util/Map.html "interface in java.util")<[String](../../../java.base/java/lang/String.html "class in java.lang"),[Object](../../../java.base/java/lang/Object.html "class in java.lang")>
Parameters:
key
- key whose associated value is to be returned.
Returns:
the value to which this map maps the specified key, ornull
if the map contains no mapping for this key.
Throws:
[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key is null
[ClassCastException](../../../java.base/java/lang/ClassCastException.html "class in java.lang")
- if key is not String
[IllegalArgumentException](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if key is empty Stringremove
Removes the mapping for this key from this map if it is present (optional operation). More formally, if this map contains a mapping from key
k
to valuev
such that(key==null ? k==null : key.equals(k))
, that mapping is removed. (The map can contain at most one such mapping.)
Returns the value to which the map previously associated the key, ornull
if the map contained no mapping for this key. (Anull
return can also indicate that the map previously associatednull
with the specified key if the implementation supportsnull
values.) The map will not contain a mapping for the specified key once the call returns.
Specified by:
[remove](../../../java.base/java/util/Map.html#remove%28java.lang.Object%29)
in interface[Map](../../../java.base/java/util/Map.html "interface in java.util")<[String](../../../java.base/java/lang/String.html "class in java.lang"),[Object](../../../java.base/java/lang/Object.html "class in java.lang")>
Parameters:
key
- key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, ornull
if there was no mapping for key.
Throws:
[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key is null
[ClassCastException](../../../java.base/java/lang/ClassCastException.html "class in java.lang")
- if key is not String
[IllegalArgumentException](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if key is empty String