Class AbstractJid

    • Field Detail

      • cache

        protected java.lang.String cache
        Cache for the String representation of this JID.
    • Constructor Detail

      • AbstractJid

        public AbstractJid()
    • Method Detail

      • isEntityJid

        public final boolean isEntityJid()
        Description copied from interface: Jid
        Check if this is a EntityBareJid or EntityFullJid.
        Specified by:
        isEntityJid in interface Jid
        Returns:
        true if this is an instance of BareJid or FullJid.
      • isEntityBareJid

        public final boolean isEntityBareJid()
        Description copied from interface: Jid
        Check if this is an instance of EntityBareJid.
        Specified by:
        isEntityBareJid in interface Jid
        Returns:
        true if this is an instance of EntityBareJid
      • isEntityFullJid

        public final boolean isEntityFullJid()
        Description copied from interface: Jid
        Check if this is an instance of EntityFullJid.
        Specified by:
        isEntityFullJid in interface Jid
        Returns:
        true if this is an instance of EntityFullJid
      • isDomainBareJid

        public final boolean isDomainBareJid()
        Description copied from interface: Jid
        Check if this is an instance of DomainBareJid.
        Specified by:
        isDomainBareJid in interface Jid
        Returns:
        true if this is an instance of DomainBareJid
      • isDomainFullJid

        public final boolean isDomainFullJid()
        Description copied from interface: Jid
        Check if this is an instance of DomainFullJid.
        Specified by:
        isDomainFullJid in interface Jid
        Returns:
        true if this is an instance of DomainFullJid
      • hasNoResource

        public abstract boolean hasNoResource()
        Description copied from interface: Jid
        Check if this is an instance of EntityBareJid or DomainBareJid.
        Specified by:
        hasNoResource in interface Jid
        Returns:
        true if this is an instance of BareJid or DomainBareJid
      • hasResource

        public final boolean hasResource()
        Description copied from interface: Jid
        Check if this is a Jid with a Resourcepart.
        Specified by:
        hasResource in interface Jid
        Returns:
        true if this Jid has a resourcepart.
      • hasLocalpart

        public final boolean hasLocalpart()
        Description copied from interface: Jid
        Check if this is a Jid with a Localpart.
        Specified by:
        hasLocalpart in interface Jid
        Returns:
        true if this Jid has a localpart.
      • downcast

        public final <T extends Jid> T downcast​(java.lang.Class<T> jidClass)
        Description copied from interface: Jid
        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.
        Specified by:
        downcast in interface Jid
        Type Parameters:
        T - the Jid type to downcast to.
        Parameters:
        jidClass - the class of JID to downcast too.
        Returns:
        the downcasted instanced of this
      • length

        public int length()
        Specified by:
        length in interface java.lang.CharSequence
      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface java.lang.CharSequence
      • subSequence

        public java.lang.CharSequence subSequence​(int start,
                                                  int end)
        Specified by:
        subSequence in interface java.lang.CharSequence
      • asEntityJidOrThrow

        public EntityJid asEntityJidOrThrow()
        Description copied from interface: Jid
        Convert this Jid to a EntityJid or throw an IllegalStateException if this is not possible.
        Specified by:
        asEntityJidOrThrow in interface Jid
        Returns:
        the corresponding EntityJid.
      • asFullJidOrThrow

        public EntityFullJid asFullJidOrThrow()
        Description copied from interface: Jid
        Convert this Jid to a FullJid or throw an IllegalStateException if this is not possible.
        Specified by:
        asFullJidOrThrow in interface Jid
        Returns:
        the corresponding FullJid.
      • getResourceOrNull

        public abstract Resourcepart getResourceOrNull()
        Description copied from interface: Jid
        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.

        Specified by:
        getResourceOrNull in interface Jid
        Returns:
        the resource of this JID or null.
      • getResourceOrEmpty

        public final Resourcepart getResourceOrEmpty()
        Description copied from interface: Jid
        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.

        Specified by:
        getResourceOrEmpty in interface Jid
        Returns:
        the resource of this JID or the empty resourcepart.
      • getResourceOrThrow

        public final Resourcepart getResourceOrThrow()
        Description copied from interface: Jid
        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.

        Specified by:
        getResourceOrThrow in interface Jid
        Returns:
        the resource of this JID.
      • getLocalpartOrNull

        public abstract Localpart getLocalpartOrNull()
        Description copied from interface: Jid
        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.

        Specified by:
        getLocalpartOrNull in interface Jid
        Returns:
        the localpart of this JID or null.
      • getLocalpartOrThrow

        public final Localpart getLocalpartOrThrow()
        Description copied from interface: Jid
        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.

        Specified by:
        getLocalpartOrThrow in interface Jid
        Returns:
        the localpart of this JID.
      • isParentOf

        public final boolean isParentOf​(Jid jid)
        Description copied from interface: 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   |
         
        Specified by:
        isParentOf in interface Jid
        Parameters:
        jid - the other JID to compare with
        Returns:
        true if this JID is a parent of the given JID.
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.CharSequence charSequence)
        Description copied from interface: Jid
        Compares the given CharSequence with this JID. Returns true if equals(charSequence.toString() would return true.
        Specified by:
        equals in interface Jid
        Parameters:
        charSequence - the CharSequence to compare this JID with.
        Returns:
        true if if equals(charSequence.toString() would return true.
        See Also:
        Jid.equals(String)
      • equals

        public final boolean equals​(java.lang.String string)
        Description copied from interface: Jid
        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.

        Specified by:
        equals in interface Jid
        Parameters:
        string - the String to compare this JID with.
        Returns:
        true if toString().equals(string).
      • compareTo

        public final int compareTo​(Jid other)
        Specified by:
        compareTo in interface java.lang.Comparable<Jid>
      • intern

        public final java.lang.String intern()
        Description copied from interface: Jid
        Returns the canonical String representation of this JID. See String.intern() for details.
        Specified by:
        intern in interface Jid
        Returns:
        the canonical String representation.
      • asUrlEncodedString

        public final java.lang.String asUrlEncodedString()
        Description copied from interface: Jid
        Get the URL encoded version of this JID.
        Specified by:
        asUrlEncodedString in interface Jid
        Returns:
        the URL encoded version of this JID.