Packagecom.bourre.core
Classpublic class HashCodeFactory

Player version: Flash Player 9.0
Language version: ActionScript 3.0

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.



Public Methods
 MethodDefined by
  
getKey(o:*):String
[static] Returns the hashcode key associated to the passed-in object.
HashCodeFactory
  
getNextKey():String
[static] Returns the next unique identifier, two consecutives call to the getNextKey will generate two different keys.
HashCodeFactory
  
hasKey(o:*):Boolean
[static] Returns true if the passed-in object already have a hashcode key.
HashCodeFactory
  
previewNextKey():String
[static] Returns the next key the getNextKey will return, without causing the getNextKey method returning a different key.
HashCodeFactory
Protected Constants
 ConstantDefined by
  _oHashTable : Dictionary
[static] A hash map which store the generated keys for each object for which an identifier was generated.
HashCodeFactory
Method detail
getKey()method
public static function getKey(o:*):String

Player version: Flash Player 9.0
Language version: ActionScript 3.0

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
String — the string hashcode for the passed-in object
getNextKey()method 
public static function getNextKey():String

Player version: Flash Player 9.0
Language version: ActionScript 3.0

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 previewNextKey method.

Returns
String — the next unique identifier

See also

hasKey()method 
public static function hasKey(o:*):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

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
Booleantrue if the passed-in object already have a hashcode key
previewNextKey()method 
public static function previewNextKey():String

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the next key the getNextKey will return, without causing the getNextKey method returning a different key. Calling several times the previewNextKey method will never affect the next call of the getNextKey method.

Returns
String — a preview of the next unique identifier
Constant detail
_oHashTableconstant
protected static const _oHashTable:Dictionary

Player version: Flash Player 9.0
Language version: ActionScript 3.0

A hash map which store the generated keys for each object for which an identifier was generated. Objects are stored as weak reference so they will be collected as any other object which has no hashcode identifier.