diff options
author | slewis | 2009-11-13 20:26:27 +0000 |
---|---|---|
committer | slewis | 2009-11-13 20:26:27 +0000 |
commit | 390b341301a7f94dfeb5a1c35d908acb847d388e (patch) | |
tree | 07f24c7172095a68fb346759f72aafb24c5c4677 /framework/bundles/org.eclipse.ecf.identity/src/org | |
parent | 1347a38220006141f159e46b23710a706026b206 (diff) | |
download | org.eclipse.ecf-390b341301a7f94dfeb5a1c35d908acb847d388e.tar.gz org.eclipse.ecf-390b341301a7f94dfeb5a1c35d908acb847d388e.tar.xz org.eclipse.ecf-390b341301a7f94dfeb5a1c35d908acb847d388e.zip |
Fixed build.properties and added Namespace method
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.identity/src/org')
4 files changed, 106 insertions, 100 deletions
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 3e725d943..53528ea5b 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 @@ -26,27 +26,13 @@ public class GUID extends StringID { private static final long serialVersionUID = -8546568877571886386L; public GUIDNamespace() { - super(GUID.class.getName(), Messages.GUID_GUID_Namespace_Description_Default); - } - - private String getInitFromExternalForm(Object[] args) { - if (args == null || args.length < 1 || args[0] == null) - return null; - if (args[0] instanceof String) { - String arg = (String) args[0]; - if (arg.startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) { - int index = arg.indexOf(Namespace.SCHEME_SEPARATOR); - if (index >= arg.length()) - return null; - return arg.substring(index + 1); - } - } - return null; + super(GUID.class.getName(), + Messages.GUID_GUID_Namespace_Description_Default); } public ID createInstance(Object[] args) throws IDCreateException { try { - String init = getInitFromExternalForm(args); + String init = getInitStringFromExternalForm(args); if (init != null) return new GUID(this, init); if (args == null || args.length <= 0) @@ -58,7 +44,8 @@ public class GUID extends StringID { else return new GUID(this); } catch (Exception e) { - throw new IDCreateException(NLS.bind("{0} createInstance()", getName()), e); //$NON-NLS-1$ + throw new IDCreateException(NLS.bind( + "{0} createInstance()", getName()), e); //$NON-NLS-1$ } } @@ -69,10 +56,11 @@ public class GUID extends StringID { /* * (non-Javadoc) * - * @see org.eclipse.ecf.core.identity.Namespace#getSupportedParameterTypesForCreateInstance() + * @seeorg.eclipse.ecf.core.identity.Namespace# + * getSupportedParameterTypesForCreateInstance() */ public Class[][] getSupportedParameterTypes() { - return new Class[][] { {}, {Integer.class}}; + return new Class[][] { {}, { Integer.class } }; } } @@ -96,13 +84,15 @@ public class GUID extends StringID { * @param byteLength * the length of the target number (in bytes) */ - protected GUID(Namespace n, String algo, String provider, int byteLength) throws IDCreateException { + protected GUID(Namespace n, String algo, String provider, int byteLength) + throws IDCreateException { super(n, ""); //$NON-NLS-1$ // Get SecureRandom instance for class try { getRandom(algo, provider); } catch (Exception e) { - throw new IDCreateException(Messages.GUID_GUID_Creation_Failure + e.getMessage()); + throw new IDCreateException(Messages.GUID_GUID_Creation_Failure + + e.getMessage()); } // make sure we have reasonable byteLength if (byteLength <= 0) @@ -139,7 +129,8 @@ public class GUID extends StringID { * @exception Exception * thrown if SecureRandom instance cannot be created/accessed */ - protected static synchronized SecureRandom getRandom(String algo, String provider) throws Exception { + protected static synchronized SecureRandom getRandom(String algo, + String provider) throws Exception { // Given algo and provider, get SecureRandom instance if (random == null) { initializeRandom(algo, provider); @@ -147,11 +138,13 @@ public class GUID extends StringID { return random; } - protected static synchronized void initializeRandom(String algo, String provider) throws Exception { + protected static synchronized void initializeRandom(String algo, + String provider) throws Exception { if (provider == null) { if (algo == null) { try { - random = SecureRandom.getInstance(Messages.GUID_IBM_SECURE_RANDOM); + random = SecureRandom + .getInstance(Messages.GUID_IBM_SECURE_RANDOM); } catch (Exception e) { random = SecureRandom.getInstance(Messages.GUID_SHA1); } 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 d091008dc..3e00d5054 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 @@ -26,34 +26,22 @@ public class LongID extends BaseID { super(LongID.class.getName(), "LongID Namespace"); //$NON-NLS-1$ } - private String getInitFromExternalForm(Object[] args) { - if (args == null || args.length < 1 || args[0] == null) - return null; - if (args[0] instanceof String) { - String arg = (String) args[0]; - if (arg.startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) { - int index = arg.indexOf(Namespace.SCHEME_SEPARATOR); - if (index >= arg.length()) - return null; - return arg.substring(index + 1); - } - } - return null; - } - /** - * @param args must not be <code>null></code> - * @return ID created. Will not be <code>null</code>. - * @throws IDCreateException never thrown + * @param args + * must not be <code>null></code> + * @return ID created. Will not be <code>null</code>. + * @throws IDCreateException + * never thrown */ public ID createInstance(Object[] args) throws IDCreateException { try { - String init = getInitFromExternalForm(args); + String init = getInitStringFromExternalForm(args); if (init != null) return new LongID(this, Long.decode(init)); return new LongID(this, (Long) args[0]); } catch (Exception e) { - throw new IDCreateException(NLS.bind("{0} createInstance()", getName()), e); //$NON-NLS-1$ + throw new IDCreateException(NLS.bind( + "{0} createInstance()", getName()), e); //$NON-NLS-1$ } } @@ -64,10 +52,11 @@ public class LongID extends BaseID { /* * (non-Javadoc) * - * @see org.eclipse.ecf.core.identity.Namespace#getSupportedParameterTypesForCreateInstance() + * @seeorg.eclipse.ecf.core.identity.Namespace# + * getSupportedParameterTypesForCreateInstance() */ public Class[][] getSupportedParameterTypes() { - return new Class[][] {{Long.class}}; + 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 0378a8221..a3f46a4da 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 @@ -88,9 +88,9 @@ public abstract class Namespace implements Serializable, IAdaptable { } /** - * Hashcode implementation. Subclasses should not override. + * Hashcode implementation. Subclasses should not override. * - * @return int hashCode for this Namespace. Should be unique. + * @return int hashCode for this Namespace. Should be unique. */ public int hashCode() { return hashCode; @@ -98,9 +98,13 @@ public abstract class Namespace implements Serializable, IAdaptable { /** * Test whether two IDs are equal to one another. - * @param first the first ID. Must not be <code>null</code>. - * @param second the second ID. Must not be <code>null</code>. - * @return <code>true</code> if this ID is equal to the given ID. <code>false</code> otherwise. + * + * @param first + * the first ID. Must not be <code>null</code>. + * @param second + * the second ID. Must not be <code>null</code>. + * @return <code>true</code> if this ID is equal to the given ID. + * <code>false</code> otherwise. */ protected boolean testIDEquals(BaseID first, BaseID second) { // First check that namespaces are the same and non-null @@ -111,22 +115,26 @@ public abstract class Namespace implements Serializable, IAdaptable { } /** - * The default implementation of this method is to call id.namespaceGetName(). Subclasses may - * override. + * The default implementation of this method is to call + * id.namespaceGetName(). Subclasses may override. * - * @param id the ID to get the name for. Must not be <code>null</code>. - * @return String that is the unique name for the given id within this Namespace. + * @param id + * the ID to get the name for. Must not be <code>null</code>. + * @return String that is the unique name for the given id within this + * Namespace. */ protected String getNameForID(BaseID id) { return id.namespaceGetName(); } /** - * The default implementation of this method is to call first.namespaceCompareTo(second). Subclasses may - * override. + * The default implementation of this method is to call + * first.namespaceCompareTo(second). Subclasses may override. * - * @param first the first id to compare. Must not be <code>null</code>. - * @param second the second id to compare. Must not be <code>null</code>. + * @param first + * the first id to compare. Must not be <code>null</code>. + * @param second + * the second id to compare. Must not be <code>null</code>. * @return int as specified by {@link Comparable}. */ protected int getCompareToForObject(BaseID first, BaseID second) { @@ -134,24 +142,30 @@ public abstract class Namespace implements Serializable, IAdaptable { } /** - * The default implementation of this method is to call id.namespaceHashCode(). Subclasses may - * override. + * The default implementation of this method is to call + * id.namespaceHashCode(). Subclasses may override. * - * @param id the id in this Namespace to get the hashcode for. Must not be <code>null</code>. - * @return the hashcode for the given id. Returned value must be unique within this process. + * @param id + * the id in this Namespace to get the hashcode for. Must not be + * <code>null</code>. + * @return the hashcode for the given id. Returned value must be unique + * within this process. */ protected int getHashCodeForID(BaseID id) { return id.namespaceHashCode(); } /** - * The default implementation of this method is to call id.namespaceToExternalForm(). Subclasses may - * override. + * The default implementation of this method is to call + * id.namespaceToExternalForm(). Subclasses may override. * - * @param id the id in this Namespace to convert to external form. - * @return String that represents the given id in an external form. Note that - * this external form may at some later time be passed to {@link #createInstance(Object[])} as a single - * String parameter, and should result in a valid ID instance of the appropriate Namespace. + * @param id + * the id in this Namespace to convert to external form. + * @return String that represents the given id in an external form. Note + * that this external form may at some later time be passed to + * {@link #createInstance(Object[])} as a single String parameter, + * and should result in a valid ID instance of the appropriate + * Namespace. */ protected String toExternalForm(BaseID id) { return id.namespaceToExternalForm(); @@ -160,8 +174,9 @@ public abstract class Namespace implements Serializable, IAdaptable { /** * Get the name of this namespace. Must not return <code>null</code>. * - * @return String name of Namespace instance. Must not return <code>null</code>, and - * the returned value should be a globally unique name for this Namespace subclass. + * @return String name of Namespace instance. Must not return + * <code>null</code>, and the returned value should be a globally + * unique name for this Namespace subclass. * */ public String getName() { @@ -172,7 +187,8 @@ public abstract class Namespace implements Serializable, IAdaptable { * Get the description, associated with this Namespace. The returned value * may be <code>null</code>. * - * @return the description associated with this Namespace. May be <code>null</code>. + * @return the description associated with this Namespace. May be + * <code>null</code>. */ public String getDescription() { return description; @@ -198,13 +214,14 @@ public abstract class Namespace implements Serializable, IAdaptable { * @throws IDCreateException * if construction fails */ - public abstract ID createInstance(Object[] parameters) throws IDCreateException; + public abstract ID createInstance(Object[] parameters) + throws IDCreateException; /** * Get the primary scheme associated with this namespace. Subclasses must * provide an implementation that returns a non-<code>null</code> scheme - * identifier. Note that the returned scheme should <b>not</b> contain the - * Namespace.SCHEME_SEPARATOR (\":\"). + * identifier. Note that the returned scheme should <b>not</b> contain the + * Namespace.SCHEME_SEPARATOR (\":\"). * * @return a String scheme identifier. Must not be <code>null</code>. */ @@ -250,8 +267,8 @@ public abstract class Namespace implements Serializable, IAdaptable { * </pre> * * The above means that there are two acceptable values for the Object [] - * passed into {@link #createInstance(Object[])}: 1) a single String, and - * 2) two Strings. These would therefore be acceptable as input to + * passed into {@link #createInstance(Object[])}: 1) a single String, and 2) + * two Strings. These would therefore be acceptable as input to * createInstance: * * <pre> @@ -266,10 +283,12 @@ public abstract class Namespace implements Serializable, IAdaptable { * parameters to {@link #createInstance(Object[])} will be ignored. */ public Class[][] getSupportedParameterTypes() { - return new Class[][] {{}}; + return new Class[][] { {} }; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter(Class adapter) { @@ -282,6 +301,21 @@ public abstract class Namespace implements Serializable, IAdaptable { return manager.loadAdapter(this, adapter.getName()); } + protected String getInitStringFromExternalForm(Object[] args) { + if (args == null || args.length < 1 || args[0] == null) + return null; + if (args[0] instanceof String) { + final String arg = (String) args[0]; + if (arg.startsWith(getScheme() + SCHEME_SEPARATOR)) { + final int index = arg.indexOf(SCHEME_SEPARATOR); + if (index >= arg.length()) + return null; + return arg.substring(index + 1); + } + } + return null; + } + public String toString() { StringBuffer b = new StringBuffer("Namespace["); //$NON-NLS-1$ b.append("name=").append(name).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ 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 9e4a3b457..2b00e877e 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 @@ -28,29 +28,17 @@ public class StringID extends BaseID { super(StringID.class.getName(), "StringID Namespace"); //$NON-NLS-1$ } - private String getInitFromExternalForm(Object[] args) { - if (args == null || args.length < 1 || args[0] == null) - return null; - if (args[0] instanceof String) { - String arg = (String) args[0]; - if (arg.startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) { - int index = arg.indexOf(Namespace.SCHEME_SEPARATOR); - if (index >= arg.length()) - return null; - return arg.substring(index + 1); - } - } - return null; - } - public ID createInstance(Object[] parameters) throws IDCreateException { try { - String init = getInitFromExternalForm(parameters); + String init = getInitStringFromExternalForm(parameters); if (init != null) return new StringID(this, init); return new StringID(this, (String) parameters[0]); } catch (Exception e) { - throw new IDCreateException(NLS.bind("{0} createInstance()", StringIDNamespace.this.getName()), e); //$NON-NLS-1$ + throw new IDCreateException( + NLS + .bind( + "{0} createInstance()", StringIDNamespace.this.getName()), e); //$NON-NLS-1$ } } @@ -61,10 +49,11 @@ public class StringID extends BaseID { /* * (non-Javadoc) * - * @see org.eclipse.ecf.core.identity.Namespace#getSupportedParameterTypesForCreateInstance() + * @seeorg.eclipse.ecf.core.identity.Namespace# + * getSupportedParameterTypesForCreateInstance() */ public Class[][] getSupportedParameterTypes() { - return new Class[][] {{String.class}}; + return new Class[][] { { String.class } }; } } @@ -143,7 +132,8 @@ public class StringID extends BaseID { protected synchronized void setEmptyNamespace() { if (namespace == null) { - namespace = IDFactory.getDefault().getNamespaceByName(StringID.class.getName()); + namespace = IDFactory.getDefault().getNamespaceByName( + StringID.class.getName()); } } |