org.jruby
Class RubyObject

java.lang.Object
  extended byorg.jruby.RubyObject
All Implemented Interfaces:
java.lang.Cloneable, IRubyObject
Direct Known Subclasses:
JavaAccessibleObject, JavaObject, JavaProxyReflectionObject, MockRubyObject, RubyArgsFile, RubyArray, RubyBinding, RubyBoolean, RubyClassPathVariable, RubyDigest.Base, RubyDir, RubyEnumerator, RubyException, RubyFileStat, RubyHash, RubyIconv, RubyIO, RubyMatchData, RubyMethod, RubyModule, RubyNil, RubyNumeric, RubyProc, RubyProcess.RubyStatus, RubyRange, RubyRegexp, RubyString, RubyStringIO, RubyStringScanner, RubyStruct, RubySymbol, RubyThread, RubyThreadGroup, RubyTime, RubyZlib.RubyGzipFile, RubyZlib.ZStream, ThreadLibrary.ConditionVariable, ThreadLibrary.Mutex, ThreadLibrary.Queue

public class RubyObject
extends java.lang.Object
implements java.lang.Cloneable, IRubyObject

Author:
jpetersen

Nested Class Summary
 class RubyObject.Finalizer
           
 
Field Summary
protected  java.util.Map instanceVariables
           
protected  boolean isTrue
           
protected  RubyClass metaClass
           
static IRubyObject NEVER
           
static ObjectAllocator OBJECT_ALLOCATOR
           
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
RubyObject(Ruby runtime, RubyClass metaClass)
           
RubyObject(Ruby runtime, RubyClass metaClass, boolean useObjectSpace)
           
 
Method Summary
 void addFinalizer(RubyProc finalizer)
           
 IRubyObject anyToString()
           
 RubyString asString()
          rb_obj_as_string
 java.lang.String asSymbol()
          rb_to_id
 void attachToObjectSpace()
           
 void callInit(IRubyObject[] args, Block block)
           
 IRubyObject callMethod(ThreadContext context, int methodIndex, java.lang.String name)
           
 IRubyObject callMethod(ThreadContext context, int methodIndex, java.lang.String name, IRubyObject arg)
           
 IRubyObject callMethod(ThreadContext context, int methodIndex, java.lang.String name, IRubyObject[] args)
           
 IRubyObject callMethod(ThreadContext context, int methodIndex, java.lang.String name, IRubyObject[] args, CallType callType)
           
 IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, int methodIndex, java.lang.String name, IRubyObject[] args, CallType callType)
           
 IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, int methodIndex, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
 IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String name)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String name, Block block)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String name, IRubyObject arg)
          rb_funcall
 IRubyObject callMethod(ThreadContext context, java.lang.String name, IRubyObject[] args)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String name, IRubyObject[] args, Block block)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String name, IRubyObject[] args, CallType callType)
           
 IRubyObject callMethod(ThreadContext context, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
static IRubyObject callMethodMissingIfNecessary(ThreadContext context, IRubyObject receiver, DynamicMethod method, java.lang.String name, IRubyObject[] args, IRubyObject self, CallType callType, Block block)
           
 IRubyObject callSuper(ThreadContext context, IRubyObject[] args, Block block)
           
 IRubyObject checkArrayType()
          rb_check_array_type
protected  void checkFrozen()
           
 IRubyObject checkStringType()
          rb_check_string_type
 IRubyObject compilerCallMethod(ThreadContext context, java.lang.String name, IRubyObject[] args, IRubyObject self, CallType callType, Block block)
          Used by the compiler to handle visibility
 IRubyObject compilerCallMethodWithIndex(ThreadContext context, int methodIndex, java.lang.String name, IRubyObject[] args, IRubyObject self, CallType callType, Block block)
          Used by the compiler to ease calling indexed methods, also to handle visibility.
 RubyArray convertToArray()
          Methods which perform to_xxx if the object has such a method
 RubyFloat convertToFloat()
           
 RubyHash convertToHash()
           
 RubyInteger convertToInteger()
           
 RubyString convertToString()
           
 IRubyObject convertToType(RubyClass targetType, int convertMethodIndex, boolean raise)
           
 IRubyObject convertToType(RubyClass targetType, int convertMethodIndex, java.lang.String convertMethod, boolean raise)
          Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type).
 IRubyObject convertToType(RubyClass targetType, int convertMethodIndex, java.lang.String convertMethod, boolean raiseOnMissingMethod, boolean raiseOnWrongTypeResult, boolean allowNilThrough)
           
 IRubyObject convertToTypeWithCheck(RubyClass targetType, int convertMethodIndex, java.lang.String convertMethod)
          Higher level conversion utility similiar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).
static RubyClass createObjectClass(Ruby runtime, RubyClass objectClass)
           
 java.lang.Object dataGetStruct()
          Our version of Data_Get_Struct.
 void dataWrapStruct(java.lang.Object obj)
          Our version of Data_Wrap_Struct.
 IRubyObject display(IRubyObject[] args)
           
protected  IRubyObject doClone()
           
 IRubyObject dup()
          rb_obj_dup should be overriden only by: Proc
 boolean eql(IRubyObject other)
          rb_eql this method is not defind for Ruby objects directly.
 boolean eqlInternal(ThreadContext context, IRubyObject other)
           
 IRubyObject equal(IRubyObject other)
          rb_equal
 IRubyObject equalInternal(ThreadContext context, IRubyObject other)
           
 boolean equals(java.lang.Object other)
          This method is just a wrapper around the Ruby "==" method, provided so that RubyObjects can be used as keys in the Java HashMap object underlying RubyHash.
 IRubyObject evalSimple(ThreadContext context, IRubyObject src, java.lang.String file)
          Evaluate the given string.
 IRubyObject evalUnder(RubyModule under, IRubyObject src, IRubyObject file, IRubyObject line)
           
 IRubyObject evalWithBinding(ThreadContext context, IRubyObject src, IRubyObject scope, java.lang.String file, int lineNumber)
          Evaluate the given string under the specified binding object.
 IRubyObject extend(IRubyObject[] args)
           
 IRubyObject freeze()
          Freeze an object.
 RubyBoolean frozen()
          rb_obj_frozen_p
 IRubyObject getInstanceVariable(java.lang.String name)
          RubyMethod getInstanceVar.
 java.util.Map getInstanceVariables()
           
 java.util.Map getInstanceVariablesSnapshot()
          Returns an unmodifiable snapshot of the current state of instance variables.
 java.lang.Class getJavaClass()
          RubyMethod getJavaClass.
 RubyClass getMetaClass()
          if exist return the meta-class else return the type of the object.
 int getNativeTypeIndex()
          This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.
 Ruby getRuntime()
          Getter for property ruby.
 RubyClass getSingletonClass()
          rb_singleton_class
 RubyClass getSingletonClassClone()
          rb_singleton_class_clone
 RubyClass getType()
          RubyMethod getType.
 RubyFixnum hash()
           
 int hashCode()
           
 RubyFixnum id_deprecated()
           
 RubyFixnum id()
          Return the internal id of an object.
 IRubyObject infectBy(IRubyObject obj)
          OBJ_INFECT
 IRubyObject inherited(IRubyObject arg, Block block)
           
static void initCopy(IRubyObject clone, IRubyObject original)
          init_copy
 IRubyObject initialize_copy(IRubyObject original)
          rb_obj_init_copy
 IRubyObject initialize(IRubyObject[] args, Block block)
           
 IRubyObject inspect()
          rb_obj_inspect
 IRubyObject instance_eval(IRubyObject[] args, Block block)
           
 IRubyObject instance_exec(IRubyObject[] args, Block block)
           
 RubyBoolean instance_of(IRubyObject type)
          rb_obj_is_instance_of
 IRubyObject instance_variable_get(IRubyObject var)
           
 IRubyObject instance_variable_set(IRubyObject var, IRubyObject value)
           
 RubyArray instance_variables()
           
 java.util.Iterator instanceVariableNames()
           
 boolean isFalse()
           
 boolean isFrozen()
          Gets the frozen.
 boolean isImmediate()
           
 boolean isKindOf(RubyModule type)
          RubyMethod isKindOf.
 boolean isNil()
          RubyMethod isNil.
 boolean isSingleton()
           
 boolean isTaint()
          Gets the taint.
 boolean isTrue()
           
 RubyBoolean kind_of(IRubyObject type)
          rb_obj_is_kind_of
 RubyClass makeMetaClass(RubyClass superClass, SinglyLinkedList parentCRef)
          Create a new meta class.
 IRubyObject match(IRubyObject arg)
           
 IRubyObject method(IRubyObject symbol)
           
 IRubyObject methods(IRubyObject[] args)
          rb_obj_methods
 IRubyObject nil_p()
           
 IRubyObject obj_equal(IRubyObject obj)
          rb_obj_equal
 IRubyObject private_methods(IRubyObject[] args)
          rb_obj_private_methods
 IRubyObject protected_methods(IRubyObject[] args)
          rb_obj_protected_methods
 IRubyObject public_methods(IRubyObject[] args)
           
static void puts(java.lang.Object obj)
           
 IRubyObject rbClone(Block unusedBlock)
          rb_obj_clone should be overriden only by: Proc, Method, UnboundedMethod, Binding
 IRubyObject remove_instance_variable(IRubyObject name, Block block)
           
 void removeFinalizers()
           
 IRubyObject removeInstanceVariable(java.lang.String name)
           
 RubyBoolean respond_to(IRubyObject[] args)
          respond_to?( aSymbol, includePriv=false ) -> true or false Returns true if this object responds to the given method.
 boolean respondsTo(java.lang.String name)
          RubyMethod respondsTo.
 java.util.Map safeGetInstanceVariables()
          Gets a copy of the instance variables for this object, if any exist.
 boolean safeHasInstanceVariables()
          Returns true if the object has any instance variables, false otherwise.
 IRubyObject send(IRubyObject[] args, Block block)
          send( aSymbol [, args ]* ) -> anObject Invokes the method identified by aSymbol, passing it any arguments specified.
 void setFrozen(boolean frozen)
          Sets the frozen.
 IRubyObject setInstanceVariable(java.lang.String name, IRubyObject value)
          rb_iv_set / rb_ivar_set
 IRubyObject setInstanceVariable(java.lang.String name, IRubyObject value, java.lang.String taintError, java.lang.String freezeError)
           
 void setInstanceVariables(java.util.Map instanceVariables)
           
 void setMetaClass(RubyClass metaClass)
           
 void setTaint(boolean taint)
          Sets the taint.
 RubyArray singleton_methods(IRubyObject[] args)
          rb_obj_singleton_methods
 IRubyObject specificEval(RubyModule mod, IRubyObject[] args, Block block)
          specific_eval
 IRubyObject taint()
          rb_obj_taint
 RubyBoolean tainted()
          rb_obj_tainted
protected  void testFrozen(java.lang.String message)
          rb_frozen_class_p
 IRubyObject to_s()
           
 java.lang.String toString()
           
static java.lang.String trueFalseNil(IRubyObject v)
           
static java.lang.String trueFalseNil(java.lang.String v)
           
 RubyClass type_deprecated()
           
 RubyClass type()
          rb_obj_type
 IRubyObject untaint()
          rb_obj_untaint
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NEVER

public static final IRubyObject NEVER

metaClass

protected RubyClass metaClass

instanceVariables

protected java.util.Map instanceVariables

isTrue

protected boolean isTrue

OBJECT_ALLOCATOR

public static ObjectAllocator OBJECT_ALLOCATOR
Constructor Detail

RubyObject

public RubyObject(Ruby runtime,
                  RubyClass metaClass)

RubyObject

public RubyObject(Ruby runtime,
                  RubyClass metaClass,
                  boolean useObjectSpace)
Method Detail

createObjectClass

public static RubyClass createObjectClass(Ruby runtime,
                                          RubyClass objectClass)

attachToObjectSpace

public void attachToObjectSpace()

getNativeTypeIndex

public int getNativeTypeIndex()
This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.

Specified by:
getNativeTypeIndex in interface IRubyObject
Returns:
the ClassIndex of the native type this object was constructed from

isImmediate

public boolean isImmediate()
Specified by:
isImmediate in interface IRubyObject
Returns:

makeMetaClass

public RubyClass makeMetaClass(RubyClass superClass,
                               SinglyLinkedList parentCRef)
Create a new meta class.

Since:
Ruby 1.6.7

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface IRubyObject
Returns:

getJavaClass

public java.lang.Class getJavaClass()
Description copied from interface: IRubyObject
RubyMethod getJavaClass.

Specified by:
getJavaClass in interface IRubyObject
Returns:
Class

puts

public static void puts(java.lang.Object obj)

equals

public boolean equals(java.lang.Object other)
This method is just a wrapper around the Ruby "==" method, provided so that RubyObjects can be used as keys in the Java HashMap object underlying RubyHash.


toString

public java.lang.String toString()

getRuntime

public Ruby getRuntime()
Getter for property ruby.

Specified by:
getRuntime in interface IRubyObject
Returns:
Value of property ruby.

safeHasInstanceVariables

public boolean safeHasInstanceVariables()
Description copied from interface: IRubyObject
Returns true if the object has any instance variables, false otherwise. "safe" in that it doesn't cause the instance var map to be created.

Specified by:
safeHasInstanceVariables in interface IRubyObject
Returns:
true if the object has instance variables, false otherwise.

safeGetInstanceVariables

public java.util.Map safeGetInstanceVariables()
Description copied from interface: IRubyObject
Gets a copy of the instance variables for this object, if any exist. Returns null if this object has no instance variables. "safe" in that it doesn't cause the instance var map to be created.

Specified by:
safeGetInstanceVariables in interface IRubyObject
Returns:
A snapshot of the instance vars, or null if none.

removeInstanceVariable

public IRubyObject removeInstanceVariable(java.lang.String name)

getInstanceVariablesSnapshot

public java.util.Map getInstanceVariablesSnapshot()
Returns an unmodifiable snapshot of the current state of instance variables. This method synchronizes access to avoid deadlocks.

Specified by:
getInstanceVariablesSnapshot in interface IRubyObject
Returns:

getInstanceVariables

public java.util.Map getInstanceVariables()
Specified by:
getInstanceVariables in interface IRubyObject
Returns:

setInstanceVariables

public void setInstanceVariables(java.util.Map instanceVariables)
Specified by:
setInstanceVariables in interface IRubyObject
Parameters:
instanceVariables -

getMetaClass

public final RubyClass getMetaClass()
if exist return the meta-class else return the type of the object.

Specified by:
getMetaClass in interface IRubyObject
Returns:

setMetaClass

public void setMetaClass(RubyClass metaClass)
Specified by:
setMetaClass in interface IRubyObject
Parameters:
metaClass -

isFrozen

public boolean isFrozen()
Gets the frozen.

Specified by:
isFrozen in interface IRubyObject
Returns:
Returns a boolean

setFrozen

public void setFrozen(boolean frozen)
Sets the frozen.

Specified by:
setFrozen in interface IRubyObject
Parameters:
frozen - The frozen to set

testFrozen

protected void testFrozen(java.lang.String message)
rb_frozen_class_p


checkFrozen

protected void checkFrozen()

isTaint

public boolean isTaint()
Gets the taint.

Specified by:
isTaint in interface IRubyObject
Returns:
Returns a boolean

setTaint

public void setTaint(boolean taint)
Sets the taint.

Specified by:
setTaint in interface IRubyObject
Parameters:
taint - The taint to set

isNil

public boolean isNil()
Description copied from interface: IRubyObject
RubyMethod isNil.

Specified by:
isNil in interface IRubyObject
Returns:
boolean

isTrue

public final boolean isTrue()
Specified by:
isTrue in interface IRubyObject
Returns:

isFalse

public final boolean isFalse()

respondsTo

public boolean respondsTo(java.lang.String name)
Description copied from interface: IRubyObject
RubyMethod respondsTo.

Specified by:
respondsTo in interface IRubyObject
Parameters:
name -
Returns:
boolean

isKindOf

public boolean isKindOf(RubyModule type)
Description copied from interface: IRubyObject
RubyMethod isKindOf.

Specified by:
isKindOf in interface IRubyObject
Parameters:
type -
Returns:
boolean

getSingletonClass

public RubyClass getSingletonClass()
rb_singleton_class

Specified by:
getSingletonClass in interface IRubyObject
Returns:
RubyClass

getSingletonClassClone

public RubyClass getSingletonClassClone()
rb_singleton_class_clone


initCopy

public static void initCopy(IRubyObject clone,
                            IRubyObject original)
init_copy


infectBy

public IRubyObject infectBy(IRubyObject obj)
OBJ_INFECT

Specified by:
infectBy in interface IRubyObject
Parameters:
obj -
Returns:

callSuper

public IRubyObject callSuper(ThreadContext context,
                             IRubyObject[] args,
                             Block block)
Specified by:
callSuper in interface IRubyObject
Parameters:
context -
args -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name,
                              IRubyObject[] args)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
name -
args -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name,
                              IRubyObject[] args,
                              Block block)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
name -
args -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
name -
args -
callType -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType,
                              Block block)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
name -
args -
callType -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject arg)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
methodIndex -
name -
arg -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject[] args)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
methodIndex -
name -
args -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
methodIndex -
name -
args -
callType -
Returns:

compilerCallMethodWithIndex

public IRubyObject compilerCallMethodWithIndex(ThreadContext context,
                                               int methodIndex,
                                               java.lang.String name,
                                               IRubyObject[] args,
                                               IRubyObject self,
                                               CallType callType,
                                               Block block)
Used by the compiler to ease calling indexed methods, also to handle visibility. NOTE: THIS IS NOT THE SAME AS THE SWITCHVALUE VERSIONS.

Specified by:
compilerCallMethodWithIndex in interface IRubyObject
Parameters:
context -
methodIndex -
name -
args -
self -
callType -
block -
Returns:

compilerCallMethod

public IRubyObject compilerCallMethod(ThreadContext context,
                                      java.lang.String name,
                                      IRubyObject[] args,
                                      IRubyObject self,
                                      CallType callType,
                                      Block block)
Used by the compiler to handle visibility

Specified by:
compilerCallMethod in interface IRubyObject
Parameters:
context -
name -
args -
self -
callType -
block -
Returns:

callMethodMissingIfNecessary

public static IRubyObject callMethodMissingIfNecessary(ThreadContext context,
                                                       IRubyObject receiver,
                                                       DynamicMethod method,
                                                       java.lang.String name,
                                                       IRubyObject[] args,
                                                       IRubyObject self,
                                                       CallType callType,
                                                       Block block)

callMethod

public IRubyObject callMethod(ThreadContext context,
                              RubyModule rubyclass,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType)

callMethod

public IRubyObject callMethod(ThreadContext context,
                              RubyModule rubyclass,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType,
                              Block block)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
rubyclass -
methodIndex -
name -
args -
callType -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              RubyModule rubyclass,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType,
                              Block block)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
rubyclass -
name -
args -
callType -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
name -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              int methodIndex,
                              java.lang.String name)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
name -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name,
                              Block block)
Specified by:
callMethod in interface IRubyObject
Parameters:
context -
name -
block -
Returns:

callMethod

public IRubyObject callMethod(ThreadContext context,
                              java.lang.String name,
                              IRubyObject arg)
rb_funcall

Specified by:
callMethod in interface IRubyObject
Parameters:
context -
name -
arg -
Returns:

instance_variable_get

public IRubyObject instance_variable_get(IRubyObject var)

getInstanceVariable

public IRubyObject getInstanceVariable(java.lang.String name)
Description copied from interface: IRubyObject
RubyMethod getInstanceVar.

Specified by:
getInstanceVariable in interface IRubyObject
Parameters:
name -
Returns:
RubyObject

instance_variable_set

public IRubyObject instance_variable_set(IRubyObject var,
                                         IRubyObject value)

setInstanceVariable

public IRubyObject setInstanceVariable(java.lang.String name,
                                       IRubyObject value,
                                       java.lang.String taintError,
                                       java.lang.String freezeError)

setInstanceVariable

public IRubyObject setInstanceVariable(java.lang.String name,
                                       IRubyObject value)
rb_iv_set / rb_ivar_set

Specified by:
setInstanceVariable in interface IRubyObject
Parameters:
name -
value -
Returns:
RubyObject

instanceVariableNames

public java.util.Iterator instanceVariableNames()
Specified by:
instanceVariableNames in interface IRubyObject
Returns:

callInit

public void callInit(IRubyObject[] args,
                     Block block)

asSymbol

public java.lang.String asSymbol()
rb_to_id

Specified by:
asSymbol in interface IRubyObject
Returns:
String the symbol name

trueFalseNil

public static java.lang.String trueFalseNil(IRubyObject v)

trueFalseNil

public static java.lang.String trueFalseNil(java.lang.String v)

convertToArray

public RubyArray convertToArray()
Description copied from interface: IRubyObject
Methods which perform to_xxx if the object has such a method

Specified by:
convertToArray in interface IRubyObject
Returns:

convertToHash

public RubyHash convertToHash()
Specified by:
convertToHash in interface IRubyObject
Returns:

convertToFloat

public RubyFloat convertToFloat()
Specified by:
convertToFloat in interface IRubyObject
Returns:

convertToInteger

public RubyInteger convertToInteger()
Specified by:
convertToInteger in interface IRubyObject
Returns:

convertToString

public RubyString convertToString()
Specified by:
convertToString in interface IRubyObject
Returns:

convertToTypeWithCheck

public IRubyObject convertToTypeWithCheck(RubyClass targetType,
                                          int convertMethodIndex,
                                          java.lang.String convertMethod)
Description copied from interface: IRubyObject
Higher level conversion utility similiar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).

Specified by:
convertToTypeWithCheck in interface IRubyObject
Parameters:
targetType - is the type we are trying to convert to
convertMethod - is the method to be called to try and convert to targeType
Returns:
the converted value

convertToType

public IRubyObject convertToType(RubyClass targetType,
                                 int convertMethodIndex,
                                 java.lang.String convertMethod,
                                 boolean raise)
Description copied from interface: IRubyObject
Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type).

Specified by:
convertToType in interface IRubyObject
Parameters:
targetType - is the type we are trying to convert to
convertMethod - is the method to be called to try and convert to targeType
raise - will throw an Error if conversion does not work
Returns:
the converted value

convertToType

public IRubyObject convertToType(RubyClass targetType,
                                 int convertMethodIndex,
                                 boolean raise)

convertToType

public IRubyObject convertToType(RubyClass targetType,
                                 int convertMethodIndex,
                                 java.lang.String convertMethod,
                                 boolean raiseOnMissingMethod,
                                 boolean raiseOnWrongTypeResult,
                                 boolean allowNilThrough)
Specified by:
convertToType in interface IRubyObject
Parameters:
targetType -
convertMethod -
raiseOnMissingMethod -
raiseOnWrongTypeResult -
allowNilThrough -
Returns:

asString

public RubyString asString()
rb_obj_as_string

Specified by:
asString in interface IRubyObject
Returns:

checkStringType

public IRubyObject checkStringType()
rb_check_string_type

Specified by:
checkStringType in interface IRubyObject
Returns:

checkArrayType

public IRubyObject checkArrayType()
rb_check_array_type

Specified by:
checkArrayType in interface IRubyObject
Returns:

specificEval

public IRubyObject specificEval(RubyModule mod,
                                IRubyObject[] args,
                                Block block)
specific_eval


evalUnder

public IRubyObject evalUnder(RubyModule under,
                             IRubyObject src,
                             IRubyObject file,
                             IRubyObject line)

evalWithBinding

public IRubyObject evalWithBinding(ThreadContext context,
                                   IRubyObject src,
                                   IRubyObject scope,
                                   java.lang.String file,
                                   int lineNumber)
Description copied from interface: IRubyObject
Evaluate the given string under the specified binding object. If the binding is not a Proc or Binding object (RubyProc or RubyBinding) throw an appropriate type error.

Specified by:
evalWithBinding in interface IRubyObject
Parameters:
context - TODO
src - The string containing the text to be evaluated
scope - The binding object under which to perform the evaluation
file - The filename to use when reporting errors during the evaluation
lineNumber - is the line number to pretend we are starting from
Returns:
An IRubyObject result from the evaluation

evalSimple

public IRubyObject evalSimple(ThreadContext context,
                              IRubyObject src,
                              java.lang.String file)
Description copied from interface: IRubyObject
Evaluate the given string.

Specified by:
evalSimple in interface IRubyObject
Parameters:
context - TODO
src - The string containing the text to be evaluated
file - The filename to use when reporting errors during the evaluation
Returns:
An IRubyObject result from the evaluation

obj_equal

public IRubyObject obj_equal(IRubyObject obj)
rb_obj_equal


equal

public IRubyObject equal(IRubyObject other)
rb_equal

Specified by:
equal in interface IRubyObject

equalInternal

public final IRubyObject equalInternal(ThreadContext context,
                                       IRubyObject other)
Specified by:
equalInternal in interface IRubyObject

eql

public boolean eql(IRubyObject other)
rb_eql this method is not defind for Ruby objects directly. notably overriden by RubyFixnum, RubyString, RubySymbol - these do a short-circuit calls. see: rb_any_cmp() in hash.c do not confuse this method with eql_p methods (which it calls by default), eql is mainly used for hash key comparison

Specified by:
eql in interface IRubyObject

eqlInternal

public final boolean eqlInternal(ThreadContext context,
                                 IRubyObject other)
Specified by:
eqlInternal in interface IRubyObject

initialize_copy

public IRubyObject initialize_copy(IRubyObject original)
rb_obj_init_copy


respond_to

public RubyBoolean respond_to(IRubyObject[] args)
respond_to?( aSymbol, includePriv=false ) -> true or false Returns true if this object responds to the given method. Private methods are included in the search only if the optional second parameter evaluates to true.

Returns:
true if this responds to the given method

id

public RubyFixnum id()
Return the internal id of an object. CRuby function: rb_obj_id

Specified by:
id in interface IRubyObject
Returns:

id_deprecated

public RubyFixnum id_deprecated()

hash

public RubyFixnum hash()

hashCode

public int hashCode()

type

public RubyClass type()
rb_obj_type


type_deprecated

public RubyClass type_deprecated()

rbClone

public IRubyObject rbClone(Block unusedBlock)
rb_obj_clone should be overriden only by: Proc, Method, UnboundedMethod, Binding

Specified by:
rbClone in interface IRubyObject
Returns:
IRubyObject

doClone

protected IRubyObject doClone()

display

public IRubyObject display(IRubyObject[] args)

dup

public IRubyObject dup()
rb_obj_dup should be overriden only by: Proc

Specified by:
dup in interface IRubyObject
Returns:

tainted

public RubyBoolean tainted()
rb_obj_tainted


taint

public IRubyObject taint()
rb_obj_taint


untaint

public IRubyObject untaint()
rb_obj_untaint


freeze

public IRubyObject freeze()
Freeze an object. rb_obj_freeze


frozen

public RubyBoolean frozen()
rb_obj_frozen_p


inspect

public IRubyObject inspect()
rb_obj_inspect

Specified by:
inspect in interface IRubyObject
Returns:
String

instance_of

public RubyBoolean instance_of(IRubyObject type)
rb_obj_is_instance_of


instance_variables

public RubyArray instance_variables()

kind_of

public RubyBoolean kind_of(IRubyObject type)
rb_obj_is_kind_of


methods

public IRubyObject methods(IRubyObject[] args)
rb_obj_methods


public_methods

public IRubyObject public_methods(IRubyObject[] args)

protected_methods

public IRubyObject protected_methods(IRubyObject[] args)
rb_obj_protected_methods


private_methods

public IRubyObject private_methods(IRubyObject[] args)
rb_obj_private_methods


singleton_methods

public RubyArray singleton_methods(IRubyObject[] args)
rb_obj_singleton_methods


method

public IRubyObject method(IRubyObject symbol)

anyToString

public IRubyObject anyToString()
Specified by:
anyToString in interface IRubyObject
Returns:

to_s

public IRubyObject to_s()

instance_eval

public IRubyObject instance_eval(IRubyObject[] args,
                                 Block block)

instance_exec

public IRubyObject instance_exec(IRubyObject[] args,
                                 Block block)

extend

public IRubyObject extend(IRubyObject[] args)

inherited

public IRubyObject inherited(IRubyObject arg,
                             Block block)

initialize

public IRubyObject initialize(IRubyObject[] args,
                              Block block)

send

public IRubyObject send(IRubyObject[] args,
                        Block block)
send( aSymbol [, args ]* ) -> anObject Invokes the method identified by aSymbol, passing it any arguments specified. You can use __send__ if the name send clashes with an existing method in this object.
 class Klass
   def hello(*args)
     "Hello " + args.join(' ')
   end
 end

 k = Klass.new
 k.send :hello, "gentle", "readers"
 

Returns:
the result of invoking the method identified by aSymbol.

nil_p

public IRubyObject nil_p()

match

public IRubyObject match(IRubyObject arg)

remove_instance_variable

public IRubyObject remove_instance_variable(IRubyObject name,
                                            Block block)

getType

public RubyClass getType()
Description copied from interface: IRubyObject
RubyMethod getType.

Specified by:
getType in interface IRubyObject
Returns:
RubyClass
See Also:
IRubyObject.getType()

dataWrapStruct

public void dataWrapStruct(java.lang.Object obj)
Description copied from interface: IRubyObject
Our version of Data_Wrap_Struct. This method will just set a private pointer to the object provided. This pointer is transient and will not be accessible from Ruby.

Specified by:
dataWrapStruct in interface IRubyObject
Parameters:
obj - the object to wrap
See Also:
org.jruby.runtime.builtin.IRubyObject#dataWrapStruct()

dataGetStruct

public java.lang.Object dataGetStruct()
Description copied from interface: IRubyObject
Our version of Data_Get_Struct. Returns a wrapped data value if there is one, otherwise returns null.

Specified by:
dataGetStruct in interface IRubyObject
Returns:
the object wrapped.
See Also:
IRubyObject.dataGetStruct()

addFinalizer

public void addFinalizer(RubyProc finalizer)
Specified by:
addFinalizer in interface IRubyObject

removeFinalizers

public void removeFinalizers()
Specified by:
removeFinalizers in interface IRubyObject


Copyright © 2002-2007 JRuby Team. All Rights Reserved.