AbstractLocator

Kind of class:public class
Package:com.bourre.core
Inherits from:none
Implements:
Known subclasses:
Classpath:com.bourre.core.AbstractLocator
File last modified:Tuesday, 15 April 2008, 09:25:42

Summary


Constructor
  • AbstractLocator (type:Class = null, typeListener:Class = null, logger:Log = null)
    • Creates a new locator instance.
Instance methods
  • getLogger : Log
    • Returns the exclusive logger object owned by this locator.
  • isRegistered (name:String) : Boolean
    • Returns true is there is a ressource associated
  • register (name:String, o:Object) : Boolean
  • unregister (name:String) : Boolean
  • locate (name:String) : Object
    • Returns the ressource associated with the passed-in key.
  • release : void
    • Clears all association between keys and objects
  • add (d:Dictionary) : void
    • Adds all ressources contained in the passed-in dictionnary
  • matchType (o:*) : Boolean
    • Verify that the passed-in object type match the current
  • getType : Class
    • Return the class type of elements in this container.
  • isTyped : Boolean
    • Returns true if this container perform a verification
  • addEventListener (type:String, listener:Object, rest) : Boolean
    • Adds an event listener for the specified event type.
  • removeEventListener (type:String, listener:Object) : Boolean
    • Removes the passed-in listener for listening the specified event.
  • getKeys : Array
    • Returns an Array view of the keys contained in this locator.
  • getValues : Array
    • Returns an Array view of the values contained in this locator.
  • toString : String
    • Returns the string representation of this instance.

Constructor

AbstractLocator

public function AbstractLocator (
type:Class = null, typeListener:Class = null, logger:Log = null)

Creates a new locator instance. If the typeargument is defined, the locator is considered as typed, and
then the type of all elements inserted in this set is checked.
Parameters:
type:
Class type for elements of this set
type:
Class type for elements of this set

Instance methods

add

public function add (
d:Dictionary) : void

Adds all ressources contained in the passed-in dictionnary
into this locator instance. If there is keys used both in
the locator and in the dictionnary an exception is thrown.
Parameters:
d:
dictionnary instance which contains ressources
to be added
Throws:
  • {VISDOC_LINK_0}IllegalArgumentException — One or more
    keys present in the dictionnary already exist in this
    locator instance.
Specified by:

addEventListener

public function addEventListener (
type:String, listener:Object, rest) : Boolean

Adds an event listener for the specified event type.
There is two behaviors for the addEventListenerfunction :
  1. The passed-in listener is an object :
    The object is added as listener only for the specified event, the object must
    have a function with the same name than type or at least a

    handleEvent function.
  2. The passed-in listener is a function :
    A Delegate object is created and then
    added as listener for the event type. There is no restriction on the name of
    the function. If the rest is not empty, all elements in it is
    used as additional arguments into the delegate object.
Parameters:
type :
name of the event for which register the listener
listener:
object or function which will receive this event
rest :
additional arguments for the function listener
Returns:
  • true if the function have been succesfully added as
    listener fot the passed-in event
Throws:
  • {VISDOC_LINK_0}UnsupportedOperationException — If the listener is an object
    which have neither a function with the same name than the event type nor
    a function called handleEvent

getKeys

public function getKeys (
) : Array

Returns an Array view of the keys contained in this locator.
Returns:
  • an array view of the keys contained in this locator
Specified by:

getLogger

public function getLogger (
) : Log

Returns the exclusive logger object owned by this locator.
It allow this logger to send logging message directly on
its owner logging channel.
Returns:
  • logger associated to the owner

getType

public function getType (
) : Class

Return the class type of elements in this container.

An untyped container returns null, as the
wildcard type (*) is not a Classand Object class doesn't fit for primitive types.

Returns:
  • Class type of the container's elements
Specified by:

getValues

public function getValues (
) : Array

Returns an Array view of the values contained in this locator.
Returns:
  • an array view of the values contained in this locator

isRegistered

public function isRegistered (
name:String) : Boolean

Returns true is there is a ressource associated
with the passed-in key. To avoid errors when
retreiving ressources from a locator you should systematically
use the isRegistered function to check if the
ressource you would access is already accessible before any
call to the locate function.
Returns:
  • true is there is a ressource associated
    with the passed-in key.

isTyped

public function isTyped (
) : Boolean

Returns true if this container perform a verification
of the type of elements.
Returns:
  • true if this container perform a verification
    of the type of elements.
Specified by:

locate

public function locate (
name:String) : Object

Returns the ressource associated with the passed-in key.
If there is no ressource identified by the passed-in key, the
function will fail with an error. To avoid the throw of an exception
when attempting to access to a ressource, take care to check the
existence of the ressource before trying to access to it.
Parameters:
key:
identifier of the ressource to access
Returns:
  • the ressource associated with the passed-in key
Throws:
  • {VISDOC_LINK_0}NoSuchElementException — There is no ressource
    associated with the passed-in key

matchType

public function matchType (
o:*) : Boolean

Verify that the passed-in object type match the current
container element's type.
Returns:
  • true if the object is elligible for this
    container, either false.

register

public function register (
name:String, o:Object) : Boolean

release

public function release (
) : void

Clears all association between keys and objects
registered for this locator.

removeEventListener

public function removeEventListener (
type:String, listener:Object) : Boolean

Removes the passed-in listener for listening the specified event. The
listener could be either an object or a function.
Parameters:
type :
name of the event for which unregister the listener
listener:
object or function to be unregistered
Returns:
  • true if the listener have been successfully removed
    as listener for the passed-in event

toString

public function toString (
) : String

Returns the string representation of this instance.
Returns:
  • the string representation of this instance

unregister

public function unregister (
name:String) : Boolean