net.rim.pushsdk.commons
Class IdGeneratorImpl

java.lang.Object
  extended by net.rim.pushsdk.commons.IdGeneratorImpl
All Implemented Interfaces:
IdGenerator

public class IdGeneratorImpl
extends Object
implements IdGenerator

Simple implementation of the IdGenerator interface to generate unique ids.

Generally, it is recommend to set the domainName instance variable to something in order to make the id even more unique. Can be set programmatically through the constructor (or the setter) or through Spring bean context XML via dependency injection.

If domainName is null, then the id will be: <11 random alpha numeric characters> + "-" + (eg. 76849392967-1445678) If domainName is not null then the id will be: + <8 random alpha numeric characters> + "-" + (eg. rim.com-76849392-1445678).

Author:
mdicesare

Constructor Summary
IdGeneratorImpl()
          Default constructor.
IdGeneratorImpl(String domainName)
          Constructs an ID generator with the given domain name to use as the prefix of the ID.
 
Method Summary
 String generateId()
          Generates a globally unique id.
 void setDomainName(String domainName)
          Sets the domain name to use when generating ids.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdGeneratorImpl

public IdGeneratorImpl()
Default constructor.


IdGeneratorImpl

public IdGeneratorImpl(String domainName)
Constructs an ID generator with the given domain name to use as the prefix of the ID.

Parameters:
domainName - A domain name to be used in generated ids
Method Detail

generateId

public String generateId()
Generates a globally unique id.

Specified by:
generateId in interface IdGenerator
Returns:
a globally unique id

setDomainName

public void setDomainName(String domainName)
Sets the domain name to use when generating ids. The domainName will prefix the id. See the Javadoc for this class for more info.

Note: This can be any String, but since domain names are unique per content provider it is a good way to ensure your push ids are unique to your push application.

Parameters:
domainName - the value to prefix the id with


Copyright © 2011 Research In Motion. All Rights Reserved.