YUI AS Component Documentation | All Packages | All Classes | Index | Frames No Frames |
Class InstanceFactory

Package | com.yahoo.astra.utils
Class | public class InstanceFactory

Creates an instance of the specified class. Sets initial properties, and calls specified methods.

Public Properties

| Property | Defined by
--- | --- | ---
|  | methods : Object A set of methods to call once the object has been created and properties have been initialized. | InstanceFactory
|  | properties : Object The initial values to pass to the properties of the newly-instantiated object. | InstanceFactory
|  | targetClass : Class The class that will be instantiated. | InstanceFactory

Public Methods

| Method | Defined by
--- | --- | ---
|  | InstanceFactory(targetClass:Class, properties:Object = null, methods:Object = null) Constructor. | InstanceFactory
|  | createInstance():Object Creates a new instance of the target class and initializes it. | InstanceFactory
|  | restoreInstance(instance:Object):void Initializes an object with the properties and methods. | InstanceFactory

Property detail

methods | property

`methods:Object` [read-write]

A set of methods to call once the object has been created and properties have been initialized. Format is a set of key-value pairs where the key is the name of the method and the value is an Array of parameter values.

Example: `{ load: [ "image.gif" ] }`

Implementation
`public function get methods():Object`
`public function set methods(value:Object):void`

properties | property |

`properties:Object` [read-write]

The initial values to pass to the properties of the newly-instantiated object.

Implementation
`public function get properties():Object`
`public function set properties(value:Object):void`

targetClass | property |

`targetClass:Class` [read-write]

The class that will be instantiated.

Implementation
`public function get targetClass():Class`
`public function set targetClass(value:Class):void`
Constructor detail

InstanceFactory | () | constructor

`public function InstanceFactory(targetClass:Class, properties:Object = null, methods:Object = null)`

Constructor.

Parameters

| `targetClass:Class`
| `properties:Object` (default = `null`)``
| `methods:Object` (default = `null`)``

Method detail

createInstance | () | method

`public function createInstance():Object`

Creates a new instance of the target class and initializes it.

Returns

| `Object`

restoreInstance | () | method |

`public function restoreInstance(instance:Object):void`

Initializes an object with the properties and methods. The object must be an instance of the `targetClass` property, or this method will throw an `ArgumentError`.

Parameters

| `instance:Object`