Package org.jxmpp.jid

Interface Jid

    • Method Detail

      • toString

        java.lang.String toString()
        Returns the String representation of this JID.
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object
        Returns:
        the String representation of this JID.
      • asUnescapedString

        java.lang.String asUnescapedString()
        Return the unescaped String representation of this JID.

        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.

        For example, if the users inputs 'at&t guy@example.com', the escaped real JID created with JidCreate will be 'at\26t\20guy@example.com', which is what toString() will return. But asUnescapedString() will return again 'at&t guy@example.com'.
        Returns:
        the unescaped String representation of this JID.
      • asUrlEncodedString

        java.lang.String asUrlEncodedString()
        Get the URL encoded version of this JID.
        Returns:
        the URL encoded version of this JID.
        Since:
        0.7.0
      • isEntityJid

        boolean isEntityJid()
        Check if this is a EntityBareJid or EntityFullJid.
        Returns:
        true if this is an instance of BareJid or FullJid.
      • isEntityBareJid

        boolean isEntityBareJid()
        Check if this is an instance of EntityBareJid.
        Returns:
        true if this is an instance of EntityBareJid
      • isEntityFullJid

        boolean isEntityFullJid()
        Check if this is an instance of EntityFullJid.
        Returns:
        true if this is an instance of EntityFullJid
      • isDomainBareJid

        boolean isDomainBareJid()
        Check if this is an instance of DomainBareJid.
        Returns:
        true if this is an instance of DomainBareJid
      • isDomainFullJid

        boolean isDomainFullJid()
        Check if this is an instance of DomainFullJid.
        Returns:
        true if this is an instance of DomainFullJid
      • hasNoResource

        boolean hasNoResource()
        Check if this is an instance of EntityBareJid or DomainBareJid.
        Returns:
        true if this is an instance of BareJid or DomainBareJid
      • hasResource

        boolean hasResource()
        Check if this is a Jid with a Resourcepart.
        Returns:
        true if this Jid has a resourcepart.
      • hasLocalpart

        boolean hasLocalpart()
        Check if this is a Jid with a Localpart.
        Returns:
        true if this Jid has a localpart.
      • asBareJid

        BareJid asBareJid()
        Return a JID created by removing the Resourcepart from this JID.
        Returns:
        this Jid without a Resourcepart.
      • asEntityBareJidOrThrow

        EntityBareJid asEntityBareJidOrThrow()
        Convert this Jid to a EntityBareJid or throw an IllegalStateException if this is not possible.
        Returns:
        the corresponding EntityBareJid.
      • asEntityFullJidOrThrow

        EntityFullJid asEntityFullJidOrThrow()
        Convert this Jid to a EntityFullJid or throw an IllegalStateException if this is not possible.
        Returns:
        the corresponding EntityFullJid.
      • asEntityJidIfPossible

        EntityJid asEntityJidIfPossible()
        Convert this Jid to a EntityJid if possible.
        Returns:
        the corresponding EntityJid or null.
      • asEntityJidOrThrow

        EntityJid asEntityJidOrThrow()
        Convert this Jid to a EntityJid or throw an IllegalStateException if this is not possible.
        Returns:
        the corresponding EntityJid.
      • asFullJidIfPossible

        FullJid asFullJidIfPossible()
        Convert this Jid to a FullJid if possible.
        Returns:
        the corresponding FullJid or null.
      • asFullJidOrThrow

        EntityFullJid asFullJidOrThrow()
        Convert this Jid to a FullJid or throw an IllegalStateException if this is not possible.
        Returns:
        the corresponding FullJid.
      • asDomainBareJid

        DomainBareJid asDomainBareJid()
        Convert this Jid to a DomainBareJid.

        Note that it is always possible to convert a Jid to a DomainBareJid, since every Jid has a domain part.

        Returns:
        the corresponding DomainBareJid.
      • asDomainFullJidIfPossible

        DomainFullJid asDomainFullJidIfPossible()
        Convert this Jid to a DomainFullJid if possible.
        Returns:
        the corresponding DomainFullJid or null.
      • asDomainFullJidOrThrow

        DomainFullJid asDomainFullJidOrThrow()
        Convert this Jid to a DomainFullJid or throw an IllegalStateException if this is not possible.
        Returns:
        the corresponding DomainFullJid.
      • getResourceOrNull

        Resourcepart getResourceOrNull()
        Get the resourcepart of this JID or null.

        If the JID is of form <localpart@domain.example/resource> then this method returns 'resource'. If the JID no resourcepart, then null is returned.

        Returns:
        the resource of this JID or null.
      • getResourceOrEmpty

        Resourcepart getResourceOrEmpty()
        Get the resourcepart of this JID or return the empty resourcepart.

        If the JID is of form <localpart@domain.example/resource> then this method returns 'resource'. If the JID no resourcepart, then Resourcepart.EMPTY is returned.

        Returns:
        the resource of this JID or the empty resourcepart.
      • getResourceOrThrow

        Resourcepart getResourceOrThrow()
        Get the resourcepart of this JID or throw an IllegalStateException.

        If the JID is of form <localpart@domain.example/resource> then this method returns 'resource'. If the JID no resourcepart, then an IllegalStateException is thrown.

        Returns:
        the resource of this JID.
      • getLocalpartOrNull

        Localpart getLocalpartOrNull()
        Get the localpart of this JID or null.

        If the JID is of form <localpart@domain.example> then this method returns 'localpart'. If the JID has no localpart, then null is returned.

        Returns:
        the localpart of this JID or null.
      • getLocalpartOrThrow

        Localpart getLocalpartOrThrow()
        Get the localpart of this JID or throw an IllegalStateException.

        If the JID is of form <localpart@domain.example> then this method returns 'localpart'. If the JID has no localpart, then null is returned.

        Returns:
        the localpart of this JID.
      • isParentOf

        boolean isParentOf​(Jid jid)
        Check if this JID is the parent of another JID. The parent of relation is defined, under the precondition that the JID parts (localpart, domainpart and resourcepart) are equal, as follows:
         | this JID (parentOf) | other JID           | result |
         |---------------------+---------------------+--------|
         | dom.example         | dom.example         | true   |
         | dom.example         | dom.example/res     | true   |
         | dom.example         | loc@dom.example     | true   |
         | dom.example         | loc@dom.example/res | true   |
         | dom.example/res     | dom.exmple          | false  |
         | dom.example/res     | dom.example/res     | true   |
         | dom.example/res     | loc@dom.example     | false  |
         | dom.example/res     | loc@dom.example/res | false  |
         | loc@dom.example     | dom.example         | false  |
         | loc@dom.example     | dom.example/res     | false  |
         | loc@dom.example     | loc@dom.example     | true   |
         | loc@dom.example     | loc@dom.example/res | true   |
         | loc@dom.example/res | dom.example         | false  |
         | loc@dom.example/res | dom.example/res     | false  |
         | loc@dom.example/res | loc@dom.example     | false  |
         | loc@dom.example/res | loc@dom.example/res | true   |
         
        Parameters:
        jid - the other JID to compare with
        Returns:
        true if this JID is a parent of the given JID.
      • isParentOf

        boolean isParentOf​(EntityBareJid bareJid)
        Parameters:
        bareJid - the bare JID.
        Returns:
        true if this JID is a parent of the given JID.
      • isParentOf

        boolean isParentOf​(EntityFullJid fullJid)
        Parameters:
        fullJid - the full JID.
        Returns:
        true if this JID is a parent of the given JID.
      • isParentOf

        boolean isParentOf​(DomainBareJid domainBareJid)
        Parameters:
        domainBareJid - the domain bare JID.
        Returns:
        true if this JID is a parent of the given JID.
      • isParentOf

        boolean isParentOf​(DomainFullJid domainFullJid)
        Parameters:
        domainFullJid - the domain full JID.
        Returns:
        true if this JID is a parent of the given JID.
      • downcast

        <T extends Jid> T downcast​(java.lang.Class<T> jidClass)
                            throws java.lang.ClassCastException
        Return the downcasted instance of this Jid. This method is unsafe, make sure to check that this is actually of the type of are casting to.
        Type Parameters:
        T - the Jid type to downcast to.
        Parameters:
        jidClass - the class of JID to downcast too.
        Returns:
        the downcasted instanced of this
        Throws:
        java.lang.ClassCastException - if this JID is not assignable to the type T.
      • equals

        boolean equals​(java.lang.CharSequence charSequence)
        Compares the given CharSequence with this JID. Returns true if equals(charSequence.toString() would return true.
        Parameters:
        charSequence - the CharSequence to compare this JID with.
        Returns:
        true if if equals(charSequence.toString() would return true.
        See Also:
        equals(String)
      • equals

        boolean equals​(java.lang.String string)
        Compares the given String wit this JID.

        Returns true if toString().equals(string), that is if the String representation of this JID matches the given string.

        Parameters:
        string - the String to compare this JID with.
        Returns:
        true if toString().equals(string).
      • intern

        java.lang.String intern()
        Returns the canonical String representation of this JID. See String.intern() for details.
        Returns:
        the canonical String representation.