diff options
| author | slewis | 2005-05-16 04:56:02 +0000 |
|---|---|---|
| committer | slewis | 2005-05-16 04:56:02 +0000 |
| commit | b9ae9e3363ca812742ab363910017c20e9b0d07d (patch) | |
| tree | 75faf93a9d59ba61a9cb5f68a6a7b31bcf32c8d3 | |
| parent | 7434c8145764fae524f09f79a636a6430050d35e (diff) | |
| download | org.eclipse.ecf-b9ae9e3363ca812742ab363910017c20e9b0d07d.tar.gz org.eclipse.ecf-b9ae9e3363ca812742ab363910017c20e9b0d07d.tar.xz org.eclipse.ecf-b9ae9e3363ca812742ab363910017c20e9b0d07d.zip | |
Fixed behavior of ServiceID class
| -rw-r--r-- | framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/ServiceID.java | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/ServiceID.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/ServiceID.java index e4a05b6f0..6bb0b2328 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/ServiceID.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/ServiceID.java @@ -12,40 +12,44 @@ package org.eclipse.ecf.core.identity; import java.net.URI; import java.net.URISyntaxException; - public class ServiceID extends BaseID { private static final long serialVersionUID = 1L; String type; String name; - + protected ServiceID(Namespace namespace, String type, String name) { super(namespace); - if (type == null) throw new NullPointerException("ServiceID type cannot be null"); - if (name == null) throw new NullPointerException("ServiceID name cannot be null"); + if (type == null) + throw new NullPointerException("ServiceID type cannot be null"); this.type = type; this.name = name; } protected String getFullyQualifiedName() { - return type+name; + if (name == null) + return type; + else + return type + name; } + protected int namespaceCompareTo(BaseID o) { if (o instanceof ServiceID) { ServiceID other = (ServiceID) o; String typename = other.getFullyQualifiedName(); - return getFullyQualifiedName().compareTo(typename); + return getFullyQualifiedName().compareTo(typename); } else { return 1; } } protected boolean namespaceEquals(BaseID o) { - if (o == null) return false; + if (o == null) + return false; if (o instanceof ServiceID) { ServiceID other = (ServiceID) o; - if (other.getServiceType().equals(type) && other.getName().equals(name)) { + if (other.getName().equals(getName())) { return true; } } @@ -53,17 +57,27 @@ public class ServiceID extends BaseID { } protected String namespaceGetName() { - return name; + return getFullyQualifiedName(); } protected int namespaceHashCode() { - return name.hashCode(); + return getFullyQualifiedName().hashCode(); } protected URI namespaceToURI() throws URISyntaxException { - throw new URISyntaxException("cannot create URI from service id with name "+getName(),getName()); + throw new URISyntaxException( + "cannot create URI from service id with name " + getName(), + getName()); } + public String getServiceType() { return type; } + + public String toString() { + StringBuffer buf = new StringBuffer("ServiceID["); + buf.append("type=").append(type).append(";name=").append(name).append( + ";full=" + getFullyQualifiedName()).append("]"); + return buf.toString(); + } } |
