Class: HashedIdFactory

alk.format.HashedIdFactory

An instance of this class generates hashed identifiers based on given strings using alk.format.HashedIdFactory#getIdForString.

new alk.format.HashedIdFactory(opt_options)

This constructor creates an object used in OpenLayers format readers.

This class has a collision check apparatus that may be turned on, but this base class does not provide a fix for a collision. Override alk.format.HashedIdFactory#hashCollisionFix to perform a suitable fix.

Option Type Description
checkForCollisions boolean | undefined

If this option is set to true, the HashedIdFactory will check for hash collisions. Default is false;

logCollisions boolean | undefined

If this option is set to true, and the options.checkForCollisions is also set to true, the HashedIdFactory will log collisions when they occur during calls to alk.format.HashedIdFactory#getIdForString. Default is false.

Override alk.format.HashedIdFactory#logCollisions to redirect logging.

Methods

getIdForString(str){number|string|undefined}

This function generates a hashed Id for this particular string.

This implementation calls out to getHashId. If there is a collision, then the hash from hashCollisionFix is returned.

Name Type Description
str string

hashCollisionFix(hash, str){number|string}

This function is called when hasHashCollision returns true.

This implementation does not fix anything and just returns the given hash. Override, if a fix is needed.

Name Type Description
hash number | string
str string