diff options
Diffstat (limited to '')
-rw-r--r-- | sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java | 105 |
1 files changed, 81 insertions, 24 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java index 65f1000265..ee7e5ba1bd 100644 --- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java +++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java @@ -65,9 +65,9 @@ import org.osgi.framework.Version; public class EndpointDescription { private final Map<String, Object> properties; private final List<String> interfaces; - private final long remoteServiceID; - private final String remoteFrameworkUUID; - private final String remoteID; + private final long serviceId; + private final String frameworkUUID; + private final String id; /** * Create an Endpoint Description from a Map. @@ -110,10 +110,10 @@ public class EndpointDescription { this.properties = Collections.unmodifiableMap(props); /* properties must be initialized before calling the following methods */ interfaces = verifyObjectClassProperty(); - remoteServiceID = verifyLongProperty(ENDPOINT_SERVICE_ID); - remoteFrameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); - remoteID = verifyStringProperty(ENDPOINT_ID); - if (remoteID == null) { + serviceId = verifyLongProperty(ENDPOINT_SERVICE_ID); + frameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); + id = verifyStringProperty(ENDPOINT_ID); + if (id == null) { throw new IllegalArgumentException(ENDPOINT_ID + " property must be set"); } @@ -204,10 +204,10 @@ public class EndpointDescription { this.properties = Collections.unmodifiableMap(props); /* properties must be initialized before calling the following methods */ interfaces = verifyObjectClassProperty(); - remoteServiceID = verifyLongProperty(ENDPOINT_SERVICE_ID); - remoteFrameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); - remoteID = verifyStringProperty(ENDPOINT_ID); - if (remoteID == null) { + serviceId = verifyLongProperty(ENDPOINT_SERVICE_ID); + frameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); + id = verifyStringProperty(ENDPOINT_ID); + if (id == null) { throw new IllegalArgumentException(ENDPOINT_ID + " property must be set"); } @@ -312,8 +312,8 @@ public class EndpointDescription { * * @return The id of the endpoint, never <code>null</code>. */ - public String getRemoteID() { - return remoteID; + public String getId() { + return id; } /** @@ -382,8 +382,8 @@ public class EndpointDescription { * not relate to an OSGi service. * */ - public long getRemoteServiceID() { - return remoteServiceID; + public long getServiceId() { + return serviceId; } /** @@ -477,8 +477,8 @@ public class EndpointDescription { * @return Remote Framework UUID, or null if this endpoint is not associated * with an OSGi framework having a framework uuid. */ - public String getRemoteFrameworkUUID() { - return remoteFrameworkUUID; + public String getFrameworkUUID() { + return frameworkUUID; } /** @@ -507,13 +507,13 @@ public class EndpointDescription { return true; } - if (this.getRemoteFrameworkUUID() == null) { + if (this.getFrameworkUUID() == null) { return false; } - return (this.getRemoteServiceID() == other.getRemoteServiceID()) - && this.getRemoteFrameworkUUID().equals( - other.getRemoteFrameworkUUID()); + return (this.getServiceId() == other.getServiceId()) + && this.getFrameworkUUID().equals( + other.getFrameworkUUID()); } /** @@ -522,7 +522,7 @@ public class EndpointDescription { * @return An integer which is a hash code value for this object. */ public int hashCode() { - return getRemoteID().hashCode(); + return getId().hashCode(); } /** @@ -544,8 +544,8 @@ public class EndpointDescription { if (!(other instanceof EndpointDescription)) { return false; } - return getRemoteID().equals( - ((EndpointDescription) other).getRemoteID()); + return getId().equals( + ((EndpointDescription) other).getId()); } /** @@ -580,6 +580,63 @@ public class EndpointDescription { } /** + * Returns the string representation of this EndpointDescription. + * + * @return String form of this EndpointDescription. + */ + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append('{'); + Iterator<Map.Entry<String, Object>> iter = properties.entrySet() + .iterator(); + boolean comma = false; + while (iter.hasNext()) { + Map.Entry<String, Object> entry = iter.next(); + if (comma) { + sb.append(", "); + } + else { + comma = true; + } + sb.append(entry.getKey()); + sb.append('='); + Object value = entry.getValue(); + if (value != null) { + Class< ? > valueType = value.getClass(); + if (Object[].class.isAssignableFrom(valueType)) { + append(sb, (Object[]) value); + continue; + } + } + sb.append(value); + } + sb.append('}'); + return sb.toString(); + } + + /** + * Append the specified Object array to the specified StringBuffer. + * + * @param sb Receiving StringBuffer. + * @param value Object array to append to the specified StringBuffer. + */ + private static void append(StringBuffer sb, Object[] value) { + sb.append('['); + boolean comma = false; + final int length = value.length; + for (int i = 0; i < length; i++) { + if (comma) { + sb.append(", "); + } + else { + comma = true; + } + sb.append(String.valueOf(value[i])); + } + sb.append(']'); + } + + /** * Unmodifiable Dictionary wrapper for a Map. This class is also used by * EndpointPermission. */ |