Interface Jid

    • Field Detail

      • MAX_FULL_JID_LENGTH

        static final int MAX_FULL_JID_LENGTH
        The maximal length of a full JID, which is 3071.

        3.1. Fundamentals

        Each allowable portion of a JID (localpart, domainpart, and resourcepart) is 1 to 1023 octets in length, resulting in a maximum total size (including the '@' and '/' separators) of 3071 octets.

        Note that the length is based on bytes, not characters.

        See Also:
        MAX_BARE_JID_LENGTH, Constant Field Values
      • MAX_BARE_JID_LENGTH

        static final int MAX_BARE_JID_LENGTH
        The maximal length of a bare JID, which is 2047 (1023 + 1 + 1023). Note that the length is based on bytes, not characters.
        See Also:
        MAX_FULL_JID_LENGTH, Constant Field Values
      • ESCAPING_FEATURE

        static final String ESCAPING_FEATURE
        The service discovery feature used for determining support of JID escaping (jid\20escaping).
        See Also:
        Constant Field Values
    • Method Detail

      • ofDomain

        static Jid ofDomain​(CharSequence domain)
        Creates a bare JID with only the domain part, e.g. capulet.com
        Parameters:
        domain - The domain.
        Returns:
        The JID.
        Throws:
        NullPointerException - If the domain is null.
        IllegalArgumentException - If the domain or local part are not valid.
      • ofLocalAndDomain

        static Jid ofLocalAndDomain​(CharSequence local,
                                    CharSequence domain)
        Creates a bare JID with a local and domain part, e.g. juliet@capulet.com
        Parameters:
        local - The local part.
        domain - The domain.
        Returns:
        The JID.
        Throws:
        NullPointerException - If the domain is null.
        IllegalArgumentException - If the domain or local part are not valid.
      • ofDomainAndResource

        static Jid ofDomainAndResource​(CharSequence domain,
                                       CharSequence resource)
        Creates a full JID with a domain and resource part, e.g. capulet.com/balcony
        Parameters:
        domain - The domain.
        resource - The resource part.
        Returns:
        The JID.
        Throws:
        NullPointerException - If the domain is null.
        IllegalArgumentException - If the domain or resource are not valid.
      • ofEscaped

        static Jid ofEscaped​(CharSequence jid)
        Creates a JID from a escaped JID string. The format must be

        [ localpart "@" ] domainpart [ "/" resourcepart ]

        This method should be used, when parsing JIDs from the XMPP stream.

        Parameters:
        jid - The JID.
        Returns:
        The JID.
        Throws:
        NullPointerException - If the jid is null.
        IllegalArgumentException - If the jid could not be parsed or is not valid.
        See Also:
        XEP-0106: JID Escaping
      • isFullJid

        boolean isFullJid()
        Checks if the JID is a full JID.

        The term "full JID" refers to an XMPP address of the form <localpart@domainpart/resourcepart> (for a particular authorized client or device associated with an account) or of the form <domainpart/resourcepart> (for a particular resource or script associated with a server).

        Returns:
        True, if the JID is a full JID; otherwise false.
      • isBareJid

        boolean isBareJid()
        Checks if the JID is a bare JID.

        The term "bare JID" refers to an XMPP address of the form <localpart@domainpart> (for an account at a server) or of the form <domainpart> (for a server).

        Returns:
        True, if the JID is a bare JID; otherwise false.
      • isDomainJid

        boolean isDomainJid()
        Checks if the JID is a domain JID, i.e. if it has no local part.
        Returns:
        True, if the JID is a domain JID, i.e. if it has no local part.
      • asBareJid

        Jid asBareJid()
        Gets the bare JID representation of this JID, i.e. removes the resource part.

        The term "bare JID" refers to an XMPP address of the form <localpart@domainpart> (for an account at a server) or of the form <domainpart> (for a server).

        Returns:
        The bare JID.
        See Also:
        withResource(CharSequence)
      • withLocal

        Jid withLocal​(CharSequence local)
        Creates a new JID with a new local part and the same domain and resource part of the current JID.
        Parameters:
        local - The local part.
        Returns:
        The JID with a new local part.
        Throws:
        IllegalArgumentException - If the local is not a valid local part.
        See Also:
        withResource(CharSequence)
      • atSubdomain

        Jid atSubdomain​(CharSequence subdomain)
        Creates a new JID at a subdomain and at the same domain as this JID.
        Parameters:
        subdomain - The subdomain.
        Returns:
        The JID at a subdomain.
        Throws:
        NullPointerException - If subdomain is null.
        IllegalArgumentException - If subdomain is not a valid subdomain name.
      • getLocal

        String getLocal()
        Gets the local part of the JID, also known as the name or node.

        3.3. Localpart

        The localpart of a JID is an optional identifier placed before the domainpart and separated from the latter by the '@' character. Typically, a localpart uniquely identifies the entity requesting and using network access provided by a server (i.e., a local account), although it can also represent other kinds of entities (e.g., a chatroom associated with a multi-user chat service [XEP-0045]). The entity represented by an XMPP localpart is addressed within the context of a specific domain (i.e., <localpart@domainpart>).

        Returns:
        The local part or null.
        See Also:
        getEscapedLocal()
      • getEscapedLocal

        String getEscapedLocal()
        Gets the escaped local part of the JID.
        Returns:
        The escaped local part or null.
        Since:
        0.8.0
        See Also:
        getLocal()
      • getDomain

        String getDomain()
        Gets the domain part.

        3.2. Domainpart

        The domainpart is the primary identifier and is the only REQUIRED element of a JID (a mere domainpart is a valid JID). Typically, a domainpart identifies the "home" server to which clients connect for XML routing and data management functionality.

        Returns:
        The domain part.
      • getResource

        String getResource()
        Gets the resource part.

        3.4. Resourcepart

        The resourcepart of a JID is an optional identifier placed after the domainpart and separated from the latter by the '/' character. A resourcepart can modify either a <localpart@domainpart> address or a mere <domainpart> address. Typically, a resourcepart uniquely identifies a specific connection (e.g., a device or location) or object (e.g., an occupant in a multi-user chatroom [XEP-0045]) belonging to the entity associated with an XMPP localpart at a domain (i.e., <localpart@domainpart/resourcepart>).

        Returns:
        The resource part or null.