diff options
| author | slewis | 2005-05-15 23:34:26 +0000 |
|---|---|---|
| committer | slewis | 2005-05-15 23:34:26 +0000 |
| commit | 3d4c2271765b935df01a1740d8e6f837daf526c1 (patch) | |
| tree | 61bdebc13b0ece8321d94508a8a975977c167e79 | |
| parent | 9d20c247439573f9bf3bb42eecd4551a3288d957 (diff) | |
| download | org.eclipse.ecf-3d4c2271765b935df01a1740d8e6f837daf526c1.tar.gz org.eclipse.ecf-3d4c2271765b935df01a1740d8e6f837daf526c1.tar.xz org.eclipse.ecf-3d4c2271765b935df01a1740d8e6f837daf526c1.zip | |
Added new ServiceID class
| -rw-r--r-- | framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/ServiceID.java | 69 |
1 files changed, 69 insertions, 0 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 new file mode 100644 index 000000000..e4a05b6f0 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/identity/ServiceID.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 Composent, Inc. 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: Composent, Inc. - initial API and implementation + ******************************************************************************/ + +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"); + this.type = type; + this.name = name; + } + + protected String getFullyQualifiedName() { + return type+name; + } + protected int namespaceCompareTo(BaseID o) { + if (o instanceof ServiceID) { + ServiceID other = (ServiceID) o; + String typename = other.getFullyQualifiedName(); + return getFullyQualifiedName().compareTo(typename); + } else { + return 1; + } + } + + protected boolean namespaceEquals(BaseID o) { + if (o == null) return false; + if (o instanceof ServiceID) { + ServiceID other = (ServiceID) o; + if (other.getServiceType().equals(type) && other.getName().equals(name)) { + return true; + } + } + return false; + } + + protected String namespaceGetName() { + return name; + } + + protected int namespaceHashCode() { + return name.hashCode(); + } + + protected URI namespaceToURI() throws URISyntaxException { + throw new URISyntaxException("cannot create URI from service id with name "+getName(),getName()); + } + public String getServiceType() { + return type; + } +} |
