|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.embed.internal.BiVariableMap<K,V>
public class BiVariableMap<K,V>
Ruby-Java bi-directional variable map implementation. Keys of this map
should be String, and values should be 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));
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Constructor Summary | |
---|---|
BiVariableMap(LocalContextProvider provider,
boolean lazy)
Constructs an empty map. |
Method Summary | |
---|---|
void |
clear()
Removes all of the mappings from this map. |
boolean |
containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the specified value. |
java.util.Set |
entrySet()
Returns a Set view of the mappings contained in this map. |
V |
get(java.lang.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. |
V |
get(java.lang.Object receiver,
java.lang.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 |
java.lang.String[] |
getLocalVarNames()
Returns Ruby's local variable names this map has. |
IRubyObject[] |
getLocalVarValues()
Returns Ruby's local variable values this map has. |
java.util.Map |
getMap()
Returns a map whose value is a Java object not a BiVariable type object. |
java.util.List<java.lang.String> |
getNames()
Returns a list of all names in this map. |
BiVariable |
getVariable(RubyObject receiver,
java.lang.String key)
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(java.lang.String key)
Deprecated. |
java.util.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 requird or false when eager retrieval is unnecessary. |
java.util.Set |
keySet()
Returns a Set view of the keys contained in this map. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this map. |
V |
put(java.lang.Object receiver,
K key,
V value)
Associates the specified value with the specified key in this map. |
void |
putAll(java.util.Map<? extends K,? extends V> t)
Copies all of the mappings from the specified map to this map. |
V |
remove(java.lang.Object key)
Removes the mapping for a key from this map if it is present in a top level. |
V |
remove(java.lang.Object receiver,
java.lang.Object key)
Removes the mapping for a key from this map if it is present in a given receiver. |
void |
setVariable(BiVariable var)
Deprecated. |
void |
setVariable(RubyObject receiver,
BiVariable var)
|
int |
size()
Returns the number of key-value mappings in this map. |
void |
update(java.lang.String name,
BiVariable value)
Adds a key-value pair of Ruby local variable to double array. |
java.util.Collection |
values()
Returns a Collection view of the values contained in this map. |
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 |
---|
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.Method Detail |
---|
public java.util.List<java.lang.String> getNames()
public java.util.List<BiVariable> getVariables()
public LocalVariableBehavior getLocalVariableBehavior()
public java.util.Map getMap()
public int size()
size
in interface java.util.Map<K,V>
public boolean isEmpty()
isEmpty
in interface java.util.Map<K,V>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,V>
key
- is a key to be tested its presence
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<K,V>
value
- is a Java object to be tested it presence
public V get(java.lang.Object key)
null
if this map contains no mapping for the key.
get
in interface java.util.Map<K,V>
key
- is the key whose associated value is to be returned
null
if this map contains no mapping for the keypublic V get(java.lang.Object receiver, java.lang.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 returned
null
if this map contains no mapping for the key@Deprecated public BiVariable getVariable(java.lang.String key)
null
if this map contains no mapping for the key.
key
- is the key whose associated BiVariable object is to be returned
null
if this map contains no mapping for the keypublic BiVariable getVariable(RubyObject receiver, java.lang.String key)
null
if this map contains no mapping for the key.
receiver
- is a receiver object to get key-value pair fromkey
- is the key whose associated BiVariable object is to be returned
null
if this map contains no mapping for the key@Deprecated public void setVariable(BiVariable var)
public void setVariable(RubyObject receiver, BiVariable var)
public V put(K key, V value)
put
in interface java.util.Map<K,V>
key
- the key with which the specified value is to be associatedvalue
- a simple Java object to be associated with the specified key
public V put(java.lang.Object receiver, K key, V 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 key
public java.lang.String[] getLocalVarNames()
public IRubyObject[] getLocalVarValues()
public V remove(java.lang.Object key)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
remove
in interface java.util.Map<K,V>
key
- the key whose mapping is to be removed from the map
public V remove(java.lang.Object receiver, java.lang.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 map
public void putAll(java.util.Map<? extends K,? extends V> t)
putAll
in interface java.util.Map<K,V>
t
- mappings to be stored in this mappublic void clear()
clear
in interface java.util.Map<K,V>
public java.util.Set 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.
keySet
in interface java.util.Map<K,V>
public java.util.Collection 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.
values
in interface java.util.Map<K,V>
public java.util.Set 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.
entrySet
in interface java.util.Map<K,V>
public void update(java.lang.String name, BiVariable value)
name
- is a Ruby's local variable namevalue
- is BiVariable type object corresponding to the namepublic boolean isLazy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |