Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.identity/src/org')
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java6
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java2
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java7
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java50
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java86
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java2
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java4
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java2
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java4
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/UuID.java109
10 files changed, 253 insertions, 19 deletions
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java
index 8cebd0fba..c86517199 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java
@@ -27,7 +27,7 @@ public abstract class BaseID implements ID {
protected Namespace namespace;
protected BaseID() {
- //
+ //
}
protected BaseID(Namespace namespace) {
@@ -151,11 +151,11 @@ public abstract class BaseID implements ID {
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
- public Object getAdapter(Class clazz) {
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class clazz) {
IAdapterManager adapterManager = Activator.getDefault()
.getAdapterManager();
if (adapterManager == null)
return null;
- return adapterManager.loadAdapter(this, clazz.getName());
+ return adapterManager.getAdapter(this, clazz.getName());
}
} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java
index 1155ff46c..27f2156bf 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java
@@ -55,7 +55,7 @@ public class GUID extends StringID {
* @seeorg.eclipse.ecf.core.identity.Namespace#
* getSupportedParameterTypesForCreateInstance()
*/
- public Class[][] getSupportedParameterTypes() {
+ public Class<?>[][] getSupportedParameterTypes() {
return new Class[][] { {}, { Integer.class } };
}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java
index cd44eb8a8..6704290a6 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/ID.java
@@ -29,7 +29,9 @@ import org.eclipse.core.runtime.IAdaptable;
* @see Namespace
*
*/
-public interface ID extends java.io.Serializable, java.lang.Comparable, java.security.Principal, IAdaptable {
+@SuppressWarnings("rawtypes")
+public interface ID extends java.io.Serializable, java.lang.Comparable,
+ java.security.Principal, IAdaptable {
public boolean equals(Object obj);
@@ -53,7 +55,8 @@ public interface ID extends java.io.Serializable, java.lang.Comparable, java.sec
public Namespace getNamespace();
/**
- * Get this ID instance in String form. Will not return null.
+ * Get this ID instance in String form. Will not return null.
+ *
* @return String that is external representation of this ID
*/
public String toExternalForm();
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java
index d56bd52d6..1ff885d4f 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IDFactory.java
@@ -8,6 +8,7 @@
******************************************************************************/
package org.eclipse.ecf.core.identity;
+import java.net.URI;
import java.util.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -22,7 +23,7 @@ public class IDFactory implements IIDFactory {
public static final String SECURITY_PROPERTY = IDFactory.class.getName()
+ ".security"; //$NON-NLS-1$
- private static Hashtable namespaces = new Hashtable();
+ private static Hashtable<String, Namespace> namespaces = new Hashtable<String, Namespace>();
protected static IIDFactory instance = null;
@@ -32,6 +33,7 @@ public class IDFactory implements IIDFactory {
addNamespace0(new GUID.GUIDNamespace());
addNamespace0(new LongID.LongNamespace());
addNamespace0(new URIID.URIIDNamespace());
+ addNamespace0(new UuID.UuIDNamespace());
}
private synchronized static void initialize() {
@@ -96,9 +98,9 @@ public class IDFactory implements IIDFactory {
*
* @see org.eclipse.ecf.core.identity.IIDFactory#getNamespaces()
*/
- public List getNamespaces() {
+ public List<Namespace> getNamespaces() {
initialize();
- return new ArrayList(namespaces.values());
+ return new ArrayList<Namespace>(namespaces.values());
}
public final static boolean containsNamespace0(Namespace n) {
@@ -267,4 +269,46 @@ public class IDFactory implements IIDFactory {
return null;
return (Namespace) namespaces.remove(n.getName());
}
+
+ /**
+ * @since 3.5
+ */
+ public ID createUuID(String uuid) throws IDCreateException {
+ return createID(new UuID.UuIDNamespace(), new Object[] { uuid });
+ }
+
+ /**
+ * @since 3.5
+ */
+ public ID createUuID(UUID uuid) throws IDCreateException {
+ return createID(new UuID.UuIDNamespace(), new Object[] { uuid });
+ }
+
+ /**
+ * @since 3.5
+ */
+ public ID createUuID(URI uuidURI) throws IDCreateException {
+ return createID(new UuID.UuIDNamespace(), new Object[] { uuidURI });
+ }
+
+ /**
+ * @since 3.5
+ */
+ public ID createURIID(URI uri) throws IDCreateException {
+ return createID(new URIID.URIIDNamespace(), new Object[] { uri });
+ }
+
+ /**
+ * @since 3.5
+ */
+ public ID createURIID(String uri) throws IDCreateException {
+ return createID(new URIID.URIIDNamespace(), new Object[] { uri });
+ }
+
+ /**
+ * @since 3.5
+ */
+ public ID createUuID() throws IDCreateException {
+ return createID(new UuID.UuIDNamespace(), (Object[]) null);
+ }
} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java
index 54bac357e..7619e2901 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/IIDFactory.java
@@ -8,11 +8,14 @@
******************************************************************************/
package org.eclipse.ecf.core.identity;
+import java.net.URI;
import java.util.List;
+import java.util.UUID;
/**
* Contract for {@link IDFactory}
*
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IIDFactory {
/**
@@ -48,7 +51,7 @@ public interface IIDFactory {
* thrown if caller does not have appropriate
* NamespacePermission for given namespace
*/
- public List getNamespaces() throws SecurityException;
+ public List<Namespace> getNamespaces() throws SecurityException;
/**
* Get the given Namespace instance from table
@@ -126,7 +129,8 @@ public interface IIDFactory {
* loaded, if something goes wrong during instance
* construction
*/
- public ID createID(String namespaceName, Object[] args) throws IDCreateException;
+ public ID createID(String namespaceName, Object[] args)
+ throws IDCreateException;
/**
* Make a new identity instance from a namespace and String.
@@ -140,7 +144,8 @@ public interface IIDFactory {
* loaded, if something goes wrong during instance
* construction
*/
- public ID createID(Namespace namespace, String uri) throws IDCreateException;
+ public ID createID(Namespace namespace, String uri)
+ throws IDCreateException;
/**
* Make a new identity instance from a namespaceName and idValue. The
@@ -157,7 +162,8 @@ public interface IIDFactory {
* loaded, if something goes wrong during instance
* construction
*/
- public ID createID(String namespaceName, String idValue) throws IDCreateException;
+ public ID createID(String namespaceName, String idValue)
+ throws IDCreateException;
/**
* Make a an ID from a String
@@ -193,6 +199,78 @@ public interface IIDFactory {
public ID createLongID(long l) throws IDCreateException;
/**
+ * Create a UuID from String
+ *
+ * @param uuid
+ * the String to use. Must be in UUID format as returned from
+ * UUID.toString(). Must not be null.
+ * @return valid ID instance
+ *
+ * @since 3.5
+ */
+ public ID createUuID(String uuid) throws IDCreateException;
+
+ /**
+ * Create a UuID from UUID
+ *
+ * @param uuid
+ * the UUID to use. Must not be null.
+ * @return valid ID instance
+ *
+ * @since 3.5
+ */
+ public ID createUuID(UUID uuid) throws IDCreateException;
+
+ /**
+ * Create a random UuID
+ *
+ * @return valid ID instance from UUID.randomUUID()
+ *
+ * @since 3.5
+ */
+ public ID createUuID() throws IDCreateException;
+
+ /**
+ * Create a UuID from URI.
+ *
+ * @param 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'
+ *
+ * @return valid ID instance
+ *
+ * @since 3.5
+ */
+ public ID createUuID(URI uuidURI) throws IDCreateException;
+
+ /**
+ * Create a URIID from URI.
+ *
+ * @param uri
+ * the URI to use for the URIID. Must not be null.
+ *
+ * @return valid ID instance
+ *
+ * @since 3.5
+ */
+ public ID createURIID(URI uri) throws IDCreateException;
+
+ /**
+ * Create a URIID from String.
+ *
+ * @param uri
+ * the String to use for the URIID. Must not be null, and must be
+ * valid URI format as per URI.toString().
+ *
+ * @return valid ID instance
+ *
+ * @since 3.5
+ */
+ public ID createURIID(String uri) throws IDCreateException;
+
+ /**
* Remove the given Namespace from our table of available Namespaces
*
* @param n
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java
index fabb7b487..8a0124b23 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java
@@ -52,7 +52,7 @@ public class LongID extends BaseID {
* @seeorg.eclipse.ecf.core.identity.Namespace#
* getSupportedParameterTypesForCreateInstance()
*/
- public Class[][] getSupportedParameterTypes() {
+ public Class<?>[][] getSupportedParameterTypes() {
return new Class[][] { { Long.class } };
}
}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java
index 53a31fcbc..46663b789 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java
@@ -282,7 +282,7 @@ public abstract class Namespace implements Serializable, IAdaptable {
* Class arrays are returned (i.e. Class[0][0]), then Object []
* parameters to {@link #createInstance(Object[])} will be ignored.
*/
- public Class[][] getSupportedParameterTypes() {
+ public Class<?>[][] getSupportedParameterTypes() {
return new Class[][] { {} };
}
@@ -291,7 +291,7 @@ public abstract class Namespace implements Serializable, IAdaptable {
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
- public Object getAdapter(Class adapter) {
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
if (adapter.isInstance(this)) {
return this;
}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java
index eb508dde3..a11401e18 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java
@@ -48,7 +48,7 @@ public class StringID extends BaseID {
* @seeorg.eclipse.ecf.core.identity.Namespace#
* getSupportedParameterTypesForCreateInstance()
*/
- public Class[][] getSupportedParameterTypes() {
+ public Class<?>[][] getSupportedParameterTypes() {
return new Class[][] { { String.class } };
}
}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java
index 661fbc7d0..2f9eea886 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java
@@ -57,7 +57,7 @@ public class URIID extends BaseID implements IResourceID {
* @seeorg.eclipse.ecf.core.identity.Namespace#
* getSupportedParameterTypesForCreateInstance()
*/
- public Class[][] getSupportedParameterTypes() {
+ public Class<?>[][] getSupportedParameterTypes() {
return new Class[][] { { String.class }, { URI.class } };
}
}
@@ -76,7 +76,7 @@ public class URIID extends BaseID implements IResourceID {
return 0;
if (!this.getClass().equals(o.getClass()))
return Integer.MIN_VALUE;
- return this.uri.compareTo((Object) ((URIID) o).uri);
+ return this.uri.compareTo(((URIID) o).uri);
}
protected boolean namespaceEquals(BaseID o) {
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/UuID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/UuID.java
new file mode 100644
index 000000000..8e8675e90
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/UuID.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Composent and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Scott Lewis - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.identity;
+
+import java.net.URI;
+import java.util.UUID;
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * @since 3.5
+ */
+public class UuID extends BaseID {
+
+ private static final long serialVersionUID = -2586540125532542205L;
+
+ public static class UuIDNamespace extends Namespace {
+
+ private static final long serialVersionUID = -7708511830843215943L;
+ public static final String SCHEME = "uuid";
+
+ public UuIDNamespace() {
+ this(UuID.class.getName(), "UuID Namespace");
+ }
+
+ public UuIDNamespace(String name, String description) {
+ super(name, description);
+ }
+
+ @Override
+ public ID createInstance(Object[] parameters) throws IDCreateException {
+ try {
+ String init = getInitStringFromExternalForm(parameters);
+ if (init != null)
+ return new UuID(this, UUID.fromString(init));
+ if (parameters != null && parameters.length > 0) {
+ if (parameters[0] instanceof String)
+ return new UuID(this,
+ UUID.fromString((String) parameters[0]));
+ else if (parameters[0] instanceof URI)
+ return new UuID(this,
+ UUID.fromString(((URI) parameters[0])
+ .getSchemeSpecificPart()));
+ else if (parameters[0] instanceof UUID)
+ return new UuID(this, (UUID) parameters[0]);
+ }
+ // If we get here, then use random
+ return new UuID(this, UUID.randomUUID());
+ } catch (Exception e) {
+ throw new IDCreateException(UuIDNamespace.this.getName()
+ + " createInstance()", e); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public String getScheme() {
+ return SCHEME;
+ }
+
+ @Override
+ public Class<?>[][] getSupportedParameterTypes() {
+ return new Class[][] { { String.class }, { UUID.class },
+ { URI.class } };
+ }
+ }
+
+ protected final UUID uuid;
+
+ protected UuID(UuIDNamespace ns, UUID uuid) {
+ super(ns);
+ Assert.isNotNull(uuid);
+ this.uuid = uuid;
+ }
+
+ protected int namespaceCompareTo(BaseID obj) {
+ return getName().compareTo(obj.getName());
+ }
+
+ protected boolean namespaceEquals(BaseID obj) {
+ if (!(obj instanceof UuID))
+ return false;
+ UuID o = (UuID) obj;
+ return uuid.equals(o.uuid);
+ }
+
+ protected String namespaceGetName() {
+ return uuid.toString();
+ }
+
+ protected int namespaceHashCode() {
+ return uuid.hashCode() ^ getClass().hashCode();
+ }
+
+ public UUID getUUID() {
+ return uuid;
+ }
+
+ @Override
+ public String toString() {
+ return "UuID[uuid=" + uuid + "]";
+ }
+
+}

Back to the top