com.metamatrix.core.id
Class UUIDFactory

java.lang.Object
  extended by com.metamatrix.core.id.UUIDFactory
All Implemented Interfaces:
ObjectIDFactory

public class UUIDFactory
extends java.lang.Object
implements ObjectIDFactory

This class is a factory for generating universally unique identifiers (UUID's).

Output format for UUIDs

UUIDs are output in the following 36-character format:

    xxxxxxxx-yyyy-zzzz-cccc-nnnnnnnnnnnn
 
where x=least significant time component, y=middle significant time component, z=most significant time component multiplexed with version, c=clock sequence multiplexed with variant, and n=node component (random number).

The generated ID's conform somewhat to the (now expired) IETF internet draft standard, "UUIDs and GUIDs", DCE spec on UUIDs.

All references in this code to bit positions as "least significant" and "most significant" refer to the bits moving from right to left, respectively.


Constructor Summary
UUIDFactory()
           
 
Method Summary
 ObjectID create()
          Create a new ObjectID instance using this protocol.
 java.lang.String getDescription()
          Return the description for the type of ObjectID described by this object.
 java.lang.String getProtocol()
          Return the name of the protocol that this factory uses.
 ObjectID stringToObject(java.lang.String value)
          Attempt to convert the specified string to the appropriate ObjectID instance.
 ObjectID stringWithoutProtocolToObject(java.lang.String value)
          Attempt to convert the specified string to the appropriate ObjectID instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UUIDFactory

public UUIDFactory()
Method Detail

getDescription

public java.lang.String getDescription()
Return the description for the type of ObjectID described by this object.

Specified by:
getDescription in interface ObjectIDFactory
Returns:
the description

stringWithoutProtocolToObject

public ObjectID stringWithoutProtocolToObject(java.lang.String value)
                                       throws InvalidIDException
Attempt to convert the specified string to the appropriate ObjectID instance. This method is called by the IDGenerator.stringToObject(String) method, which must process the protocol to determine the correct parser to use. As such, it guarantees that the parser that receives this call can assume that the protocol was equal to the protocol returned by the parser's ObjectIDDescriptor#getProtocol().

Specified by:
stringWithoutProtocolToObject in interface ObjectIDFactory
Parameters:
value - the stringified id with the protocol and ObjectID.DELIMITER already removed, and should never null or zero length
Returns:
the ObjectID instance for the stringified ID if this factory is able to parse the string, or null if the factory is unaware of the specified format.
Throws:
InvalidIDException - if the parser is aware of this protocol, but it is of the wrong format for this type of ObjectID.

stringToObject

public ObjectID stringToObject(java.lang.String value)
                        throws InvalidIDException
Attempt to convert the specified string to the appropriate ObjectID instance.

Specified by:
stringToObject in interface ObjectIDFactory
Parameters:
value - the stringified id (the result of ObjectID.toString()), and should never null or zero length
Returns:
the ObjectID instance for the stringified ID if this factory is able to parse the string, or null if the factory is unaware of the specified format.
Throws:
InvalidIDException - if the parser is aware of this protocol, but it is of the wrong format for this type of ObjectID.

getProtocol

public java.lang.String getProtocol()
Return the name of the protocol that this factory uses.

Specified by:
getProtocol in interface ObjectIDFactory
Returns:
the protocol name

create

public ObjectID create()

Create a new ObjectID instance using this protocol.

Specified by:
create in interface ObjectIDFactory
Returns:
Universally unique ID (UUID)


Copyright © 2009. All Rights Reserved.