Top Description Constructors Methods
org.jruby.embed.variable

public Class VariableInterceptor

extends Object
Class Inheritance
Imports
java.util.Collection, .List, org.jruby.Ruby, .RubyObject, org.jruby.embed.internal.BiVariableMap, org.jruby.embed.LocalVariableBehavior, org.jruby.runtime.DynamicScope, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.scope.ManyVarsDynamicScope

This class is responsible to local variable behavior dependent processing.
Author
Yoko Harada <[email protected]>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static BiVariable

Returns:

an appropriate type of the variable instance.
getVariableInstance
(LocalVariableBehavior behavior, RubyObject
Receiver object returned when a script is evaluated.
receiver
,
String
variable name
name
,
Object...
variable value
value
)

Returns an appropriate type of a variable instance to the specified local variable behavior.

public static void
inject(BiVariableMap
a variable map that has name-value pairs to be injected
map
,
Ruby
Ruby runtime
runtime
,
ManyVarsDynamicScope
scope to inject local variable values
scope
)
Deprecated

Injects variable values from Java to Ruby just before an evaluation or method invocation.

public static void
inject(BiVariableMap
a variable map that has name-value pairs to be injected
map
,
DynamicScope
scope to inject local variable values
scope
)

Injects variable values from Java to Ruby just before an evaluation or method invocation.

public static boolean

Returns:

true when the name is a legal Ruby variable/constant name, otherwise false.
isKindOfRubyVariable
(LocalVariableBehavior behavior, String
a given name to be checked
name
)

Checks the given name is whether a legal Ruby variable/constant name or not.

private static BiVariable
resolve(BiVariable[] entries)

public static void
retrieve(LocalVariableBehavior behavior, BiVariableMap
variable map that holds retrieved name-value pairs.
map
,
RubyObject
a receiver when the script has been evaluated once
receiver
)

Retrieves variable/constant names and values after the evaluation or method invocation.

public static void
terminateGlobalVariables(LocalVariableBehavior behavior, Collection<BiVariable>
a variable list to be cleared from Ruby runtime
variables
,
Ruby
Ruby runtime
runtime
)

Clears global variable values from Ruby runtime to behave the same as JSR 223 reference implementation.

public static void
terminateLocalVariables(LocalVariableBehavior behavior, List<String>
variable name list to be cleared
varNames
,
List<BiVariable>
variable value list to be cleared
variables
)

Clears local variables form the variable map so that old local variable name-value pairs are not to be used in successive evaluations.

public static void
tryLazyRetrieval(LocalVariableBehavior behavior, BiVariableMap
variable map that holds retrieved name-value pairs.
map
,
IRubyObject
a receiver when the script has been evaluated once
receiver
,
Object key)

Retrieves specified variable/constant name and value after the evaluation or method invocation only when it is requested.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

VariableInterceptorback to summary
public VariableInterceptor()

Method Detail

getVariableInstanceback to summary
public static BiVariable getVariableInstance(LocalVariableBehavior behavior, RubyObject receiver, String name, Object... value)

Returns an appropriate type of a variable instance to the specified local variable behavior.

Parameters
receiver:RubyObject

Receiver object returned when a script is evaluated.

name:String

variable name

value:Object[]

variable value

Returns:BiVariable

an appropriate type of the variable instance.

injectback to summary
public static void inject(BiVariableMap map, Ruby runtime, ManyVarsDynamicScope scope)

Deprecated

Injects variable values from Java to Ruby just before an evaluation or method invocation.

Parameters
map:BiVariableMap

a variable map that has name-value pairs to be injected

runtime:Ruby

Ruby runtime

scope:ManyVarsDynamicScope

scope to inject local variable values

Annotations
@Deprecated
injectback to summary
public static void inject(BiVariableMap map, DynamicScope scope)

Injects variable values from Java to Ruby just before an evaluation or method invocation.

Parameters
map:BiVariableMap

a variable map that has name-value pairs to be injected

scope:DynamicScope

scope to inject local variable values

isKindOfRubyVariableback to summary
public static boolean isKindOfRubyVariable(LocalVariableBehavior behavior, String name)

Checks the given name is whether a legal Ruby variable/constant name or not.

Parameters
name:String

a given name to be checked

Returns:boolean

true when the name is a legal Ruby variable/constant name, otherwise false.

resolveback to summary
private static BiVariable resolve(BiVariable[] entries)
retrieveback to summary
public static void retrieve(LocalVariableBehavior behavior, BiVariableMap map, RubyObject receiver)

Retrieves variable/constant names and values after the evaluation or method invocation.

Parameters
map:BiVariableMap

variable map that holds retrieved name-value pairs.

receiver:RubyObject

a receiver when the script has been evaluated once

terminateGlobalVariablesback to summary
public static void terminateGlobalVariables(LocalVariableBehavior behavior, Collection<BiVariable> variables, Ruby runtime)

Clears global variable values from Ruby runtime to behave the same as JSR 223 reference implementation.

Parameters
variables:Collection<BiVariable>

a variable list to be cleared from Ruby runtime

runtime:Ruby

Ruby runtime

terminateLocalVariablesback to summary
public static void terminateLocalVariables(LocalVariableBehavior behavior, List<String> varNames, List<BiVariable> variables)

Clears local variables form the variable map so that old local variable name-value pairs are not to be used in successive evaluations.

Parameters
varNames:List<String>

variable name list to be cleared

variables:List<BiVariable>

variable value list to be cleared

tryLazyRetrievalback to summary
public static void tryLazyRetrieval(LocalVariableBehavior behavior, BiVariableMap map, IRubyObject receiver, Object key)

Retrieves specified variable/constant name and value after the evaluation or method invocation only when it is requested.

Parameters
map:BiVariableMap

variable map that holds retrieved name-value pairs.

receiver:IRubyObject

a receiver when the script has been evaluated once