The Id Component

Commons Id is a component used to generate identifiers. Several identifier-generation algorithms are supported by Generators included with the package. The framework is extensible to support additional implementations.

A utility class, IdentifierUtils, provides access to singleton generators and methods to generate identifiers without explicitly creating a Generator.

For example, to generate a sequence of Alphanumeric identifiers, starting with ""000000000000001" and increasing sequentially, you can just repeatedly call

The underlying Generator used in this case is a static field of the IdentifierUtils class, exposed publicly as IdentifierUtils.STRING_ALPHANUMERIC_IDENTIFIER_GENERATOR. The Generator implementation (like all others in this package) is synchronized.

You can also create Generators explicitly using the IdentifierGeneratorFactory abstract factory class. To get an Identifier Generator instance, first get a concrete factory and then use the appropriate instance creation method:

    IdentifierGeneratorFactory factory = IdentifierGeneratorFactory.newInstance();
    StringIdentifierGenerator generator = factory.alphanumericGenerator();
Then you can use the Generator to generate identifiers:
    String id = generator.nextStringIdentifier();

Generators Provided

Generator Description
AlphanumericGenerator Generates an incrementing number in base 36 as a String object
NumericGenerator Generates an incrementing decimal number as a String object
LongGenerator Generates an incrementing number as a Long object
SessionIdGenerator Generates an alphanumeric 10+ character identifier with a random component. The exact length depends on the number of ids requested per time period.
UUID Generators Generates universally Unique Identifiers based on the IETF Draft Uuid Specification.


See the downloads page for information on obtaining releases.


The JavaDoc API documents are available online.