HashCodeFactory

Kind of class:public class
Package:com.bourre.core
Inherits from:none
Classpath:com.bourre.core.HashCodeFactory
File last modified:Monday, 24 November 2008, 11:36:49
The HashCodeFactory class provides convenient methods
to emulate the behavior of the Java™ Object.hashcode()method. The hashcode factory provides an unique identifier for any
instance in an application.

However, there is a major difference between the Java™ behavior
and the Flash™ behavior. In Java™ the hashcode method
will return the same value for two different instance of the same
class which have the same properties value, in Flash™ the
hashcode factory will return a different identifier for all instances
even if their properties are equals.

Summary


Class methods
  • getKey (o:*) : String
    • Returns the hashcode key associated to the passed-in object.
  • hasKey (o:*) : Boolean
    • Returns true if the passed-in object already
  • getNextKey : String
    • Returns the next unique identifier, two consecutives
  • previewNextKey : String
    • Returns the next key the getNextKeywill return, without causing the getNextKeymethod returning a different key.

Class methods

getKey

public static function getKey (
o:*) : String

Returns the hashcode key associated to the passed-in object.
If the objects has not yet a hashcode, the function will generate
one and then register the object with its hashcode.
Parameters:
o:
object for which get the hashcode key
Returns:
  • the string hashcode for the passed-in object

getNextKey

public static function getNextKey (
) : String

Returns the next unique identifier, two consecutives
call to the getNextKey will generate two
different keys. To get the next key without changing
the next call result use the previewNextKeymethod.
Returns:
  • the next unique identifier
See also:

hasKey

public static function hasKey (
o:*) : Boolean

Returns true if the passed-in object already
have a hashcode key.
Parameters:
o:
object for which verify the presence of a hashcode key
Returns:
  • true if the passed-in object already
    have a hashcode key

previewNextKey

public static function previewNextKey (
) : String

Returns the next key the getNextKeywill return, without causing the getNextKeymethod returning a different key. Calling several times
the previewNextKey method will never affect
the next call of the getNextKey method.
Returns:
  • a preview of the next unique identifier