Top Description Fields Constructors Methods
org.jruby.embed.variable

public Class LocalGlobalVariable

extends GlobalVariable
Class Inheritance
Imports
org.jruby.Ruby, .RubyObject, org.jruby.embed.internal.BiVariableMap, org.jruby.internal.runtime.GlobalVariables, org.jruby.runtime.builtin.IRubyObject

An implementation of BiVariable for JSR223 style global variable. The assigned name is like a local variables in Java, but a global in Ruby.
Author
Yoko Harada <[email protected]>

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
private
LocalGlobalVariable(RubyObject receiver, String name, Object... javaObject)

pack-priv
LocalGlobalVariable(RubyObject receiver, String
the local global type variable name
name
,
IRubyObject
Ruby global object
irubyObject
)

A constructor used when local global type variables are retrieved from Ruby.

Method Summary

Modifier and TypeMethod and Description
public static BiVariable

Returns:

the instance of LocalGlobalVariable
getInstance
(RubyObject
Receiver object returned when a script is evaluated.
receiver
,
String
a variable name
name
,
Object...
Java object that should be assigned to.
javaObject
)

Hides org.jruby.embed.variable.GlobalVariable.getInstance.

Returns an instance of this class.

public BiVariable.Type

Returns:

this enum type, BiVariable.Type.GlobalVariable.
getType
()

Overrides org.jruby.embed.variable.GlobalVariable.getType.

Implements org.jruby.embed.variable.BiVariable.getType.

Returns enum type of this variable defined in BiVariable.

public void
inject()

Overrides org.jruby.embed.variable.GlobalVariable.inject.

Implements org.jruby.embed.variable.BiVariable.inject.

Injects a global value to a parsed Ruby script.

public static boolean

Returns:

true if the given name is of a local global type variable.
isValidName
(Object
is a name to be checked.
name
)

Hides org.jruby.embed.variable.GlobalVariable.isValidName.

Returns true if the given name is a local global type variable.

public void
public static void
retrieve(final RubyObject
receiver object returned when a script is evaluated.
receiver
,
final BiVariableMap
map to save retrieved global variables.
vars
)

Retrieves global variables eagerly from Ruby right after the evaluation.

public static void
retrieveByKey(final Ruby
Ruby runtime
runtime
,
final BiVariableMap
map to save a retrieved global variable.
vars
,
final String
name of the global variable
name
)

Hides org.jruby.embed.variable.GlobalVariable.retrieveByKey.

Retrieves a global variable by key from Ruby runtime after the evaluation.

private static void
updateLocalGlobal(final RubyObject receiver, final BiVariableMap vars, final String name, final IRubyObject value)

Inherited from org.jruby.embed.variable.GlobalVariable:
isPredefinedisReceiverIdenticalretrievesetJavaObjecttryEagerInjectiontryEagerInjection

Field Detail

VALID_NAMEback to summary
private static final String VALID_NAME

Hides org.jruby.embed.variable.GlobalVariable.VALID_NAME.

Constructor Detail

LocalGlobalVariableback to summary
private LocalGlobalVariable(RubyObject receiver, String name, Object... javaObject)
LocalGlobalVariableback to summary
pack-priv LocalGlobalVariable(RubyObject receiver, String name, IRubyObject irubyObject)

A constructor used when local global type variables are retrieved from Ruby.

Parameters
name:String

the local global type variable name

irubyObject:IRubyObject

Ruby global object

Method Detail

getInstanceback to summary
public static BiVariable getInstance(RubyObject receiver, String name, Object... javaObject)

Hides org.jruby.embed.variable.GlobalVariable.getInstance.

Returns an instance of this class. This factory method is used when a local global type variable is put into BiVariableMap.

Parameters
receiver:RubyObject

Receiver object returned when a script is evaluated.

name:String

a variable name

javaObject:Object[]

Java object that should be assigned to.

Returns:BiVariable

the instance of LocalGlobalVariable

getTypeback to summary
public BiVariable.Type getType()

Overrides org.jruby.embed.variable.GlobalVariable.getType.

Implements org.jruby.embed.variable.BiVariable.getType.

Returns enum type of this variable defined in BiVariable.

Returns:BiVariable.Type

this enum type, BiVariable.Type.GlobalVariable.

Annotations
@Override
injectback to summary
public void inject()

Overrides org.jruby.embed.variable.GlobalVariable.inject.

Implements org.jruby.embed.variable.BiVariable.inject.

Injects a global value to a parsed Ruby script. This method is invoked during EvalUnit#run() is executed.

Annotations
@Override
isValidNameback to summary
public static boolean isValidName(Object name)

Hides org.jruby.embed.variable.GlobalVariable.isValidName.

Returns true if the given name is a local global type variable. Unless returns false.

Parameters
name:Object

is a name to be checked.

Returns:boolean

true if the given name is of a local global type variable.

removeback to summary
public void remove()

Overrides org.jruby.embed.variable.GlobalVariable.remove.

Implements org.jruby.embed.variable.BiVariable.remove.

Removes this object from BiVariableMap.

Annotations
@Override
retrieveback to summary
public static void retrieve(final RubyObject receiver, final BiVariableMap vars)

Retrieves global variables eagerly from Ruby right after the evaluation. The variable names to be retrieved must be in a variable map.

Parameters
receiver:RubyObject

receiver object returned when a script is evaluated.

vars:BiVariableMap

map to save retrieved global variables.

retrieveByKeyback to summary
public static void retrieveByKey(final Ruby runtime, final BiVariableMap vars, final String name)

Hides org.jruby.embed.variable.GlobalVariable.retrieveByKey.

Retrieves a global variable by key from Ruby runtime after the evaluation. This method is used when eager retrieval is off.

Parameters
runtime:Ruby

Ruby runtime

vars:BiVariableMap

map to save a retrieved global variable.

name:String

name of the global variable

updateLocalGlobalback to summary
private static void updateLocalGlobal(final RubyObject receiver, final BiVariableMap vars, final String name, final IRubyObject value)