1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 22:12:05 +01:00

Added method to parse the address without resource, fixed parsing of name (SMACK-80)

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2056 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-08-23 14:59:09 +00:00 committed by mtucker
parent 2693d7f5b4
commit 31854b21a3

View file

@ -80,12 +80,11 @@ public class StringUtils {
return null; return null;
} }
int atIndex = XMPPAddress.indexOf("@"); int atIndex = XMPPAddress.indexOf("@");
if (atIndex < 0) { if (atIndex <= 0) {
return XMPPAddress.substring(0); return "";
} }
else { else {
return XMPPAddress.substring(0, atIndex); return XMPPAddress.substring(0, atIndex);
} }
} }
@ -136,6 +135,30 @@ public class StringUtils {
} }
} }
/**
* Returns the XMPP address with any resource information removed. For example,
* for the address "matt@jivesoftware.com/Smack", "matt@jivesoftware.com" would
* be returned.
*
* @param XMPPAddress the XMPP address.
* @return the bare XMPP address without resource information.
*/
public static String parseBareAddress(String XMPPAddress) {
if (XMPPAddress == null) {
return null;
}
int slashIndex = XMPPAddress.indexOf("/");
if (slashIndex < 0) {
return XMPPAddress;
}
else if (slashIndex == 0) {
return "";
}
else {
return XMPPAddress.substring(0, slashIndex);
}
}
/** /**
* Escapes all necessary characters in the String so that it can be used * Escapes all necessary characters in the String so that it can be used
* in an XML doc. * in an XML doc.