Class Localpart

java.lang.Object
org.jxmpp.jid.parts.Part
org.jxmpp.jid.parts.Localpart
All Implemented Interfaces:
Serializable, CharSequence

public class Localpart extends Part
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 Details

    • asUnescapedString

      public String 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

      public static Localpart fromOrThrowUnchecked(CharSequence cs)
      Like from(String) but does throw an unchecked IllegalArgumentException instead of a XmppStringprepException.
      Parameters:
      cs - the character sequence which should be transformed to a Localpart
      Returns:
      the Localpart if no exception occurs
      Throws:
      IllegalArgumentException - if the given input is not a valid Localpart
      Since:
      0.6.2
      See Also:
    • fromUnescapedOrThrowUnchecked

      public static Localpart fromUnescapedOrThrowUnchecked(CharSequence cs)
      Like fromUnescaped(String) but does throw an unchecked IllegalArgumentException instead of a XmppStringprepException.
      Parameters:
      cs - the character sequence which should be transformed to a Localpart
      Returns:
      the Localpart if no exception occurs
      Since:
      0.6.2
      See Also:
    • formUnescapedOrNull

      public static Localpart formUnescapedOrNull(CharSequence cs)
      Get a Localpart from a given CharSequence or null if the input is not a valid localpart.
      Parameters:
      cs - the input CharSequence
      Returns:
      a Localpart or null
    • fromUnescaped

      public static Localpart fromUnescaped(String unescapedLocalpart) throws org.jxmpp.stringprep.XmppStringprepException
      Get a Localpart from an unescaped String.
      Parameters:
      unescapedLocalpart - an unescaped String representing a Localpart.
      Returns:
      a Localpart
      Throws:
      org.jxmpp.stringprep.XmppStringprepException - if an error occurs.
      Since:
      0.6.2
    • fromUnescaped

      public static Localpart fromUnescaped(CharSequence unescapedLocalpart) throws org.jxmpp.stringprep.XmppStringprepException
      Get a Localpart from an unescaped CharSequence.
      Parameters:
      unescapedLocalpart - an unescaped CharSequence representing a Localpart.
      Returns:
      a Localpart
      Throws:
      org.jxmpp.stringprep.XmppStringprepException - if an error occurs.
      Since:
      0.6.2
    • fromOrNull

      public static Localpart fromOrNull(CharSequence cs)
      Get a Localpart from a given CharSequence or null if the input is not a valid localpart.
      Parameters:
      cs - the input CharSequence
      Returns:
      a Localpart or null
    • from

      public static Localpart from(String localpart) throws org.jxmpp.stringprep.XmppStringprepException
      Get the Localpart representing the input String.
      Parameters:
      localpart - the input String.
      Returns:
      the localpart.
      Throws:
      org.jxmpp.stringprep.XmppStringprepException - if an error occurs.
    • from

      public static Localpart from(String localpart, org.jxmpp.JxmppContext context) throws org.jxmpp.stringprep.XmppStringprepException
      Get the Localpart representing the input String.
      Parameters:
      localpart - the input String.
      context - the JXMPP context.
      Returns:
      the localpart.
      Throws:
      org.jxmpp.stringprep.XmppStringprepException - if an error occurs.