Top Fields Constructors Methods
org.jruby.util

public Class TypeConverter

extends Object
Class Inheritance
Imports
org.jruby.Ruby, .RubyBasicObject, .RubyArray, .RubyBoolean, .RubyClass, .RubyEncoding, .RubyFixnum, .RubyFloat, .RubyHash, .RubyIO, .RubyInteger, .RubyModule, .RubyNumeric, .RubyString, .RubySymbol, org.jruby.api.Check, .Convert, org.jruby.exceptions.RaiseException, org.jruby.java.proxies.JavaProxy, org.jruby.runtime.ClassIndex, .JavaSites, .JavaSites.TypeConverterSites, .ThreadContext, org.jruby.runtime.builtin.IRubyObject

Field Summary

Modifier and TypeField and Description
private static final String[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
checkArrayType(IRubyObject obj)
Deprecated

public static IRubyObject

Returns:

the converted value
checkData
(IRubyObject
the object to check
obj
)
Deprecated

Checks that this object is of type DATA and then returns it, otherwise raises failure (MRI: Check_Type(obj, T_DATA))

public static IRubyObject
public static IRubyObject
public static IRubyObject
checkHashType(Ruby runtime, IRubyObject obj, boolean raise)

public static IRubyObject
public static RubySymbol
checkID(IRubyObject obj)
Deprecated since 10.0.

public static RubySymbol
checkID(Ruby runtime, String name)
Deprecated since 10.0.

Convert the supplied object into an internal identifier String.

public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
checkToInteger(ThreadContext context, IRubyObject obj)
Deprecated

public static IRubyObject
checkToInteger(Ruby runtime, IRubyObject obj, String method)
Deprecated

public static void
public static String
public static IRubyObject
convertToInteger(ThreadContext context, IRubyObject val, int base, boolean exception)

public static IRubyObject
convertToInteger(ThreadContext context, IRubyObject val, int base)

public static IRubyObject

Returns:

the converted value
convertToType
(IRubyObject
the object to convert
obj
,
RubyClass
is the type we are trying to convert to
target
,
String
is the method to be called to try and convert to target type
convertMethod
,
boolean
will throw an Error if conversion does not work
raise
)

Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type).

public static IRubyObject
convertToType(ThreadContext context, IRubyObject obj, RubyClass target, String convertMethod, boolean raise)

public static IRubyObject

Returns:

the converted value
convertToType
(ThreadContext context, IRubyObject
the object to convert
obj
,
RubyClass
is the type we are trying to convert to
target
,
JavaSites.CheckedSites
is the CheckedSites call sites to be called to try and convert to targetType
sites
,
boolean
will throw an Error if conversion does not work
raise
)

Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type 1.9).

public static IRubyObject

Returns:

the converted value
convertToType
(IRubyObject
the object to convert
obj
,
RubyClass
is the type we are trying to convert to
target
,
String
is the method to be called to try and convert to targeType
convertMethod
)

Converts this object to type 'targetType' using 'convertMethod' method and raises TypeError exception on failure (MRI: rb_convert_type).

public static IRubyObject

Returns:

the converted value
convertToType
(ThreadContext context, IRubyObject
the object to convert
obj
,
RubyClass
is the type we are trying to convert to
target
,
JavaSites.CheckedSites
is the CheckedSites call sites to use to dispatch the convert method
sites
)

Converts this object to type 'targetType' using 'convertMethod' method and raises TypeError exception on failure (MRI: rb_convert_type).

public static IRubyObject
convertToType(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod, boolean raise)
Deprecated

public static IRubyObject
convertToType(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod)
Deprecated

public static IRubyObject

Returns:

the converted value
convertToTypeOrRaise
(IRubyObject
the object to convert
obj
,
RubyClass
is the type we are trying to convert to
target
,
String
is the method to be called to try and convert to targeType
convertMethod
)
Deprecated

Higher level conversion utility similar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).

public static IRubyObject
convertToTypeUnchecked(ThreadContext context, IRubyObject obj, RubyClass target, String convertMethod, boolean raise)

public static IRubyObject

Returns:

the converted value
convertToTypeWithCheck
(IRubyObject
the object to convert
obj
,
RubyClass
is the type we are trying to convert to
target
,
String
is the method to be called to try and convert to targeType
convertMethod
)

Higher level conversion utility similar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).

public static IRubyObject

Returns:

the converted value
convertToTypeWithCheck
(ThreadContext context, IRubyObject
the object to convert
obj
,
RubyClass
is the type we are trying to convert to
target
,
JavaSites.CheckedSites
the CheckedSites call sites to use for coersion
sites
)

Higher level conversion utility similar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).

public static IRubyObject
convertToTypeWithCheck(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod)
Deprecated

public static IRubyObject
handleImplicitlyUncoercibleObject(boolean raise, IRubyObject obj, RubyClass target)
Deprecated

public static IRubyObject
handleUncoercibleObject(boolean raise, IRubyObject obj, RubyClass target)

public static IRubyObject
handleUncoercibleObject(Ruby runtime, IRubyObject obj, RubyClass target, boolean raise)

public static IRubyObject
ioCheckIO(Ruby runtime, IRubyObject obj)

public static RubyIO
ioGetIO(Ruby runtime, IRubyObject obj)

private static boolean
public static RaiseException
newTypeError(IRubyObject obj, RubyClass target, String convertMethod, IRubyObject val)

public static RaiseException
newTypeError(Ruby runtime, IRubyObject obj, RubyClass target, String methodName, IRubyObject val)

public static RaiseException
newTypeErrorMismatch(Ruby runtime, IRubyObject obj, RubyClass target, String methodName, IRubyObject val)

private static IRubyObject
raiseIntegerBaseError(ThreadContext context, boolean exception)

public static RubyArray<T extends IRubyObject>
public static JavaSites.TypeConverterSites
public static RubyArray<T extends IRubyObject>
public static RubyFloat
toFloat(Ruby runtime, IRubyObject obj)

public static RubyString
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

IMPLICIT_CONVERTED_METHODSback to summary
private static final String[] IMPLICIT_CONVERTED_METHODS

Constructor Detail

TypeConverterback to summary
public TypeConverter()

Method Detail

booleanExpectedback to summary
public static boolean booleanExpected(ThreadContext context, IRubyObject object, String id)
checkArrayTypeback to summary
public static IRubyObject checkArrayType(Ruby runtime, IRubyObject obj)
checkArrayTypeback to summary
public static IRubyObject checkArrayType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj)
checkArrayTypeback to summary
public static IRubyObject checkArrayType(ThreadContext context, IRubyObject obj)
checkArrayTypeback to summary
public static IRubyObject checkArrayType(IRubyObject obj)

Deprecated

Annotations
@Deprecated
checkDataback to summary
public static IRubyObject checkData(IRubyObject obj)

Deprecated

Checks that this object is of type DATA and then returns it, otherwise raises failure (MRI: Check_Type(obj, T_DATA))

Parameters
obj:IRubyObject

the object to check

Returns:IRubyObject

the converted value

Annotations
@Deprecated
checkFloatTypeback to summary
public static IRubyObject checkFloatType(Ruby runtime, IRubyObject obj)
checkHashTypeback to summary
public static IRubyObject checkHashType(Ruby runtime, IRubyObject obj)
checkHashTypeback to summary
public static IRubyObject checkHashType(Ruby runtime, IRubyObject obj, boolean raise)
checkHashTypeback to summary
public static IRubyObject checkHashType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj)
checkIDback to summary
public static RubySymbol checkID(IRubyObject obj)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
checkIDback to summary
public static RubySymbol checkID(Ruby runtime, String name)

Deprecated

since 10.0.

Convert the supplied object into an internal identifier String. Basically, symbols are stored internally as raw bytes from whatever encoding they were originally sourced from. When methods are stored they must also get stored in this same raw fashion so that if we use symbols to look up methods or make symbols from these method names they will match up. For 2.2 compatibility, we also force all incoming identifiers to get anchored as hard-referenced symbols.

Annotations
@Deprecated
since:10.0
checkIntegerTypeback to summary
public static IRubyObject checkIntegerType(ThreadContext context, IRubyObject obj)
checkStringTypeback to summary
public static IRubyObject checkStringType(Ruby runtime, IRubyObject obj)
checkStringTypeback to summary
public static IRubyObject checkStringType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj)
checkStringTypeback to summary
public static IRubyObject checkStringType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj, RubyClass target)
checkToIntegerback to summary
public static IRubyObject checkToInteger(ThreadContext context, IRubyObject obj)

Deprecated

Annotations
@Deprecated
checkToIntegerback to summary
public static IRubyObject checkToInteger(Ruby runtime, IRubyObject obj, String method)

Deprecated

Annotations
@Deprecated
checkTypeback to summary
public static void checkType(ThreadContext context, IRubyObject x, final RubyModule type)
convertToIdentifierback to summary
public static String convertToIdentifier(IRubyObject obj)

Deprecated

Annotations
@Deprecated
convertToIntegerback to summary
public static IRubyObject convertToInteger(ThreadContext context, IRubyObject val, int base, boolean exception)
convertToIntegerback to summary
public static IRubyObject convertToInteger(ThreadContext context, IRubyObject val, int base)
convertToTypeback to summary
public static IRubyObject convertToType(IRubyObject obj, RubyClass target, String convertMethod, boolean raise)

Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type).

Parameters
obj:IRubyObject

the object to convert

target:RubyClass

is the type we are trying to convert to

convertMethod:String

is the method to be called to try and convert to target type

raise:boolean

will throw an Error if conversion does not work

Returns:IRubyObject

the converted value

convertToTypeback to summary
public static IRubyObject convertToType(ThreadContext context, IRubyObject obj, RubyClass target, String convertMethod, boolean raise)
convertToTypeback to summary
public static IRubyObject convertToType(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites, boolean raise)

Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type 1.9).

Parameters
obj:IRubyObject

the object to convert

target:RubyClass

is the type we are trying to convert to

sites:JavaSites.CheckedSites

is the CheckedSites call sites to be called to try and convert to targetType

raise:boolean

will throw an Error if conversion does not work

Returns:IRubyObject

the converted value

convertToTypeback to summary
public static IRubyObject convertToType(IRubyObject obj, RubyClass target, String convertMethod)

Converts this object to type 'targetType' using 'convertMethod' method and raises TypeError exception on failure (MRI: rb_convert_type).

Parameters
obj:IRubyObject

the object to convert

target:RubyClass

is the type we are trying to convert to

convertMethod:String

is the method to be called to try and convert to targeType

Returns:IRubyObject

the converted value

convertToTypeback to summary
public static IRubyObject convertToType(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites)

Converts this object to type 'targetType' using 'convertMethod' method and raises TypeError exception on failure (MRI: rb_convert_type).

Parameters
obj:IRubyObject

the object to convert

target:RubyClass

is the type we are trying to convert to

sites:JavaSites.CheckedSites

is the CheckedSites call sites to use to dispatch the convert method

Returns:IRubyObject

the converted value

convertToTypeback to summary
public static IRubyObject convertToType(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod, boolean raise)

Deprecated

Annotations
@Deprecated
convertToTypeback to summary
public static IRubyObject convertToType(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod)

Deprecated

Annotations
@Deprecated
convertToTypeOrRaiseback to summary
public static IRubyObject convertToTypeOrRaise(IRubyObject obj, RubyClass target, String convertMethod)

Deprecated

Higher level conversion utility similar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).

Parameters
obj:IRubyObject

the object to convert

target:RubyClass

is the type we are trying to convert to

convertMethod:String

is the method to be called to try and convert to targeType

Returns:IRubyObject

the converted value

Annotations
@Deprecated
convertToTypeUncheckedback to summary
public static IRubyObject convertToTypeUnchecked(ThreadContext context, IRubyObject obj, RubyClass target, String convertMethod, boolean raise)
convertToTypeWithCheckback to summary
public static IRubyObject convertToTypeWithCheck(IRubyObject obj, RubyClass target, String convertMethod)

Higher level conversion utility similar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).

Parameters
obj:IRubyObject

the object to convert

target:RubyClass

is the type we are trying to convert to

convertMethod:String

is the method to be called to try and convert to targeType

Returns:IRubyObject

the converted value

convertToTypeWithCheckback to summary
public static IRubyObject convertToTypeWithCheck(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites)

Higher level conversion utility similar to convertToType but it can throw an additional TypeError during conversion (MRI: rb_check_convert_type).

Parameters
obj:IRubyObject

the object to convert

target:RubyClass

is the type we are trying to convert to

sites:JavaSites.CheckedSites

the CheckedSites call sites to use for coersion

Returns:IRubyObject

the converted value

convertToTypeWithCheckback to summary
public static IRubyObject convertToTypeWithCheck(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod)

Deprecated

Annotations
@Deprecated
handleImplicitlyUncoercibleObjectback to summary
public static IRubyObject handleImplicitlyUncoercibleObject(boolean raise, IRubyObject obj, RubyClass target)

Deprecated

Annotations
@Deprecated
handleUncoercibleObjectback to summary
public static IRubyObject handleUncoercibleObject(boolean raise, IRubyObject obj, RubyClass target)
handleUncoercibleObjectback to summary
public static IRubyObject handleUncoercibleObject(Ruby runtime, IRubyObject obj, RubyClass target, boolean raise)
ioCheckIOback to summary
public static IRubyObject ioCheckIO(Ruby runtime, IRubyObject obj)
ioGetIOback to summary
public static RubyIO ioGetIO(Ruby runtime, IRubyObject obj)
isImplicitTypeErrorback to summary
private static boolean isImplicitTypeError(String methodID)
newTypeErrorback to summary
public static RaiseException newTypeError(IRubyObject obj, RubyClass target, String convertMethod, IRubyObject val)
newTypeErrorback to summary
public static RaiseException newTypeError(Ruby runtime, IRubyObject obj, RubyClass target, String methodName, IRubyObject val)
newTypeErrorMismatchback to summary
public static RaiseException newTypeErrorMismatch(Ruby runtime, IRubyObject obj, RubyClass target, String methodName, IRubyObject val)
raiseIntegerBaseErrorback to summary
private static IRubyObject raiseIntegerBaseError(ThreadContext context, boolean exception)
rb_Arrayback to summary
public static RubyArray<T extends IRubyObject> rb_Array(ThreadContext context, IRubyObject val)
sitesback to summary
public static JavaSites.TypeConverterSites sites(ThreadContext context)
to_aryback to summary
public static RubyArray<T extends IRubyObject> to_ary(ThreadContext context, IRubyObject ary)
toFloatback to summary
public static RubyFloat toFloat(Ruby runtime, IRubyObject obj)
typeAsStringback to summary
public static RubyString typeAsString(IRubyObject obj)