Package org.jruby.embed.variable
Interface BiVariable
- All Known Implementing Classes:
Argv
,ClassVariable
,Constant
,GlobalVariable
,InstanceVariable
,LocalGlobalVariable
,PersistentLocalVariable
,TransientLocalVariable
public interface BiVariable
Represents bidirectional, both Java and Ruby, variables. Users don't instantiate
BiVariable type objects. Instead, users can get this type object from
BiVariableMap
after a variable is set to the map. Users can set variables
in Java program explicitly through put() methods in ScriptingContainer
and BiVariableMap
or equivalents. However, variables in Ruby scripts are
set in the map implicitly. When variables and constants
are used in the script, those are automatically saved in the map converting to this type.- Author:
- Yoko Harada <[email protected]>
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Defines a type correspond to Ruby's variables and constant types. -
Method Summary
Modifier and TypeMethodDescriptionReturns a value of the variable this object holds in Java type.getName()
Returns a name of the variable this object holds.Returns the original receiver where this variable has been retrieved.Returns a value of the variable this object holds in a org.jruby.runtime.builtin.IRubyObject type.getType()
Returns one of the Ruby's variables or constant types defined by Type.void
inject()
Injects a variable value to a parsed Ruby script.boolean
isReceiverIdentical
(RubyObject receiver) Returns true if a given receiver is identical to the receiver this object has.void
remove()
Attempts to remove this variable/constant from top self or receiver.void
setJavaObject
(Ruby runtime, Object javaObject) Sets a Java object as a value of this object.void
setRubyObject
(IRubyObject rubyObject) Sets a org.jruby.runtime.builtin.IRubyObject type, Ruby object as a value of this object.
-
Method Details
-
getType
BiVariable.Type getType()Returns one of the Ruby's variables or constant types defined by Type.- Returns:
- a type that corresponds to Ruby's variables and constant types.
-
getReceiver
IRubyObject getReceiver()Returns the original receiver where this variable has been retrieved.- Returns:
- an original receiver.
-
isReceiverIdentical
Returns true if a given receiver is identical to the receiver this object has.- Returns:
- true if identical otherwise false.
-
getName
String getName()Returns a name of the variable this object holds. The name follows Ruby's naming rule.- Returns:
- a name of the variable
-
getJavaObject
Object getJavaObject()Returns a value of the variable this object holds in Java type.- Returns:
- a value in Java type.
-
setJavaObject
Sets a Java object as a value of this object. At the same time, an equivalent Ruby object is set automatically.- Parameters:
runtime
- is used to convert a Java object to Ruby object.javaObject
- is a variable value to be set.
-
inject
void inject()Injects a variable value to a parsed Ruby script. This method is invoked during EvalUnit#run() is executed. Users don't use this method. -
getRubyObject
IRubyObject getRubyObject()Returns a value of the variable this object holds in a org.jruby.runtime.builtin.IRubyObject type.- Returns:
- a value in IRubyObject type.
-
setRubyObject
Sets a org.jruby.runtime.builtin.IRubyObject type, Ruby object as a value of this object. At the same time, an equivalent Java object is set automatically.- Parameters:
rubyObject
- is a variable value to be set.
-
remove
void remove()Attempts to remove this variable/constant from top self or receiver.
-