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;
}
}
Aggregations