Class AbstractJid

java.lang.Object
org.jxmpp.jid.impl.AbstractJid
All Implemented Interfaces:
Serializable, CharSequence, Comparable<Jid>, Jid
Direct Known Subclasses:
DomainAndResourcepartJid, DomainpartJid, LocalAndDomainpartJid, LocalDomainAndResourcepartJid

public abstract class AbstractJid extends Object implements Jid
See Also:
  • Field Details

    • cache

      protected String cache
      Cache for the String representation of this JID.
  • Constructor Details

  • Method Details

    • 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(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 CharSequence
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • asEntityBareJidOrThrow

      Description copied from interface: Jid
      Convert this Jid to a EntityBareJid or throw an IllegalStateException if this is not possible.
      Specified by:
      asEntityBareJidOrThrow in interface Jid
      Returns:
      the corresponding EntityBareJid.
    • asEntityFullJidOrThrow

      Description copied from interface: Jid
      Convert this Jid to a EntityFullJid or throw an IllegalStateException if this is not possible.
      Specified by:
      asEntityFullJidOrThrow in interface Jid
      Returns:
      the corresponding EntityFullJid.
    • 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

      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.
    • asDomainFullJidOrThrow

      Description copied from interface: Jid
      Convert this Jid to a DomainFullJid or throw an IllegalStateException if this is not possible.
      Specified by:
      asDomainFullJidOrThrow in interface Jid
      Returns:
      the corresponding DomainFullJid.
    • 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

      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

      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

      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.
    • isStrictParentOf

      public final boolean isStrictParentOf(Jid jid)
      Description copied from interface: Jid
      Check if this JID is the strict parent of another JID. In other words, all parts of this JID must exist on the other JID, and match this JID's values. Furthermore, and this is what makes this method different from Jid.isParentOf(Jid), the other JID must have one additional part, that this JID does not have. The parent of relation is defined, under the precondition that the JID parts (localpart, domainpart and resourcepart) are equal, as follows:
       | this JID            | other JID           | result |
       |---------------------+---------------------+--------|
       | dom.example         | dom.example         | false  | (different from isParentOf)
       | 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     | false  | (different from isParentOf)
       | 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     | false  | (different from isParentOf)
       | 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 | false  | (different from isParentOf)
       
      Specified by:
      isStrictParentOf 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 Object
    • equals

      public final boolean equals(Object other)
      Overrides:
      equals in class Object
    • equals

      public final boolean equals(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:
    • equals

      public final boolean equals(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 Comparable<Jid>
    • intern

      public final 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 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.