public class XmppStringUtils
extends java.lang.Object
| Constructor and Description |
|---|
XmppStringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
completeJidFrom(java.lang.CharSequence localpart,
java.lang.CharSequence domainpart) |
static java.lang.String |
completeJidFrom(java.lang.CharSequence localpart,
java.lang.CharSequence domainpart,
java.lang.CharSequence resource) |
static java.lang.String |
completeJidFrom(java.lang.String localpart,
java.lang.String domainpart) |
static java.lang.String |
completeJidFrom(java.lang.String localpart,
java.lang.String domainpart,
java.lang.String resource) |
static java.lang.String |
escapeLocalpart(java.lang.String localpart)
Escapes the localpart of a JID according to "JID Escaping" (XEP-0106).
|
static java.lang.String |
generateKey(java.lang.String element,
java.lang.String namespace)
Generate a unique key from a element name and namespace.
|
static boolean |
isBareJid(java.lang.String jid)
Returns true if
jid is a bare JID ("foo@bar.com"). |
static boolean |
isFullJID(java.lang.String jid)
Returns true if jid is a full JID (i.e.
|
static java.lang.String |
parseBareAddress(java.lang.String jid)
Deprecated.
use
parseBareJid(String) instead |
static java.lang.String |
parseBareJid(java.lang.String jid)
Returns the JID with any resource information removed.
|
static java.lang.String |
parseDomain(java.lang.String jid)
Returns the domain of an XMPP address (JID).
|
static java.lang.String |
parseLocalpart(java.lang.String jid)
Returns the localpart of an XMPP address (JID).
|
static java.lang.String |
parseResource(java.lang.String jid)
Returns the resource portion of an XMPP address (JID).
|
static java.lang.String |
unescapeLocalpart(java.lang.String localpart)
Un-escapes the localpart of a JID according to "JID Escaping" (XEP-0106).
|
public static java.lang.String parseLocalpart(java.lang.String jid)
jid is null, then this method returns also null. If
the input String is no valid JID or has no localpart, then this method will return the empty String. jid - the XMPP address to parse.null.public static java.lang.String parseDomain(java.lang.String jid)
jid is null, then this method returns also null. If
the input String is no valid JID or has no domainpart, then this method will return the empty String.jid - the XMPP address to parse.null.public static java.lang.String parseResource(java.lang.String jid)
jid is null, then this method returns also
null. If the input String is no valid JID or has no resourcepart, then this method will return the
empty String.jid - the XMPP address to parse.@Deprecated public static java.lang.String parseBareAddress(java.lang.String jid)
parseBareJid(String) insteadjid - the XMPP JID.public static java.lang.String parseBareJid(java.lang.String jid)
jid - the XMPP JID.public static boolean isFullJID(java.lang.String jid)
jid - public static boolean isBareJid(java.lang.String jid)
jid is a bare JID ("foo@bar.com").
This method may return true for Strings that are not valid JIDs (e.g. because of Stringprep violations). Consider
using org.jxmpp.jid.util.JidUtil.validateBareJid(String) from jxmpp-jid instead of this method as it
exceptions provide a meaningful message string why the JID is not a bare JID and will also check for Stringprep
errors.
jid - public static java.lang.String escapeLocalpart(java.lang.String localpart)
| Unescaped Character | Encoded Sequence |
| <space> | \20 |
| " | \22 |
| & | \26 |
| ' | \27 |
| / | \2f |
| : | \3a |
| < | \3c |
| > | \3e |
| @ | \40 |
| \ | \5c |
This process is useful when the localpart comes from an external source that doesn't conform to Nodeprep. For example, a username in LDAP may be "Joe Smith". Because the <space> character isn't a valid part of a localpart, the username should be escaped to "Joe\20Smith" before being made into a JID (e.g. "joe\20smith@example.com" after case-folding, etc. has been applied).
All localpart escaping and un-escaping must be performed manually at the appropriate time; the JID class will not escape or un-escape automatically.localpart - the localpart.public static java.lang.String unescapeLocalpart(java.lang.String localpart)
| Unescaped Character | Encoded Sequence |
| <space> | \20 |
| " | \22 |
| & | \26 |
| ' | \27 |
| / | \2f |
| : | \3a |
| < | \3c |
| > | \3e |
| @ | \40 |
| \ | \5c |
This process is useful when the localpart comes from an external source that doesn't conform to Nodeprep. For example, a username in LDAP may be "Joe Smith". Because the <space> character isn't a valid part of a localpart, the username should be escaped to "Joe\20Smith" before being made into a JID (e.g. "joe\20smith@example.com" after case-folding, etc. has been applied).
All localpart escaping and un-escaping must be performed manually at the appropriate time; the JID class will not escape or un-escape automatically.localpart - the escaped version of the localpart.public static java.lang.String completeJidFrom(java.lang.CharSequence localpart,
java.lang.CharSequence domainpart)
public static java.lang.String completeJidFrom(java.lang.String localpart,
java.lang.String domainpart)
public static java.lang.String completeJidFrom(java.lang.CharSequence localpart,
java.lang.CharSequence domainpart,
java.lang.CharSequence resource)
public static java.lang.String completeJidFrom(java.lang.String localpart,
java.lang.String domainpart,
java.lang.String resource)
public static java.lang.String generateKey(java.lang.String element,
java.lang.String namespace)
element + '\t' + namespace.
The tab character (\t) was chosen because it will be normalized, i.e. replace by space, in attribute values. It
therefore should never appear in element or namespace. For more information about the
normalization, see the XML specification ยง 3.3.3
Attribute-Value Normalization.
element - namespace -