AccessorFactory

Kind of class:public class
Package:com.bourre.core
Inherits from:none
Author:Cédric Néhémie
Classpath:com.bourre.core.AccessorFactory
File last modified:Monday, 24 November 2008, 11:36:49
A factory for Accessor and AccessorComposer creation.
With the AccessorFactory, you don't have to know if you attempt to
access to a property or to a method. The creational methods of the factory
will return the corresponding concret accessor.

Summary


Class methods
  • getAccessor (t:Object, setter:String, getter:String = null) : Accessor
    • Returns an accessor object for the passed-in property or methods of the
  • getMultiAccessor (t:Object, setter:Array, getter:Array = null) : AccessorComposer
    • Returns an accessor object for the passed-in properties or methods of the

Class methods

getAccessor

public static function getAccessor (
t:Object, setter:String, getter:String = null) : Accessor

Returns an accessor object for the passed-in property or methods of the
specified target object. The concret type of the accessor cannot be
known before the call, as for any other factories.

In the case of accessing to method member, the setter and

getter arguments must be set.

Parameters:
t :
the object onto which access member(s)
setter:
name of the setter property on the target
getter:
name of the getter property on the target, used
only if the setter property is a function
Returns:
  • a concret Accessor to the specified member(s)
Throws:
  • {VISDOC_LINK_0}NullPointerException — The passed-in target is
    null
  • {VISDOC_LINK_1}NoSuchFieldException — The target object doesn't
    own any field named as setter
  • {VISDOC_LINK_2}NoSuchMethodException — There'is no getter
    method to associate with the corresponding setter

getMultiAccessor

public static function getMultiAccessor (
t:Object, setter:Array, getter:Array = null) : AccessorComposer

Returns an accessor object for the passed-in properties or methods of the
specified target object. The concret type of the accessor cannot be
known before the call, as for any other factories.

In the case of accessing to method member, the setter and

getter arguments must be set.

Parameters:
t :
the object onto which access member(s)
setter:
array of setter member's name
getter:
array of getter member's name, when mixing properties
and methods, the same order must be conservated in the
two arrays
Returns:
  • a concret AccessorComposer to the specified member(s)
Throws:
  • {VISDOC_LINK_0}NullPointerException — The passed-in target is
    null
  • {VISDOC_LINK_1}NoSuchFieldException — The target object doesn't
    own any field named as setter
  • {VISDOC_LINK_2}NoSuchMethodException — There'is no getter
    method to associate with the corresponding setter
Example:
  • The orders of the parameters must be equivalent both in the setter
    array and in the getter array. When mixing properties and methods, the
    getter name of a properties is null, as the properties may generally
    provides read and write access to it.
    AccessorFactory.getMultiAccessor (
    anObject,
    [ "someProperty", "getSomething", "getAnotherThing" ],
    [ null, "setSomething", "setAnotherThing" ]
    );