org.eclipse.ecf.core.identity
Class IDFactory

java.lang.Object
  extended by org.eclipse.ecf.core.identity.IDFactory
All Implemented Interfaces:
IIDFactory

public class IDFactory
extends java.lang.Object
implements IIDFactory

A factory class for creating ID instances. This is the factory for plugins to manufacture ID instances.


Field Summary
protected static IIDFactory instance
           
static java.lang.String SECURITY_PROPERTY
           
 
Method Summary
 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
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 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
protected static Namespace removeNamespace0(Namespace n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECURITY_PROPERTY

public static final java.lang.String SECURITY_PROPERTY

instance

protected static IIDFactory instance
Method Detail

getDefault

public static IIDFactory getDefault()

addNamespace

public Namespace addNamespace(Namespace namespace)
                       throws java.lang.SecurityException
Description copied from interface: IIDFactory
Add the given Namespace to our table of available Namespaces

Specified by:
addNamespace in interface IIDFactory
Parameters:
namespace - the Namespace to add
Returns:
Namespace the namespace already in table (null if Namespace not previously in table)
Throws:
java.lang.SecurityException - thrown if caller does not have appropriate NamespacePermission for given namespace

addNamespace0

public static final Namespace addNamespace0(Namespace namespace)

checkPermission

protected static final void checkPermission(NamespacePermission namespacepermission)
                                     throws java.lang.SecurityException
Throws:
java.lang.SecurityException

containsNamespace

public boolean containsNamespace(Namespace namespace)
                          throws java.lang.SecurityException
Description copied from interface: IIDFactory
Check whether table contains given Namespace instance

Specified by:
containsNamespace in interface IIDFactory
Parameters:
namespace - the Namespace to look for
Returns:
true if table does contain given Namespace, false otherwise
Throws:
java.lang.SecurityException - thrown if caller does not have appropriate NamespacePermission for given namespace

getNamespaces

public java.util.List getNamespaces()
Description copied from interface: IIDFactory
Get a list of the current Namespace instances exposed by this factory.

Specified by:
getNamespaces in interface IIDFactory
Returns:
List of Namespace instances

containsNamespace0

public static final boolean containsNamespace0(Namespace n)

getNamespace

public Namespace getNamespace(Namespace namespace)
                       throws java.lang.SecurityException
Description copied from interface: IIDFactory
Get the given Namespace instance from table

Specified by:
getNamespace in interface IIDFactory
Parameters:
namespace - the Namespace to look for
Returns:
Namespace
Throws:
java.lang.SecurityException - thrown if caller does not have appropriate NamespacePermission for given namespace

getNamespaceByName

public Namespace getNamespaceByName(java.lang.String name)
                             throws java.lang.SecurityException
Description copied from interface: IIDFactory
Get a Namespace instance by its string name.

Specified by:
getNamespaceByName in interface IIDFactory
Parameters:
name - the name to use for lookup
Returns:
Namespace instance. Null if not found.
Throws:
java.lang.SecurityException - thrown if caller does not have appropriate NamespacePermission for given namespace

getNamespace0

protected static final Namespace getNamespace0(Namespace n)

getNamespace0

protected static final Namespace getNamespace0(java.lang.String name)

createGUID

public ID createGUID()
              throws IDCreateException
Description copied from interface: IIDFactory
Make 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:
createGUID in interface IIDFactory
Returns:
new ID instance
Throws:
IDCreateException - if ID cannot be constructed

createGUID

public ID createGUID(int length)
              throws IDCreateException
Description copied from interface: IIDFactory
Make 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:
createGUID in 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

logAndThrow

protected static void logAndThrow(java.lang.String s,
                                  java.lang.Throwable t)
                           throws IDCreateException
Throws:
IDCreateException

createID

public ID createID(Namespace n,
                   java.lang.Object[] args)
            throws IDCreateException
Description copied from interface: IIDFactory
Make 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:
createID in 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

createID

public ID createID(java.lang.String namespaceName,
                   java.lang.Object[] args)
            throws IDCreateException
Description copied from interface: IIDFactory
Make 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:
createID in 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

createID

public ID createID(Namespace namespace,
                   java.lang.String uri)
            throws IDCreateException
Description copied from interface: IIDFactory
Make a new identity instance from a namespace and String.

Specified by:
createID in 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

createID

public ID createID(java.lang.String namespace,
                   java.lang.String uri)
            throws IDCreateException
Description copied from interface: IIDFactory
Make a new identity instance from a namespaceName and idValue. The namespaceName is first used to lookup the namespace with IIDFactory.getNamespaceByName(String), and then the result is passed into IIDFactory.createID(Namespace,String).

Specified by:
createID in 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

createStringID

public ID createStringID(java.lang.String idstring)
                  throws IDCreateException
Description copied from interface: IIDFactory
Make a an ID from a String

Specified by:
createStringID in 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

createLongID

public ID createLongID(long l)
                throws IDCreateException
Description copied from interface: IIDFactory
Make a an ID from a long

Specified by:
createLongID in 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

removeNamespace

public Namespace removeNamespace(Namespace n)
                          throws java.lang.SecurityException
Description copied from interface: IIDFactory
Remove the given Namespace from our table of available Namespaces

Specified by:
removeNamespace in interface IIDFactory
Parameters:
n - the Namespace to remove
Returns:
Namespace the namespace already in table (null if Namespace not previously in table)
Throws:
java.lang.SecurityException - thrown if caller does not have appropriate NamespacePermission for given namespace

removeNamespace0

protected static final Namespace removeNamespace0(Namespace n)