Search in sources :

Example 1 with StringID

use of org.eclipse.ecf.core.identity.StringID in project ecf by eclipse.

the class DnsSdNamespace method createInstance.

/* (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[0] instanceof String) {
        String str = (String) parameters[0];
        return new DnsSdServiceTypeID(this, str);
    } else if (parameters != null && parameters.length == 1 && parameters[0] instanceof IServiceTypeID) {
        IServiceTypeID serviceTypeID = (IServiceTypeID) parameters[0];
        return new DnsSdServiceTypeID(this, serviceTypeID);
    } else if (parameters != null && parameters.length == 1 && parameters[0] instanceof IServiceID) {
        IServiceID serviceID = (IServiceID) parameters[0];
        return new DnsSdServiceTypeID(this, serviceID.getServiceTypeID());
    } else if (parameters != null && parameters.length == 1 && parameters[0] instanceof StringID) {
        StringID stringID = (StringID) parameters[0];
        return new DnsSdServiceTypeID(this, stringID.getName());
    } else if (parameters != null && parameters.length == 2 && parameters[0] instanceof IServiceTypeID && parameters[1] instanceof URI) {
        IServiceTypeID serviceTypeID = (IServiceTypeID) parameters[0];
        URI uri = (URI) parameters[1];
        return new DnsSdServiceID(this, new DnsSdServiceTypeID(this, serviceTypeID), uri);
    } else if (parameters != null && parameters.length == 2 && parameters[0] instanceof String && parameters[1] instanceof URI) {
        String serviceType = (String) parameters[0];
        URI uri = (URI) parameters[1];
        return new DnsSdServiceID(this, new DnsSdServiceTypeID(this, serviceType), uri);
    } else {
        throw new IDCreateException(Messages.DnsSdNamespace_Wrong_Parameters);
    }
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) StringID(org.eclipse.ecf.core.identity.StringID) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IServiceID(org.eclipse.ecf.discovery.identity.IServiceID) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 StringID (org.eclipse.ecf.core.identity.StringID)1 IServiceID (org.eclipse.ecf.discovery.identity.IServiceID)1 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)1