Package org.jruby.embed.internal
Class EmbedRubyObjectAdapterImpl
java.lang.Object
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl
- All Implemented Interfaces:
EmbedRubyObjectAdapter
,RubyObjectAdapter
Implementation of
EmbedRubyObjectAdapter
. Users get an instance of this
class by newObjectAdapter() method of ScriptingContainer
.- Author:
- Yoko Harada <[email protected]>
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionEmbedRubyObjectAdapterImpl
(ScriptingContainer container) EmbedRubyObjectAdapterImpl
(ScriptingContainer container, boolean wrapExceptions) -
Method Summary
Modifier and TypeMethodDescription<T> T
callMethod
(Object receiver, String methodName, Class<T> returnType) Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script.callMethod
(Object receiver, String methodName, Object... args) Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Object[] args, Class<T> returnType) Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Object[] args, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script.<T> T
Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Object[] args, Block block, Class<T> returnType, EmbedEvalUnit unit) Executes a method defined in Ruby script.<T> T
callMethod
(Object receiver, String methodName, Object singleArg, Class<T> returnType) Executes a method defined in Ruby script.callMethod
(Object receiver, String methodName, Block block, Object... args) Executes a method defined in Ruby script.callMethod
(IRubyObject receiver, String methodName) callMethod
(IRubyObject receiver, String methodName, IRubyObject singleArg) callMethod
(IRubyObject receiver, String methodName, IRubyObject[] args) callMethod
(IRubyObject receiver, String methodName, IRubyObject[] args, Block block) <T> T
<T> T
callSuper
(IRubyObject receiver, IRubyObject[] args) callSuper
(IRubyObject receiver, IRubyObject[] args, Block block) convertToJavaArray
(IRubyObject array) getInstanceVariable
(IRubyObject obj, String variableName) boolean
isKindOf
(IRubyObject value, RubyModule rubyModule) <T> T
Executes a method defined in Ruby script.setInstanceVariable
(IRubyObject obj, String variableName, IRubyObject value)
-
Constructor Details
-
EmbedRubyObjectAdapterImpl
-
EmbedRubyObjectAdapterImpl
-
-
Method Details
-
isKindOf
- Specified by:
isKindOf
in interfaceRubyObjectAdapter
-
convertToJavaArray
- Specified by:
convertToJavaArray
in interfaceRubyObjectAdapter
-
convertToRubyInteger
- Specified by:
convertToRubyInteger
in interfaceRubyObjectAdapter
-
convertToRubyString
- Specified by:
convertToRubyString
in interfaceRubyObjectAdapter
-
setInstanceVariable
- Specified by:
setInstanceVariable
in interfaceRubyObjectAdapter
-
getInstanceVariable
- Specified by:
getInstanceVariable
in interfaceRubyObjectAdapter
-
callMethod
- Specified by:
callMethod
in interfaceRubyObjectAdapter
-
callMethod
- Specified by:
callMethod
in interfaceRubyObjectAdapter
-
callMethod
- Specified by:
callMethod
in interfaceRubyObjectAdapter
-
callMethod
public IRubyObject callMethod(IRubyObject receiver, String methodName, IRubyObject[] args, Block block) - Specified by:
callMethod
in interfaceRubyObjectAdapter
-
callSuper
- Specified by:
callSuper
in interfaceRubyObjectAdapter
-
callSuper
- Specified by:
callSuper
in interfaceRubyObjectAdapter
-
callMethod
Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script. This method is used when a Ruby method does not have any argument.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledreturnType
- is the type we want it to convert to- Returns:
- an instance of requested Java type
-
callMethod
Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script. This method is used when a Ruby method have only one argument.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledsingleArg
- is an method argumentreturnType
- returnType is the type we want it to convert to- Returns:
- an instance of requested Java type
-
callMethod
Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script. This method is used when a Ruby method have multiple arguments.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledargs
- is an array of method argumentsreturnType
- is the type we want it to convert to- Returns:
- an instance of requested Java type
-
callMethod
public <T> T callMethod(Object receiver, String methodName, Object[] args, Block block, Class<T> returnType) Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script. This method is used when a Ruby method have multiple arguments, one of which is a block.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledargs
- is an array of method arguments except a blockblock
- is a block to be executed in this methodreturnType
- is the type we want it to convert to- Returns:
- an instance of requested Java type
-
callMethod
public <T> T callMethod(Object receiver, String methodName, Class<T> returnType, EmbedEvalUnit unit) Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script. This method is used when a Ruby method does not have any argument, and users want to inject Ruby's local variables' values from Java.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledreturnType
- is the type we want it to convert tounit
- is parsed unit- Returns:
- an instance of requested Java type
-
callMethod
public <T> T callMethod(Object receiver, String methodName, Object[] args, Class<T> returnType, EmbedEvalUnit unit) Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script. This method is used when a Ruby method have multiple arguments, and users want to inject Ruby's local variables' values from Java.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledargs
- is an array of method argumentsreturnType
- is the type we want it to convert tounit
- is parsed unit- Returns:
- an instance of requested Java type
-
callMethod
public <T> T callMethod(Object receiver, String methodName, Object[] args, Block block, Class<T> returnType, EmbedEvalUnit unit) Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script. This method is used when a Ruby method have multiple arguments, one of which is a block, and users want to inject Ruby's local variables' values from Java.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledargs
- is an array of method arguments except a blockblock
- is a block to be executed in this methodreturnType
- is the type we want it to convert tounit
- is parsed unit- Returns:
- is the type we want it to convert to
-
callSuper
- Specified by:
callSuper
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callargs
- is an array of method argumentsreturnType
- is the type we want it to convert to- Returns:
- is the type we want it to convert to
-
callSuper
- Specified by:
callSuper
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callargs
- is an array of method arguments except a blockblock
- is a block to be executed in this methodreturnType
- is the type we want it to convert to- Returns:
- is the type we want it to convert to
-
callMethod
Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledargs
- are method arguments.- Returns:
- an instance automatically converted from Ruby to Java
-
callMethod
Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script. This method is used when a Ruby method has a block in its arguments.- Specified by:
callMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
receiver
- is an instance that will receive this method callmethodName
- is a method name to be calledblock
- is a block to be executed in this methodargs
- is an array of method arguments except a block- Returns:
- an instance of automatically converted Java type
-
runRubyMethod
public <T> T runRubyMethod(Class<T> returnType, Object receiver, String methodName, Block block, Object... args) Description copied from interface:EmbedRubyObjectAdapter
Executes a method defined in Ruby script.- Specified by:
runRubyMethod
in interfaceEmbedRubyObjectAdapter
- Parameters:
returnType
- is the type we want it to convert toreceiver
- is an instance that will receive this method call. The receiver can be null or other Java objects. The null will be converted to RubyNil or wrapped in RubyObject.methodName
- is a method name to be calledblock
- is an optional Block object. Send null for no block.args
- is an array of method arguments- Returns:
- an instance of requested Java type
-