Packageorg.spicefactory.lib.reflect
Classpublic class Converters

Facility for registering custom Converter implementations. Also contains a utility method that converts a value using one of the registered Converters.



Public Methods
 MethodDefined by
  
addConverter(type:Class, converter:Converter):void
[static] Registers a Converter for the specified class.
Converters
  
convert(value:*, targetType:Class):*
[static] Converts the given value to the specified target type.
Converters
  
getConverter(type:Class):Converter
[static] Returns the Converter registered for the specified class.
Converters
Method detail
addConverter()method
public static function addConverter(type:Class, converter:Converter):void

Registers a Converter for the specified class. Converters will be used for automatic type conversion when setting property values with Spicelib Property instances or invoking methods with Spicelib Method instances.

Parameters
type:Class — the class for which to register the Converter
 
converter:Converter — the Converter instance to be used for the specified type
convert()method 
public static function convert(value:*, targetType:Class):*

Converts the given value to the specified target type. If no conversion is necessary the value will be returned unchanged. Otherwise this method will look for a matching Converter instance and try to convert the value.

Parameters
value:* — the value to convert
 
targetType:Class — the type to convert the value to

Returns
*

Throws
— if the conversion fails or if there is no Converter registered for the specified type.
getConverter()method 
public static function getConverter(type:Class):Converter

Returns the Converter registered for the specified class.

Parameters
type:Class — the class for which to return the registered Converter

Returns
Converter — the Converter registered for the specified class or null if no Converter has been registered for that class