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
Creates a new locator instance. If the
then the type of all elements inserted in this set is checked.
typeargument is defined, the locator is considered as typed, andthen the type of all elements inserted in this set is checked.
Parameters:
type:
Class type for elements of this settype:
Class type for elements of this setInstance 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.
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
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
There is two behaviors for the
addEventListenerfunction :- 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 thantypeor at least ahandleEventfunction. - The passed-in listener is a function :
ADelegateobject is created and then
added as listener for the event type. There is no restriction on the name of
the function. If therestis 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:
-
trueif 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 calledhandleEvent
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
Returns the exclusive logger object owned by this locator.
It allow this logger to send logging message directly on
its owner logging channel.
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:
-
Classtype 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
with the passed-in
retreiving ressources from a locator you should systematically
use the
ressource you would access is already accessible before any
call to the
true is there is a ressource associatedwith the passed-in
key. To avoid errors whenretreiving ressources from a locator you should systematically
use the
isRegistered function to check if theressource you would access is already accessible before any
call to the
locate function. Returns:
-
trueis there is a ressource associated
with the passed-inkey.
isTyped
public function isTyped (
) : Boolean
Returns
of the type of elements.
true if this container perform a verificationof the type of elements.
Returns:
-
trueif 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
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.
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.
container element's type.
Returns:
-
trueif the object is elligible for this
container, eitherfalse.
Specified by:
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.
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.
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:
-
trueif 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