Package org.jruby.util
Class TypeConverter
java.lang.Object
org.jruby.util.TypeConverter
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IRubyObjectcheckArrayType(Ruby runtime, IRubyObject obj) static IRubyObjectDeprecated.static IRubyObjectcheckArrayType(ThreadContext context, IRubyObject obj) static IRubyObjectcheckArrayType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj) static IRubyObjectcheckData(IRubyObject obj) Checks that this object is of type DATA and then returns it, otherwise raises failure (MRI: Check_Type(obj, T_DATA))static IRubyObjectcheckFloatType(Ruby runtime, IRubyObject obj) static IRubyObjectcheckHashType(Ruby runtime, IRubyObject obj) static IRubyObjectcheckHashType(Ruby runtime, IRubyObject obj, boolean raise) static IRubyObjectcheckHashType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj) static RubySymbolConvert the supplied object into an internal identifier String.static RubySymbolcheckID(IRubyObject obj) Convert the supplied object into an internal identifier String.static IRubyObjectcheckIntegerType(Ruby runtime, IRubyObject obj, String method) static IRubyObjectcheckIntegerType(ThreadContext context, IRubyObject obj) static IRubyObjectcheckStringType(Ruby runtime, IRubyObject obj) static IRubyObjectcheckStringType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj) static IRubyObjectcheckStringType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj, RubyClass target) static voidcheckType(ThreadContext context, IRubyObject x, RubyModule type) static StringDeprecated.static IRubyObjectconvertToInteger(ThreadContext context, IRubyObject val, int base) static IRubyObjectconvertToInteger(ThreadContext context, IRubyObject val, int base, boolean exception) static IRubyObjectconvertToType(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod) Deprecated.static IRubyObjectconvertToType(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod, boolean raise) Deprecated.static IRubyObjectconvertToType(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).static IRubyObjectconvertToType(IRubyObject obj, RubyClass target, String convertMethod, boolean raise) Converts this object to type 'targetType' using 'convertMethod' method (MRI: convert_type).static IRubyObjectconvertToType(ThreadContext context, IRubyObject obj, RubyClass target, String convertMethod, boolean raise) static IRubyObjectconvertToType(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).static IRubyObjectconvertToType(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).static IRubyObjectconvertToType19(IRubyObject obj, RubyClass target, String convertMethod) Deprecated.static IRubyObjectconvertToType19(IRubyObject obj, RubyClass target, String convertMethod, boolean raise) Deprecated.static IRubyObjectconvertToType19(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites) Deprecated.static IRubyObjectconvertToType19(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites, boolean raise) Deprecated.static IRubyObjectconvertToTypeOrRaise(IRubyObject obj, RubyClass target, String convertMethod) Deprecated.static IRubyObjectconvertToTypeWithCheck(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod) Deprecated.static IRubyObjectconvertToTypeWithCheck(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).static IRubyObjectconvertToTypeWithCheck(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).static IRubyObjectconvertToTypeWithCheck19(IRubyObject obj, RubyClass target, String convertMethod) Deprecated.static IRubyObjectconvertToTypeWithCheck19(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites) Deprecated.static IRubyObjecthandleImplicitlyUncoercibleObject(boolean raise, IRubyObject obj, RubyClass target) Deprecated.static IRubyObjecthandleUncoercibleObject(boolean raise, IRubyObject obj, RubyClass target) static IRubyObjecthandleUncoercibleObject(Ruby runtime, IRubyObject obj, RubyClass target, boolean raise) static IRubyObjectioCheckIO(Ruby runtime, IRubyObject obj) static RubyIOioGetIO(Ruby runtime, IRubyObject obj) private static booleanisImplicitTypeError(String methodID) static RaiseExceptionnewTypeError(Ruby runtime, IRubyObject obj, RubyClass target, String methodName, IRubyObject val) static RaiseExceptionnewTypeError(IRubyObject obj, RubyClass target, String convertMethod, IRubyObject val) static RaiseExceptionnewTypeErrorMismatch(Ruby runtime, IRubyObject obj, RubyClass target, String methodName, IRubyObject val) private static IRubyObjectraiseIntegerBaseError(ThreadContext context, boolean exception) static RubyArrayrb_Array(ThreadContext context, IRubyObject val) private static JavaSites.TypeConverterSitessites(ThreadContext context) static RubyArrayto_ary(ThreadContext context, IRubyObject ary) static RubyFloattoFloat(Ruby runtime, IRubyObject obj) static RubyStringtypeAsString(IRubyObject obj)
-
Field Details
-
IMPLICIT_CONVERTED_METHODS
-
-
Constructor Details
-
TypeConverter
public TypeConverter()
-
-
Method Details
-
convertToType
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- the object to converttarget- is the type we are trying to convert toconvertMethod- is the method to be called to try and convert to target typeraise- will throw an Error if conversion does not work- Returns:
- the converted value
-
convertToType
public static IRubyObject convertToType(ThreadContext context, IRubyObject obj, RubyClass target, String convertMethod, boolean raise) -
convertToType
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- the object to converttarget- is the type we are trying to convert tosites- is the CheckedSites call sites to be called to try and convert to targetTyperaise- will throw an Error if conversion does not work- Returns:
- the converted value
-
convertToType
Converts this object to type 'targetType' using 'convertMethod' method and raises TypeError exception on failure (MRI: rb_convert_type).- Parameters:
obj- the object to converttarget- is the type we are trying to convert toconvertMethod- is the method to be called to try and convert to targeType- Returns:
- the converted value
-
convertToType
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- the object to converttarget- is the type we are trying to convert tosites- is the CheckedSites call sites to use to dispatch the convert method- Returns:
- the converted value
-
convertToType19
@Deprecated public static IRubyObject convertToType19(IRubyObject obj, RubyClass target, String convertMethod, boolean raise) Deprecated. -
convertToType19
@Deprecated public static IRubyObject convertToType19(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites, boolean raise) Deprecated. -
convertToType19
@Deprecated public static IRubyObject convertToType19(IRubyObject obj, RubyClass target, String convertMethod) Deprecated. -
convertToType19
@Deprecated public static IRubyObject convertToType19(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites) Deprecated. -
toFloat
-
checkData
Checks that this object is of type DATA and then returns it, otherwise raises failure (MRI: Check_Type(obj, T_DATA))- Parameters:
obj- the object to check- Returns:
- the converted value
-
typeAsString
-
checkID
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. -
checkID
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. -
convertToTypeWithCheck
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- the object to converttarget- is the type we are trying to convert toconvertMethod- is the method to be called to try and convert to targeType- Returns:
- the converted value
-
convertToTypeWithCheck
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- the object to converttarget- is the type we are trying to convert tosites- the CheckedSites call sites to use for coersion- Returns:
- the converted value
-
convertToTypeWithCheck19
@Deprecated public static IRubyObject convertToTypeWithCheck19(IRubyObject obj, RubyClass target, String convertMethod) Deprecated. -
convertToTypeWithCheck19
@Deprecated public static IRubyObject convertToTypeWithCheck19(ThreadContext context, IRubyObject obj, RubyClass target, JavaSites.CheckedSites sites) Deprecated. -
newTypeError
public static RaiseException newTypeError(IRubyObject obj, RubyClass target, String convertMethod, IRubyObject val) -
newTypeError
public static RaiseException newTypeError(Ruby runtime, IRubyObject obj, RubyClass target, String methodName, IRubyObject val) -
newTypeErrorMismatch
public static RaiseException newTypeErrorMismatch(Ruby runtime, IRubyObject obj, RubyClass target, String methodName, IRubyObject val) -
checkIntegerType
-
checkIntegerType
-
checkFloatType
-
checkHashType
-
checkHashType
-
checkHashType
public static IRubyObject checkHashType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj) -
checkStringType
-
checkStringType
public static IRubyObject checkStringType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj) -
checkStringType
public static IRubyObject checkStringType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj, RubyClass target) -
checkArrayType
-
checkArrayType
public static IRubyObject checkArrayType(ThreadContext context, JavaSites.CheckedSites sites, IRubyObject obj) -
ioCheckIO
-
ioGetIO
-
checkArrayType
-
checkArrayType
Deprecated. -
handleUncoercibleObject
-
handleUncoercibleObject
public static IRubyObject handleUncoercibleObject(Ruby runtime, IRubyObject obj, RubyClass target, boolean raise) -
handleImplicitlyUncoercibleObject
@Deprecated public static IRubyObject handleImplicitlyUncoercibleObject(boolean raise, IRubyObject obj, RubyClass target) Deprecated. -
checkType
-
convertToInteger
public static IRubyObject convertToInteger(ThreadContext context, IRubyObject val, int base, boolean exception) -
convertToInteger
-
rb_Array
-
to_ary
-
raiseIntegerBaseError
-
sites
-
convertToType
@Deprecated public static IRubyObject convertToType(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod, boolean raise) Deprecated. -
convertToType
@Deprecated public static IRubyObject convertToType(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod) Deprecated. -
convertToTypeWithCheck
@Deprecated public static IRubyObject convertToTypeWithCheck(IRubyObject obj, RubyClass target, int convertMethodIndex, String convertMethod) Deprecated. -
convertToIdentifier
Deprecated. -
convertToTypeOrRaise
@Deprecated 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- the object to converttarget- is the type we are trying to convert toconvertMethod- is the method to be called to try and convert to targeType- Returns:
- the converted value
-
isImplicitTypeError
-