mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 18:48:00 +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:
parent
2693d7f5b4
commit
31854b21a3
1 changed files with 26 additions and 3 deletions
|
@ -80,12 +80,11 @@ public class StringUtils {
|
|||
return null;
|
||||
}
|
||||
int atIndex = XMPPAddress.indexOf("@");
|
||||
if (atIndex < 0) {
|
||||
return XMPPAddress.substring(0);
|
||||
if (atIndex <= 0) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
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
|
||||
* in an XML doc.
|
||||
|
|
Loading…
Reference in a new issue