public class IDFactory extends java.lang.Object implements IIDFactory
Modifier and Type | Field and Description |
---|---|
protected static IIDFactory |
instance |
static java.lang.String |
SECURITY_PROPERTY |
Modifier and Type | Method and Description |
---|---|
Namespace |
addNamespace(Namespace namespace)
Add the given Namespace to our table of available Namespaces
|
static Namespace |
addNamespace0(Namespace namespace) |
protected static void |
checkPermission(NamespacePermission namespacepermission) |
boolean |
containsNamespace(Namespace namespace)
Check whether table contains given Namespace instance
|
static boolean |
containsNamespace0(Namespace n) |
ID |
createGUID()
Make a GUID using SHA-1 hash algorithm and a default of 16bits of data
length.
|
ID |
createGUID(int length)
Make a GUID using SHA-1 hash algorithm and a default of 16bits of data
length.
|
ID |
createID(Namespace n,
java.lang.Object[] args)
Make a new identity.
|
ID |
createID(Namespace namespace,
java.lang.String uri)
Make a new identity instance from a namespace and String.
|
ID |
createID(java.lang.String namespaceName,
java.lang.Object[] args)
Make a new identity.
|
ID |
createID(java.lang.String namespace,
java.lang.String uri)
Make a new identity instance from a namespaceName and idValue.
|
ID |
createLongID(long l)
Make a an ID from a long
|
ID |
createStringID(java.lang.String idstring)
Make a an ID from a String
|
ID |
createURIID(java.lang.String uri)
Create a URIID from String.
|
ID |
createURIID(java.net.URI uri)
Create a URIID from URI.
|
ID |
createUuID()
Create a random UuID
|
ID |
createUuID(java.lang.String uuid)
Create a UuID from String
|
ID |
createUuID(java.net.URI uuidURI)
Create a UuID from URI.
|
ID |
createUuID(java.util.UUID uuid)
Create a UuID from UUID
|
static IIDFactory |
getDefault() |
Namespace |
getNamespace(Namespace namespace)
Get the given Namespace instance from table
|
protected static Namespace |
getNamespace0(Namespace n) |
protected static Namespace |
getNamespace0(java.lang.String name) |
Namespace |
getNamespaceByName(java.lang.String name)
Get a Namespace instance by its string name.
|
java.util.List<Namespace> |
getNamespaces()
Get a list of the current Namespace instances exposed by this factory.
|
protected static void |
logAndThrow(java.lang.String s,
java.lang.Throwable t) |
Namespace |
removeNamespace(Namespace n)
Remove the given Namespace from our table of available Namespaces
|
static Namespace |
removeNamespace0(Namespace n) |
public static final java.lang.String SECURITY_PROPERTY
protected static IIDFactory instance
public static IIDFactory getDefault()
public Namespace addNamespace(Namespace namespace) throws java.lang.SecurityException
IIDFactory
addNamespace
in interface IIDFactory
namespace
- the Namespace to addjava.lang.SecurityException
- thrown if caller does not have appropriate
NamespacePermission for given namespaceprotected static final void checkPermission(NamespacePermission namespacepermission) throws java.lang.SecurityException
java.lang.SecurityException
public boolean containsNamespace(Namespace namespace) throws java.lang.SecurityException
IIDFactory
containsNamespace
in interface IIDFactory
namespace
- the Namespace to look forjava.lang.SecurityException
- thrown if caller does not have appropriate
NamespacePermission for given namespacepublic java.util.List<Namespace> getNamespaces()
IIDFactory
getNamespaces
in interface IIDFactory
public static final boolean containsNamespace0(Namespace n)
public Namespace getNamespace(Namespace namespace) throws java.lang.SecurityException
IIDFactory
getNamespace
in interface IIDFactory
namespace
- the Namespace to look forjava.lang.SecurityException
- thrown if caller does not have appropriate
NamespacePermission for given namespacepublic Namespace getNamespaceByName(java.lang.String name) throws java.lang.SecurityException
IIDFactory
getNamespaceByName
in interface IIDFactory
name
- the name to use for lookupjava.lang.SecurityException
- thrown if caller does not have appropriate
NamespacePermission for given namespaceprotected static final Namespace getNamespace0(java.lang.String name)
public ID createGUID() throws IDCreateException
IIDFactory
createGUID
in interface IIDFactory
IDCreateException
- if ID cannot be constructedpublic ID createGUID(int length) throws IDCreateException
IIDFactory
createGUID
in interface IIDFactory
length
- the byte-length of data used to create a GUIDIDCreateException
- if ID cannot be constructedprotected static void logAndThrow(java.lang.String s, java.lang.Throwable t) throws IDCreateException
IDCreateException
public ID createID(Namespace n, java.lang.Object[] args) throws IDCreateException
IIDFactory
createID
in interface IIDFactory
n
- the Namespace to which the ID will belongargs
- an Object [] of the parameters for the ID instance constructorIDCreateException
- thrown if class for instantiator or instance can't be
loaded, if something goes wrong during instance
constructionpublic ID createID(java.lang.String namespaceName, java.lang.Object[] args) throws IDCreateException
IIDFactory
createID
in interface IIDFactory
namespaceName
- the name of the Namespace to which the ID will belongargs
- an Object [] of the parameters for the ID instance constructorIDCreateException
- thrown if class for instantiator or ID instance can't be
loaded, if something goes wrong during instance
constructionpublic ID createID(Namespace namespace, java.lang.String uri) throws IDCreateException
IIDFactory
createID
in interface IIDFactory
namespace
- the namespace to use to create the IDuri
- the String uri to use to create the IDIDCreateException
- thrown if class for instantiator or ID instance can't be
loaded, if something goes wrong during instance
constructionpublic ID createID(java.lang.String namespace, java.lang.String uri) throws IDCreateException
IIDFactory
IIDFactory.getNamespaceByName(String)
, and then the result is passed into
IIDFactory.createID(Namespace,String)
.createID
in interface IIDFactory
namespace
- the name of the namespace that should be used to create the IDuri
- the String value to use to create the IDIDCreateException
- thrown if class for instantiator or ID instance can't be
loaded, if something goes wrong during instance
constructionpublic ID createStringID(java.lang.String idstring) throws IDCreateException
IIDFactory
createStringID
in interface IIDFactory
idstring
- the String to use as this ID's unique value. Note: It is
incumbent upon the caller of this method to be sure that the
given string allows the resulting ID to satisfy the ID
contract for global uniqueness within the associated
Namespace.IDCreateException
- thrown if class for instantiator or ID instance can't be
loaded, if something goes wrong during instance constructionpublic ID createLongID(long l) throws IDCreateException
IIDFactory
createLongID
in interface IIDFactory
l
- the long to use as this ID's unique value. Note: It is
incumbent upon the caller of this method to be sure that the
given long allows the resulting ID to satisfy the ID contract
for global uniqueness within the associated Namespace.IDCreateException
- thrown if class for instantiator or ID instance can't be
loaded, if something goes wrong during instance constructionpublic Namespace removeNamespace(Namespace n) throws java.lang.SecurityException
IIDFactory
removeNamespace
in interface IIDFactory
n
- the Namespace to removejava.lang.SecurityException
- thrown if caller does not have appropriate
NamespacePermission for given namespacepublic ID createUuID(java.lang.String uuid) throws IDCreateException
IIDFactory
createUuID
in interface IIDFactory
uuid
- the String to use. Must be in UUID format as returned from
UUID.toString(). Must not be null.IDCreateException
public ID createUuID(java.util.UUID uuid) throws IDCreateException
IIDFactory
createUuID
in interface IIDFactory
uuid
- the UUID to use. Must not be null.IDCreateException
public ID createUuID(java.net.URI uuidURI) throws IDCreateException
IIDFactory
createUuID
in interface IIDFactory
uuidURI
- the URI. Must not be null and must be in valid uuid syntax
form as specified by rfc4122 see
http://tools.ietf.org/html/rfc4122. Example:
'uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6'IDCreateException
public ID createURIID(java.net.URI uri) throws IDCreateException
IIDFactory
createURIID
in interface IIDFactory
uri
- the URI to use for the URIID. Must not be null.IDCreateException
public ID createURIID(java.lang.String uri) throws IDCreateException
IIDFactory
createURIID
in interface IIDFactory
uri
- the String to use for the URIID. Must not be null, and must be
valid URI format as per URI.toString().IDCreateException
public ID createUuID() throws IDCreateException
IIDFactory
createUuID
in interface IIDFactory
IDCreateException