Class EmbedRubyObjectAdapterImpl

java.lang.Object
org.jruby.embed.internal.EmbedRubyObjectAdapterImpl
All Implemented Interfaces:
EmbedRubyObjectAdapter, RubyObjectAdapter

public class EmbedRubyObjectAdapterImpl extends Object implements EmbedRubyObjectAdapter
Implementation of EmbedRubyObjectAdapter. Users get an instance of this class by newObjectAdapter() method of ScriptingContainer.
Author:
Yoko Harada <[email protected]>
  • Constructor Details

    • EmbedRubyObjectAdapterImpl

      public EmbedRubyObjectAdapterImpl(ScriptingContainer container)
    • EmbedRubyObjectAdapterImpl

      public EmbedRubyObjectAdapterImpl(ScriptingContainer container, boolean wrapExceptions)
  • Method Details

    • isKindOf

      public boolean isKindOf(IRubyObject value, RubyModule rubyModule)
      Specified by:
      isKindOf in interface RubyObjectAdapter
    • convertToJavaArray

      public IRubyObject[] convertToJavaArray(IRubyObject array)
      Specified by:
      convertToJavaArray in interface RubyObjectAdapter
    • convertToRubyInteger

      public RubyInteger convertToRubyInteger(IRubyObject obj)
      Specified by:
      convertToRubyInteger in interface RubyObjectAdapter
    • convertToRubyString

      public RubyString convertToRubyString(IRubyObject obj)
      Specified by:
      convertToRubyString in interface RubyObjectAdapter
    • setInstanceVariable

      public IRubyObject setInstanceVariable(IRubyObject obj, String variableName, IRubyObject value)
      Specified by:
      setInstanceVariable in interface RubyObjectAdapter
    • getInstanceVariable

      public IRubyObject getInstanceVariable(IRubyObject obj, String variableName)
      Specified by:
      getInstanceVariable in interface RubyObjectAdapter
    • callMethod

      public IRubyObject callMethod(IRubyObject receiver, String methodName)
      Specified by:
      callMethod in interface RubyObjectAdapter
    • callMethod

      public IRubyObject callMethod(IRubyObject receiver, String methodName, IRubyObject singleArg)
      Specified by:
      callMethod in interface RubyObjectAdapter
    • callMethod

      public IRubyObject callMethod(IRubyObject receiver, String methodName, IRubyObject[] args)
      Specified by:
      callMethod in interface RubyObjectAdapter
    • callMethod

      public IRubyObject callMethod(IRubyObject receiver, String methodName, IRubyObject[] args, Block block)
      Specified by:
      callMethod in interface RubyObjectAdapter
    • callSuper

      public IRubyObject callSuper(IRubyObject receiver, IRubyObject[] args)
      Specified by:
      callSuper in interface RubyObjectAdapter
    • callSuper

      public IRubyObject callSuper(IRubyObject receiver, IRubyObject[] args, Block block)
      Specified by:
      callSuper in interface RubyObjectAdapter
    • callMethod

      public <T> T callMethod(Object receiver, String methodName, Class<T> returnType)
      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 interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      returnType - 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 singleArg, Class<T> returnType)
      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 interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      singleArg - is an method argument
      returnType - returnType 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, 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.
      Specified by:
      callMethod in interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      args - is an array of method arguments
      returnType - 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 interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      args - is an array of method arguments except a block
      block - is a block to be executed in this method
      returnType - 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 interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      returnType - is the type we want it to convert to
      unit - 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 interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      args - is an array of method arguments
      returnType - is the type we want it to convert to
      unit - 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 interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      args - is an array of method arguments except a block
      block - is a block to be executed in this method
      returnType - is the type we want it to convert to
      unit - is parsed unit
      Returns:
      is the type we want it to convert to
    • callSuper

      public <T> T callSuper(Object receiver, Object[] args, Class<T> returnType)
      Specified by:
      callSuper in interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      args - is an array of method arguments
      returnType - is the type we want it to convert to
      Returns:
      is the type we want it to convert to
    • callSuper

      public <T> T callSuper(Object receiver, Object[] args, Block block, Class<T> returnType)
      Specified by:
      callSuper in interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      args - is an array of method arguments except a block
      block - is a block to be executed in this method
      returnType - is the type we want it to convert to
      Returns:
      is the type we want it to convert to
    • callMethod

      public Object callMethod(Object receiver, String methodName, Object... args)
      Description copied from interface: EmbedRubyObjectAdapter
      Executes a method defined in Ruby script.
      Specified by:
      callMethod in interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      args - are method arguments.
      Returns:
      an instance automatically converted from Ruby to Java
    • callMethod

      public Object callMethod(Object receiver, String methodName, Block block, Object... args)
      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 interface EmbedRubyObjectAdapter
      Parameters:
      receiver - is an instance that will receive this method call
      methodName - is a method name to be called
      block - is a block to be executed in this method
      args - 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 interface EmbedRubyObjectAdapter
      Parameters:
      returnType - is the type we want it to convert to
      receiver - 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 called
      block - is an optional Block object. Send null for no block.
      args - is an array of method arguments
      Returns:
      an instance of requested Java type