Search in sources :

Example 6 with IChatID

use of org.eclipse.ecf.presence.im.IChatID in project ecf by eclipse.

the class ChatRoomManagerView method getHostnameFromID.

/**
 * @return String hostname for given <code>targetID</code>
 */
public static String getHostnameFromID(ID targetID) {
    IChatID chatID = (IChatID) targetID.getAdapter(IChatID.class);
    if (chatID != null)
        return chatID.getHostname();
    try {
        URI uri = new URI(targetID.getName());
        String host = uri.getHost();
        return host == null ? targetID.getName() : host;
    } catch (URISyntaxException e) {
        String userAtHost = targetID.getName();
        int atIndex = userAtHost.lastIndexOf(ATSIGN);
        if (atIndex != -1)
            userAtHost = userAtHost.substring(atIndex + 1);
        return userAtHost;
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) IChatID(org.eclipse.ecf.presence.im.IChatID)

Aggregations

IChatID (org.eclipse.ecf.presence.im.IChatID)6 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ID (org.eclipse.ecf.core.identity.ID)2 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 IRCID (org.eclipse.ecf.internal.provider.irc.identity.IRCID)1