public class GlobalVariable extends Object
BiVariable.Type
Modifier and Type | Field and Description |
---|---|
protected boolean |
fromRuby |
protected IRubyObject |
irubyObject |
protected Object |
javaObject |
protected Class |
javaType |
protected String |
name |
protected IRubyObject |
receiver |
Modifier | Constructor and Description |
---|---|
protected |
GlobalVariable(RubyObject receiver,
String name,
Object... javaObjects) |
Modifier and Type | Method and Description |
---|---|
static BiVariable |
getInstance(RubyObject receiver,
String name,
Object... javaObject)
Returns an instance of this class.
|
Object |
getJavaObject()
Returns a value of the variable this object holds in Java type.
|
String |
getName()
Returns a name of the variable this object holds.
|
IRubyObject |
getReceiver()
Returns the original receiver where this variable has been retrieved.
|
protected static RubyModule |
getRubyClass(Ruby runtime) |
IRubyObject |
getRubyObject()
Returns a value of the variable this object holds in
a org.jruby.runtime.builtin.IRubyObject type.
|
BiVariable.Type |
getType()
Returns enum type of this variable defined in
BiVariable . |
void |
inject()
A global variable is injected when it is set.
|
protected static boolean |
isPredefined(String name) |
boolean |
isReceiverIdentical(RubyObject recv)
Returns true if a given receiver is identical to the receiver this object has.
|
static boolean |
isValidName(Object name)
Returns true if the given name is a decent Ruby global variable.
|
protected static boolean |
isValidName(String pattern,
Object name) |
void |
remove()
Attempts to remove this variable from top self or receiver.
|
static void |
retrieve(IRubyObject receiver,
BiVariableMap vars)
Retrieves global variables from Ruby after the evaluation.
|
static void |
retrieveByKey(Ruby runtime,
BiVariableMap vars,
String key)
Retrieves a global variable by key from Ruby after the evaluation.
|
void |
setJavaObject(Ruby runtime,
Object javaObject)
Sets a Java object and its Ruby type 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.
|
void |
tryEagerInjection(IRubyObject receiver)
Injects a global variable value to a parsed Ruby script.
|
void |
tryEagerInjection(Ruby runtime,
IRubyObject receiver)
Deprecated.
|
protected void |
updateByJavaObject(Ruby runtime,
Object... values) |
protected void |
updateRubyObject(IRubyObject rubyObject) |
protected final IRubyObject receiver
protected final String name
protected Object javaObject
protected Class javaType
protected IRubyObject irubyObject
protected boolean fromRuby
protected GlobalVariable(RubyObject receiver, String name, Object... javaObjects)
public static BiVariable getInstance(RubyObject receiver, String name, Object... javaObject)
BiVariableMap
.runtime
- Ruby runtimename
- a variable namejavaObject
- Java object that should be assigned to.public static void retrieve(IRubyObject receiver, BiVariableMap vars)
runtime
- Ruby runtimereceiver
- receiver object returned when a script is evaluated.vars
- map to save retrieved global variables.public static void retrieveByKey(Ruby runtime, BiVariableMap vars, String key)
runtime
- Ruby runtimereceiver
- receiver object returned when a script is evaluated.vars
- map to save a retrieved global variable.key
- name of the global variableprotected static boolean isPredefined(String name)
public BiVariable.Type getType()
BiVariable
.public static boolean isValidName(Object name)
name
- is a name to be checked.public void setJavaObject(Ruby runtime, Object javaObject)
setJavaObject
in interface BiVariable
runtime
- is used to convert a Java object to Ruby object.javaObject
- is a variable value to be set.public void inject()
@Deprecated public void tryEagerInjection(Ruby runtime, IRubyObject receiver)
public void tryEagerInjection(IRubyObject receiver)
runtime
- is environment where a variable injection occursreceiver
- is the instance that will have variable injection.public void remove()
public boolean isReceiverIdentical(RubyObject recv)
isReceiverIdentical
in interface BiVariable
protected void updateRubyObject(IRubyObject rubyObject)
public IRubyObject getReceiver()
BiVariable
getReceiver
in interface BiVariable
public String getName()
BiVariable
getName
in interface BiVariable
public Object getJavaObject()
BiVariable
getJavaObject
in interface BiVariable
public IRubyObject getRubyObject()
BiVariable
getRubyObject
in interface BiVariable
public void setRubyObject(IRubyObject rubyObject)
BiVariable
setRubyObject
in interface BiVariable
rubyObject
- is a variable value to be set.protected static RubyModule getRubyClass(Ruby runtime)
Copyright © 2001-2016 JRuby. All Rights Reserved.