Packageorg.spicefactory.lib.reflect
Classpublic class Converters
InheritanceConverters Inheritance Object

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



Public Properties
 PropertyDefined By
  processingDomain : ApplicationDomain
[static] The ApplicationDomain to be used by converters that need to use reflection.
Converters
Public Methods
 MethodDefined By
  
addConverter(type:Class, converter:Converter):void
[static] Registers a Converter for the specified class.
Converters
  
convert(value:*, targetType:Class, domain:ApplicationDomain = null):*
[static] Converts the given value to the specified target type.
Converters
  
[static] Returns the Converter registered for the specified class.
Converters
Property Detail
processingDomainproperty
processingDomain:ApplicationDomain

The ApplicationDomain to be used by converters that need to use reflection. This hook allows to temporarily overwrite the default, which is using the domain the owner class of the property or method that triggers conversion belongs to. Sometimes the default is not sufficient, for example when a framework class has a property of type Class that may hold values pointing to classes loaded into child ApplicationDomains.

It is recommended to set this value in a try/finally clause and set it back to the previous value in the finally clause.


Implementation
    public static function get processingDomain():ApplicationDomain
    public static function set processingDomain(value:ApplicationDomain):void
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, domain:ApplicationDomain = null):*

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
 
domain:ApplicationDomain (default = null)

Returns
*

Throws
ConversionError — 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