Class TransientLocalVariable

java.lang.Object
org.jruby.embed.variable.TransientLocalVariable
All Implemented Interfaces:
BiVariable

public class TransientLocalVariable extends Object
An implementation of BiVariable for a transient local variable. This type of a local variable is available during only one evaluation. After the evaluation, the variable vanishes.
Author:
Yoko Harada <yokolet@gmail.com>
  • Field Details Link icon

    • receiver Link icon

      protected final IRubyObject receiver
    • name Link icon

      protected final String name
    • javaObject Link icon

      protected volatile Object javaObject
    • javaType Link icon

      protected volatile Class javaType
    • rubyObject Link icon

      protected volatile IRubyObject rubyObject
    • fromRuby Link icon

      protected volatile boolean fromRuby
  • Method Details Link icon

    • getInstance Link icon

      public static BiVariable getInstance(RubyObject receiver, String name, Object... javaObject)
      Returns an instance of this class. This factory method is used when a transient local variable is put in BiVariableMap.
      Parameters:
      receiver - receiver object returned when a script is evaluated.
      name - a variable name
      javaObject - Java object that should be assigned to.
      Returns:
      the instance of TransientLocalVariable
    • getType Link icon

      public BiVariable.Type getType()
      Returns enum type of this variable defined in BiVariable.
      Returns:
      this enum type, BiVariable.Type.LocalVariable.
    • isValidName Link icon

      public static boolean isValidName(Object name)
      Returns true if the given name is a decent Ruby local variable. Unless returns false.
      Parameters:
      name - is a name to be checked.
      Returns:
      true if the given name is of a Ruby local variable.
    • retrieve Link icon

      public static void retrieve(RubyObject receiver, BiVariableMap vars)
      Doesn't do anything since a transient local variable should not be retrieved from Ruby.
      Parameters:
      receiver - receiver object returned when a script is evaluated.
      vars - map to save retrieved local variables.
    • inject Link icon

      public void inject()
      Injects a local variable value to a parsed Ruby script. This method is invoked during EvalUnit#run() is executed.
    • remove Link icon

      public void remove()
      Attempts to remove this variable from top self or receiver.
    • updateByJavaObject Link icon

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

      protected void updateRubyObject(IRubyObject rubyObject)
    • getReceiver Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      protected static RubyModule getRubyClass(Ruby runtime)
    • isValidName Link icon

      protected static boolean isValidName(String pattern, Object name)