Package org.jxmpp.jid.parts
Class Localpart
java.lang.Object
org.jxmpp.jid.parts.Part
org.jxmpp.jid.parts.Localpart
- All Implemented Interfaces:
Serializable
,CharSequence
A localpart of an XMPP address (JID). The localpart is the part before the
first @ sign in an XMPP address and usually identifies the user (or the XMPP
entity) within an XMPP service. It is also often referred to as "username",
but note that the actual username used to login may be different from the
resulting localpart of the user's JID.
You can create instances of this class from Strings using from(String)
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturn the unescaped String representation of this Localpart.static Localpart
static Localpart
Get theLocalpart
representing the input String.static Localpart
from
(String localpart, JxmppContext context) Get theLocalpart
representing the input String.static Localpart
static Localpart
Likefrom(String)
but does throw an uncheckedIllegalArgumentException
instead of aXmppStringprepException
.static Localpart
fromUnescaped
(CharSequence unescapedLocalpart) Get aLocalpart
from an unescaped CharSequence.static Localpart
fromUnescaped
(String unescapedLocalpart) Get aLocalpart
from an unescaped String.static Localpart
LikefromUnescaped(String)
but does throw an uncheckedIllegalArgumentException
instead of aXmppStringprepException
.Methods inherited from class org.jxmpp.jid.parts.Part
assertNotLongerThan1023BytesOrEmpty, charAt, equals, hashCode, intern, length, subSequence, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
Method Details
-
asUnescapedString
Return the unescaped String representation of this Localpart.Since certain Unicode code points are disallowed in the localpart of a JID by the required stringprep profile, those need to get escaped when used in a real JID. The unescaped representation of the JID is only for presentation to a human user or for gatewaying to a non-XMPP system.
- Returns:
- the unescaped String representation of this JID.
- Since:
- 0.6.1
- See Also:
-
fromOrThrowUnchecked
Likefrom(String)
but does throw an uncheckedIllegalArgumentException
instead of aXmppStringprepException
.- Parameters:
cs
- the character sequence which should be transformed to aLocalpart
- Returns:
- the
Localpart
if no exception occurs - Throws:
IllegalArgumentException
- if the given input is not a validLocalpart
- Since:
- 0.6.2
- See Also:
-
fromUnescapedOrThrowUnchecked
LikefromUnescaped(String)
but does throw an uncheckedIllegalArgumentException
instead of aXmppStringprepException
. -
formUnescapedOrNull
- Parameters:
cs
- the input CharSequence- Returns:
- a Localpart or
null
-
fromUnescaped
Get aLocalpart
from an unescaped String.- Parameters:
unescapedLocalpart
- an unescaped String representing a Localpart.- Returns:
- a Localpart
- Throws:
XmppStringprepException
- if an error occurs.- Since:
- 0.6.2
-
fromUnescaped
public static Localpart fromUnescaped(CharSequence unescapedLocalpart) throws XmppStringprepException Get aLocalpart
from an unescaped CharSequence.- Parameters:
unescapedLocalpart
- an unescaped CharSequence representing a Localpart.- Returns:
- a Localpart
- Throws:
XmppStringprepException
- if an error occurs.- Since:
- 0.6.2
-
fromOrNull
- Parameters:
cs
- the input CharSequence- Returns:
- a Localpart or
null
-
from
Get theLocalpart
representing the input String.- Parameters:
localpart
- the input String.- Returns:
- the localpart.
- Throws:
XmppStringprepException
- if an error occurs.
-
from
Get theLocalpart
representing the input String.- Parameters:
localpart
- the input String.context
- the JXMPP context.- Returns:
- the localpart.
- Throws:
XmppStringprepException
- if an error occurs.
-