Class AbstractVariable

java.lang.Object
org.jruby.embed.variable.AbstractVariable
All Implemented Interfaces:
BiVariable
Direct Known Subclasses:
Argv, ClassVariable, Constant, GlobalVariable, InstanceVariable, PersistentLocalVariable, TransientLocalVariable

abstract class AbstractVariable extends Object implements BiVariable
  • Field Details

    • receiver

      protected final IRubyObject receiver
    • name

      protected final String name
    • javaObject

      protected Object javaObject
    • javaType

      protected Class javaType
    • rubyObject

      protected IRubyObject rubyObject
    • fromRuby

      protected boolean fromRuby
  • Constructor Details

    • AbstractVariable

      protected AbstractVariable(IRubyObject receiver, String name, boolean fromRuby)
      Constructor used when this variable is originaed from Java.
      Parameters:
      runtime -
      name -
      fromRuby -
      values -
    • AbstractVariable

      protected AbstractVariable(IRubyObject receiver, String name, boolean fromRuby, IRubyObject rubyObject)
      Constructor when the variable is originated from Ruby.
      Parameters:
      receiver - a receiver object that this variable/constant is originally in. When the variable/constant is originated from Ruby, receiver may not be null.
      name -
      fromRuby -
      rubyObject -
  • Method Details

    • getRuntime

      final Ruby getRuntime()
    • getCurrentContext

      final ThreadContext getCurrentContext()
    • getTopSelf

      final RubyObject getTopSelf()
    • getTopSelf

      static RubyObject getTopSelf(IRubyObject receiver)
    • updateByJavaObject

      protected void updateByJavaObject(Ruby runtime, Object... values)
    • updateRubyObject

      protected void updateRubyObject(IRubyObject rubyObject)
    • getReceiver

      public IRubyObject getReceiver()
      Description copied from interface: BiVariable
      Returns the original receiver where this variable has been retrieved.
      Specified by:
      getReceiver in interface BiVariable
      Returns:
      an original receiver.
    • isReceiverIdentical

      public boolean isReceiverIdentical(RubyObject receiver)
      Returns true if a given receiver is identical to the receiver this object has.
      Specified by:
      isReceiverIdentical in interface BiVariable
      Returns:
      true if identical otherwise false
    • getName

      public String getName()
      Description copied from interface: BiVariable
      Returns a name of the variable this object holds. The name follows Ruby's naming rule.
      Specified by:
      getName in interface BiVariable
      Returns:
      a name of the variable
    • getJavaObject

      public Object getJavaObject()
      Description copied from interface: BiVariable
      Returns a value of the variable this object holds in Java type.
      Specified by:
      getJavaObject in interface BiVariable
      Returns:
      a value in Java type.
    • setJavaObject

      public void setJavaObject(Ruby runtime, Object javaObject)
      Description copied from interface: BiVariable
      Sets a Java object as a value of this object. At the same time, an equivalent Ruby object is set automatically.
      Specified by:
      setJavaObject in interface BiVariable
      Parameters:
      runtime - is used to convert a Java object to Ruby object.
      javaObject - is a variable value to be set.
    • getRubyObject

      public IRubyObject getRubyObject()
      Description copied from interface: BiVariable
      Returns a value of the variable this object holds in a org.jruby.runtime.builtin.IRubyObject type.
      Specified by:
      getRubyObject in interface BiVariable
      Returns:
      a value in IRubyObject type.
    • setRubyObject

      public void setRubyObject(IRubyObject rubyObject)
      Description copied from interface: BiVariable
      Sets a org.jruby.runtime.builtin.IRubyObject type, Ruby object as a value of this object. At the same time, an equivalent Java object is set automatically.
      Specified by:
      setRubyObject in interface BiVariable
      Parameters:
      rubyObject - is a variable value to be set.
    • getRubyClass

      protected static RubyModule getRubyClass(Ruby runtime)
    • isValidName

      protected static boolean isValidName(String pattern, Object name)