Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-05-14 05:54:58 +0000
committerslewis2008-05-14 05:54:58 +0000
commitbded75abdf05d9b089e147cd4e99f2f4ecfde942 (patch)
tree753143d7f0a8da14cdad782925d712854b3d40ac /providers/bundles/org.eclipse.ecf.provider.jmdns
parent0575142c96742dedd2ce67818c0ccbab3e97fea7 (diff)
downloadorg.eclipse.ecf-bded75abdf05d9b089e147cd4e99f2f4ecfde942.tar.gz
org.eclipse.ecf-bded75abdf05d9b089e147cd4e99f2f4ecfde942.tar.xz
org.eclipse.ecf-bded75abdf05d9b089e147cd4e99f2f4ecfde942.zip
Fix for 231969
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.jmdns')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java43
1 files changed, 34 insertions, 9 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
index 0f4aa9378..f72ca791e 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
@@ -12,6 +12,7 @@ package org.eclipse.ecf.provider.jmdns.identity;
import org.eclipse.ecf.core.identity.*;
import org.eclipse.ecf.internal.provider.jmdns.Messages;
+import org.eclipse.osgi.util.NLS;
public class JMDNSNamespace extends Namespace {
@@ -28,20 +29,44 @@ public class JMDNSNamespace extends Namespace {
super();
}
+ 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;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ecf.core.identity.Namespace#createInstance(java.lang.Object[])
*/
public ID createInstance(Object[] parameters) throws IDCreateException {
- if (parameters == null || parameters.length < 1 || parameters.length > 2) {
- throw new IDCreateException(Messages.JMDNSNamespace_EXCEPTION_ID_WRONG_PARAM_COUNT);
- }
String type = null;
- if (parameters[0] instanceof JMDNSServiceTypeID) {
- type = ((JMDNSServiceTypeID) parameters[0]).getInternal();
- } else if (parameters[0] instanceof String) {
- type = (String) parameters[0];
- } else
- throw new IDCreateException(Messages.JMDNSNamespace_EXCEPTION_TYPE_PARAM_NOT_STRING);
+ try {
+ String init = getInitFromExternalForm(parameters);
+ if (init != null)
+ type = init;
+ else {
+ if (parameters == null || parameters.length < 1 || parameters.length > 2) {
+ throw new IDCreateException(Messages.JMDNSNamespace_EXCEPTION_ID_WRONG_PARAM_COUNT);
+ }
+ if (parameters[0] instanceof JMDNSServiceTypeID) {
+ type = ((JMDNSServiceTypeID) parameters[0]).getInternal();
+ } else if (parameters[0] instanceof String) {
+ type = (String) parameters[0];
+ } else
+ throw new IDCreateException(Messages.JMDNSNamespace_EXCEPTION_TYPE_PARAM_NOT_STRING);
+ }
+ } catch (Exception e) {
+ throw new IDCreateException(NLS.bind("{0} createInstance()", getName()), e); //$NON-NLS-1$
+ }
final JMDNSServiceTypeID stid = new JMDNSServiceTypeID(this, type);
String name = null;

Back to the top