Package org.eclipse.ecf.core.identity
Class IDFactory
- java.lang.Object
- 
- org.eclipse.ecf.core.identity.IDFactory
 
- 
- All Implemented Interfaces:
- IIDFactory
 
 public class IDFactory extends Object implements IIDFactory A factory class for creating ID instances. This is the factory for plugins to manufacture ID instances.
- 
- 
Field SummaryFields Modifier and Type Field Description protected static IIDFactoryinstancestatic StringSECURITY_PROPERTY
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NamespaceaddNamespace(Namespace namespace)Add the given Namespace to our table of available Namespacesstatic NamespaceaddNamespace0(Namespace namespace)protected static voidcheckPermission(NamespacePermission namespacepermission)booleancontainsNamespace(Namespace namespace)Check whether table contains given Namespace instancestatic booleancontainsNamespace0(Namespace n)IDcreateGUID()Make a GUID using SHA-1 hash algorithm and a default of 16bits of data length.IDcreateGUID(int length)Make a GUID using SHA-1 hash algorithm and a default of 16bits of data length.IDcreateID(String namespaceName, Object[] args)Make a new identity.IDcreateID(String namespace, String uri)Make a new identity instance from a namespaceName and idValue.IDcreateID(Namespace n, Object[] args)Make a new identity.IDcreateID(Namespace namespace, String uri)Make a new identity instance from a namespace and String.IDcreateLongID(long l)Make a an ID from a longIDcreateStringID(String idstring)Make a an ID from a StringIDcreateURIID(String uri)Create a URIID from String.IDcreateURIID(URI uri)Create a URIID from URI.IDcreateUuID()Create a random UuIDIDcreateUuID(String uuid)Create a UuID from StringIDcreateUuID(URI uuidURI)Create a UuID from URI.IDcreateUuID(UUID uuid)Create a UuID from UUIDstatic IIDFactorygetDefault()NamespacegetNamespace(Namespace namespace)Get the given Namespace instance from tableprotected static NamespacegetNamespace0(String name)protected static NamespacegetNamespace0(Namespace n)NamespacegetNamespaceByName(String name)Get a Namespace instance by its string name.List<Namespace>getNamespaces()Get a list of the current Namespace instances exposed by this factory.protected static voidlogAndThrow(String s, Throwable t)NamespaceremoveNamespace(Namespace n)Remove the given Namespace from our table of available Namespacesstatic NamespaceremoveNamespace0(Namespace n)
 
- 
- 
- 
Field Detail- 
SECURITY_PROPERTYpublic static final String SECURITY_PROPERTY 
 - 
instanceprotected static IIDFactory instance 
 
- 
 - 
Method Detail- 
getDefaultpublic static IIDFactory getDefault() 
 - 
addNamespacepublic Namespace addNamespace(Namespace namespace) throws SecurityException Description copied from interface:IIDFactoryAdd the given Namespace to our table of available Namespaces- Specified by:
- addNamespacein interface- IIDFactory
- Parameters:
- namespace- the Namespace to add
- Returns:
- Namespace the namespace already in table (null if Namespace not previously in table)
- Throws:
- SecurityException- thrown if caller does not have appropriate NamespacePermission for given namespace
 
 - 
checkPermissionprotected static final void checkPermission(NamespacePermission namespacepermission) throws SecurityException - Throws:
- SecurityException
 
 - 
containsNamespacepublic boolean containsNamespace(Namespace namespace) throws SecurityException Description copied from interface:IIDFactoryCheck whether table contains given Namespace instance- Specified by:
- containsNamespacein interface- IIDFactory
- Parameters:
- namespace- the Namespace to look for
- Returns:
- true if table does contain given Namespace, false otherwise
- Throws:
- SecurityException- thrown if caller does not have appropriate NamespacePermission for given namespace
 
 - 
getNamespacespublic List<Namespace> getNamespaces() Description copied from interface:IIDFactoryGet a list of the current Namespace instances exposed by this factory.- Specified by:
- getNamespacesin interface- IIDFactory
- Returns:
- Listof Namespace instances 
 
 - 
containsNamespace0public static final boolean containsNamespace0(Namespace n) 
 - 
getNamespacepublic Namespace getNamespace(Namespace namespace) throws SecurityException Description copied from interface:IIDFactoryGet the given Namespace instance from table- Specified by:
- getNamespacein interface- IIDFactory
- Parameters:
- namespace- the Namespace to look for
- Returns:
- Namespace
- Throws:
- SecurityException- thrown if caller does not have appropriate NamespacePermission for given namespace
 
 - 
getNamespaceByNamepublic Namespace getNamespaceByName(String name) throws SecurityException Description copied from interface:IIDFactoryGet a Namespace instance by its string name.- Specified by:
- getNamespaceByNamein interface- IIDFactory
- Parameters:
- name- the name to use for lookup
- Returns:
- Namespace instance. Null if not found.
- Throws:
- SecurityException- thrown if caller does not have appropriate NamespacePermission for given namespace
 
 - 
createGUIDpublic ID createGUID() throws IDCreateException Description copied from interface:IIDFactoryMake a GUID using SHA-1 hash algorithm and a default of 16bits of data length. The value is Base64 encoded to allow for easy display.- Specified by:
- createGUIDin interface- IIDFactory
- Returns:
- new ID instance
- Throws:
- IDCreateException- if ID cannot be constructed
 
 - 
createGUIDpublic ID createGUID(int length) throws IDCreateException Description copied from interface:IIDFactoryMake a GUID using SHA-1 hash algorithm and a default of 16bits of data length. The value is Base64 encoded to allow for easy display.- Specified by:
- createGUIDin interface- IIDFactory
- Parameters:
- length- the byte-length of data used to create a GUID
- Returns:
- new ID instance
- Throws:
- IDCreateException- if ID cannot be constructed
 
 - 
logAndThrowprotected static void logAndThrow(String s, Throwable t) throws IDCreateException - Throws:
- IDCreateException
 
 - 
createIDpublic ID createID(Namespace n, Object[] args) throws IDCreateException Description copied from interface:IIDFactoryMake a new identity. Given a Namespace, and an array of instance constructor parameters, return a new instance of an ID belonging to the given Namespace- Specified by:
- createIDin interface- IIDFactory
- Parameters:
- n- the Namespace to which the ID will belong
- args- an Object [] of the parameters for the ID instance constructor
- Throws:
- IDCreateException- thrown if class for instantiator or instance can't be loaded, if something goes wrong during instance construction
 
 - 
createIDpublic ID createID(String namespaceName, Object[] args) throws IDCreateException Description copied from interface:IIDFactoryMake a new identity. Given a Namespace name, and an array of instance constructor parameters, return a new instance of an ID belonging to the given Namespace- Specified by:
- createIDin interface- IIDFactory
- Parameters:
- namespaceName- the name of the Namespace to which the ID will belong
- args- an Object [] of the parameters for the ID instance constructor
- Throws:
- IDCreateException- thrown if class for instantiator or ID instance can't be loaded, if something goes wrong during instance construction
 
 - 
createIDpublic ID createID(Namespace namespace, String uri) throws IDCreateException Description copied from interface:IIDFactoryMake a new identity instance from a namespace and String.- Specified by:
- createIDin interface- IIDFactory
- Parameters:
- namespace- the namespace to use to create the ID
- uri- the String uri to use to create the ID
- Throws:
- IDCreateException- thrown if class for instantiator or ID instance can't be loaded, if something goes wrong during instance construction
 
 - 
createIDpublic ID createID(String namespace, String uri) throws IDCreateException Description copied from interface:IIDFactoryMake a new identity instance from a namespaceName and idValue. The namespaceName is first used to lookup the namespace withIIDFactory.getNamespaceByName(String), and then the result is passed intoIIDFactory.createID(Namespace,String).- Specified by:
- createIDin interface- IIDFactory
- Parameters:
- namespace- the name of the namespace that should be used to create the ID
- uri- the String value to use to create the ID
- Throws:
- IDCreateException- thrown if class for instantiator or ID instance can't be loaded, if something goes wrong during instance construction
 
 - 
createStringIDpublic ID createStringID(String idstring) throws IDCreateException Description copied from interface:IIDFactoryMake a an ID from a String- Specified by:
- createStringIDin interface- IIDFactory
- Parameters:
- 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.
- Returns:
- valid ID instance
- Throws:
- IDCreateException- thrown if class for instantiator or ID instance can't be loaded, if something goes wrong during instance construction
 
 - 
createLongIDpublic ID createLongID(long l) throws IDCreateException Description copied from interface:IIDFactoryMake a an ID from a long- Specified by:
- createLongIDin interface- IIDFactory
- Parameters:
- 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.
- Returns:
- valid ID instance
- Throws:
- IDCreateException- thrown if class for instantiator or ID instance can't be loaded, if something goes wrong during instance construction
 
 - 
removeNamespacepublic Namespace removeNamespace(Namespace n) throws SecurityException Description copied from interface:IIDFactoryRemove the given Namespace from our table of available Namespaces- Specified by:
- removeNamespacein interface- IIDFactory
- Parameters:
- n- the Namespace to remove
- Returns:
- Namespace the namespace already in table (null if Namespace not previously in table)
- Throws:
- SecurityException- thrown if caller does not have appropriate NamespacePermission for given namespace
 
 - 
createUuIDpublic ID createUuID(String uuid) throws IDCreateException Description copied from interface:IIDFactoryCreate a UuID from String- Specified by:
- createUuIDin interface- IIDFactory
- Parameters:
- uuid- the String to use. Must be in UUID format as returned from UUID.toString(). Must not be null.
- Returns:
- valid ID instance
- Throws:
- IDCreateException
- Since:
- 3.5
 
 - 
createUuIDpublic ID createUuID(UUID uuid) throws IDCreateException Description copied from interface:IIDFactoryCreate a UuID from UUID- Specified by:
- createUuIDin interface- IIDFactory
- Parameters:
- uuid- the UUID to use. Must not be null.
- Returns:
- valid ID instance
- Throws:
- IDCreateException
- Since:
- 3.5
 
 - 
createUuIDpublic ID createUuID(URI uuidURI) throws IDCreateException Description copied from interface:IIDFactoryCreate a UuID from URI.- Specified by:
- createUuIDin interface- IIDFactory
- Parameters:
- 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'
- Returns:
- valid ID instance
- Throws:
- IDCreateException
- Since:
- 3.5
 
 - 
createURIIDpublic ID createURIID(URI uri) throws IDCreateException Description copied from interface:IIDFactoryCreate a URIID from URI.- Specified by:
- createURIIDin interface- IIDFactory
- Parameters:
- uri- the URI to use for the URIID. Must not be null.
- Returns:
- valid ID instance
- Throws:
- IDCreateException
- Since:
- 3.5
 
 - 
createURIIDpublic ID createURIID(String uri) throws IDCreateException Description copied from interface:IIDFactoryCreate a URIID from String.- Specified by:
- createURIIDin interface- IIDFactory
- Parameters:
- uri- the String to use for the URIID. Must not be null, and must be valid URI format as per URI.toString().
- Returns:
- valid ID instance
- Throws:
- IDCreateException
- Since:
- 3.5
 
 - 
createUuIDpublic ID createUuID() throws IDCreateException Description copied from interface:IIDFactoryCreate a random UuID- Specified by:
- createUuIDin interface- IIDFactory
- Returns:
- valid ID instance from UUID.randomUUID()
- Throws:
- IDCreateException
- Since:
- 3.5
 
 
- 
 
-