public class BiVariableMap extends Object implements Map<String,Object>
BiVariable
type object.
This map does not permit null or empty key. Each operation of this class is not
synchronized; however, concurrent access to values are synchronized. When
ScriptingContainer
is shared by multiple threads, specify thread safe
for a local context scope, which makes a map thread local.
Usage example:
ScriptingContainer container = new ScriptingContainer(); Map map = container.getVarMap(); map.put("@coefficient", new Float(3.14));or, using a shortcut method: *
ScriptingContainer container = new ScriptingContainer(); container.put("@coefficient", new Float(3.14));
Constructor and Description |
---|
BiVariableMap(LocalContextProvider provider,
boolean lazy)
Constructs an empty map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the mappings from this map.
|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified
key.
|
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the
specified value.
|
Set<Map.Entry<String,Object>> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
Object |
get(Object key)
Returns the value in simple Java object to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
Object |
get(Object receiver,
Object key)
Returns the value in simple Java object to which the specified receiver
and key is mapped, or
null if this map contains no mapping
for the key in a given receiver. |
LocalVariableBehavior |
getLocalVariableBehavior()
Returns a local variable behavior
|
String[] |
getLocalVarNames()
Returns Ruby's local variable names this map has.
|
IRubyObject[] |
getLocalVarValues()
Returns Ruby's local variable values this map has.
|
Map<String,Object> |
getMap()
Returns a map whose value is a Java object not a BiVariable type object.
|
List<String> |
getNames()
Returns a list of all names in this map.
|
Ruby |
getRuntime() |
BiVariable |
getVariable(RubyObject receiver,
String name)
Returns the value in BiVariable type to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
BiVariable |
getVariable(String name)
Returns the value in BiVariable type to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
List<BiVariable> |
getVariables()
Returns a list of all values in this map.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
boolean |
isLazy()
Returns true when eager retrieval is required or false when eager
retrieval is unnecessary.
|
Set<String> |
keySet()
Returns a
Set view of the keys contained in this map. |
Object |
put(Object receiver,
String key,
Object value)
Associates the specified value with the specified key in this map.
|
Object |
put(String key,
Object value)
Associates the specified value with the specified key in this map.
|
void |
putAll(Map<? extends String,? extends Object> map)
Copies all of the mappings from the specified map to this map.
|
Object |
remove(Object key)
Removes the mapping for a key from this map if it is present in a top level.
|
Object |
removeFrom(Object receiver,
Object key)
Removes the mapping for a key from this map if it is present in a given
receiver.
|
void |
setVariable(BiVariable var) |
void |
setVariable(RubyObject receiver,
BiVariable var) |
int |
size()
Returns the number of key-value mappings in this map.
|
String |
toString() |
void |
update(String name,
BiVariable value)
Adds a key-value pair of Ruby local variable to double array.
|
void |
updateVariable(RubyObject receiver,
String name,
IRubyObject value,
Class<? extends BiVariable> type) |
Collection<Object> |
values()
Returns a
Collection view of the values contained in this map. |
public BiVariableMap(LocalContextProvider provider, boolean lazy)
runtime
- is environment where variables are used to execute Ruby scripts.behavior
- is one of variable behaviors defined in VariableBehavior.public List<String> getNames()
public List<BiVariable> getVariables()
public Ruby getRuntime()
public LocalVariableBehavior getLocalVariableBehavior()
public Map<String,Object> getMap()
public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
containsKey
in interface Map<String,Object>
key
- is a key to be tested its presencepublic boolean containsValue(Object value)
containsValue
in interface Map<String,Object>
value
- is a Java object to be tested it presencepublic Object get(Object key)
null
if this map contains no mapping for the key.public Object get(Object receiver, Object key)
null
if this map contains no mapping
for the key in a given receiver.receiver
- is a receiver object to get the value fromkey
- is the key whose associated value is to be returnednull
if this map contains no mapping for the keypublic BiVariable getVariable(String name)
null
if this map contains no mapping for the key.name
- is the key whose associated BiVariable object is to be returnednull
if this map contains no mapping for the keypublic BiVariable getVariable(RubyObject receiver, String name)
null
if this map contains no mapping for the key.receiver
- is a receiver object to get key-value pair fromname
- is the key whose associated BiVariable object is to be returnednull
if this map contains no mapping for the keypublic void setVariable(BiVariable var)
public void setVariable(RubyObject receiver, BiVariable var)
public Object put(String key, Object value)
public Object put(Object receiver, String key, Object value)
receiver
- a receiver object to associate a given key-value pair withkey
- the key with which the specified value is to be associatedvalue
- a simple Java object to be associated with the specified keypublic String[] getLocalVarNames()
public IRubyObject[] getLocalVarValues()
public Object remove(Object key)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
public Object removeFrom(Object receiver, Object key)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
key
- the key whose mapping is to be removed from the mappublic void putAll(Map<? extends String,? extends Object> map)
public void clear()
public Set<String> keySet()
Set
view of the keys contained in this map.
The set is backed by the map, so changes to the map should be
reflected in the set, and vice-versa. However, the implementation
does not reflect changes currently.public Collection<Object> values()
Collection
view of the values contained in this map.
The collection is backed by the map, so changes to the map should be
reflected in the collection, and vice-versa. However, the implementation
does not reflect changes currently.public Set<Map.Entry<String,Object>> entrySet()
Set
view of the mappings contained in this map.
The set is backed by the map, so changes to the map should be
reflected in the set, and vice-versa. However, the implementation
does not reflect changes currently.public void update(String name, BiVariable value)
name
- is a Ruby's local variable namevalue
- is BiVariable type object corresponding to the namepublic void updateVariable(RubyObject receiver, String name, IRubyObject value, Class<? extends BiVariable> type)
public boolean isLazy()
Copyright © 2001-2015 JRuby. All Rights Reserved.