gzz.util
Class URN5Namespace

java.lang.Object
  |
  +--gzz.util.URN5Namespace

public class URN5Namespace
extends java.lang.Object

A class which is able to generate globally unique URN-5 identifiers. URN-5 identifiers are globally unique, nonhierarchical identifiers.

The names generated by the same instance share the same "random number" part and differ only by the "local part". See http://www.iana.org/assignments/urn-informal/urn-5

The java.security.SecureRandom class is used as a source of random numbers.


Field Summary
static URN5Namespace instance
          Static instance to use when security concerns aren't too high.
static int NAMESPACECHARS
          21 bytes ^= 28 base64 namespace chars
 
Constructor Summary
URN5Namespace()
           
 
Method Summary
 java.lang.String generateId()
           
static java.lang.String generateRandomChars()
          Generate a sequence of base64 characters with at least 160 bits of randomness.
 java.lang.String getNamespaceId()
          Get the base id of the namespace.
 java.lang.String getStormDataBlockId()
          Get the first part of a Storm data block id.
static void main(java.lang.String[] argv)
          If run as a main program, generate and print to stdout a single urn-5 identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACECHARS

public static final int NAMESPACECHARS
21 bytes ^= 28 base64 namespace chars

See Also:
Constant Field Values

instance

public static final URN5Namespace instance
Static instance to use when security concerns aren't too high. The security concerns are that everything using this in the same session will have the same 'random number' part, making it obvious that they were created in the same session.

Constructor Detail

URN5Namespace

public URN5Namespace()
Method Detail

generateRandomChars

public static java.lang.String generateRandomChars()
Generate a sequence of base64 characters with at least 160 bits of randomness.


getNamespaceId

public java.lang.String getNamespaceId()
Get the base id of the namespace. This does not generate unique identifiers: this is simply the prefix of all identifiers generated in this namespace. Of course, if you create a URN5Namespace, call this method once and then throw away the object, the result should be random.


generateId

public java.lang.String generateId()

getStormDataBlockId

public java.lang.String getStormDataBlockId()
Get the first part of a Storm data block id. I.e., something like 'storm:data:abcdef...faq:1:'; a full data block URI can be formed by appending the content type (optional) a comma, and the data. This is used by FakeTextSpan.


main

public static void main(java.lang.String[] argv)
If run as a main program, generate and print to stdout a single urn-5 identifier.