Class AbstractJid
- java.lang.Object
-
- org.jxmpp.jid.impl.AbstractJid
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.CharSequence
,java.lang.Comparable<Jid>
,Jid
- Direct Known Subclasses:
DomainAndResourcepartJid
,DomainpartJid
,LocalAndDomainpartJid
,LocalDomainAndResourcepartJid
public abstract class AbstractJid extends java.lang.Object implements Jid
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
cache
Cache for the String representation of this JID.
-
Constructor Summary
Constructors Constructor Description AbstractJid()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DomainFullJid
asDomainFullJidOrThrow()
Convert this Jid to aDomainFullJid
or throw anIllegalStateException
if this is not possible.EntityBareJid
asEntityBareJidOrThrow()
Convert this Jid to aEntityBareJid
or throw anIllegalStateException
if this is not possible.EntityFullJid
asEntityFullJidOrThrow()
Convert this Jid to aEntityFullJid
or throw anIllegalStateException
if this is not possible.EntityJid
asEntityJidOrThrow()
Convert this Jid to aEntityJid
or throw anIllegalStateException
if this is not possible.EntityFullJid
asFullJidOrThrow()
Convert this Jid to aFullJid
or throw anIllegalStateException
if this is not possible.java.lang.String
asUrlEncodedString()
Get the URL encoded version of this JID.char
charAt(int index)
int
compareTo(Jid other)
<T extends Jid>
Tdowncast(java.lang.Class<T> jidClass)
Return the downcasted instance of this Jid.boolean
equals(java.lang.CharSequence charSequence)
Compares the given CharSequence with this JID.boolean
equals(java.lang.Object other)
boolean
equals(java.lang.String string)
Compares the given String wit this JID.abstract Localpart
getLocalpartOrNull()
Get the localpart of this JID or null.Localpart
getLocalpartOrThrow()
Get the localpart of this JID or throw anIllegalStateException
.Resourcepart
getResourceOrEmpty()
Get the resourcepart of this JID or return the empty resourcepart.abstract Resourcepart
getResourceOrNull()
Get the resourcepart of this JID or null.Resourcepart
getResourceOrThrow()
Get the resourcepart of this JID or throw anIllegalStateException
.int
hashCode()
boolean
hasLocalpart()
Check if this is a Jid with aLocalpart
.abstract boolean
hasNoResource()
Check if this is an instance ofEntityBareJid
orDomainBareJid
.boolean
hasResource()
Check if this is a Jid with aResourcepart
.java.lang.String
intern()
Returns the canonical String representation of this JID.boolean
isDomainBareJid()
Check if this is an instance ofDomainBareJid
.boolean
isDomainFullJid()
Check if this is an instance ofDomainFullJid
.boolean
isEntityBareJid()
Check if this is an instance ofEntityBareJid
.boolean
isEntityFullJid()
Check if this is an instance ofEntityFullJid
.boolean
isEntityJid()
Check if this is aEntityBareJid
orEntityFullJid
.boolean
isParentOf(Jid jid)
Check if this JID is the parent of another JID.int
length()
java.lang.CharSequence
subSequence(int start, int end)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jxmpp.jid.Jid
asBareJid, asDomainBareJid, asDomainFullJidIfPossible, asEntityBareJidIfPossible, asEntityFullJidIfPossible, asEntityJidIfPossible, asFullJidIfPossible, asUnescapedString, getDomain, isParentOf, isParentOf, isParentOf, isParentOf, toString
-
-
-
-
Method Detail
-
isEntityJid
public final boolean isEntityJid()
Description copied from interface:Jid
Check if this is aEntityBareJid
orEntityFullJid
.- Specified by:
isEntityJid
in interfaceJid
- 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 ofEntityBareJid
.- Specified by:
isEntityBareJid
in interfaceJid
- 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 ofEntityFullJid
.- Specified by:
isEntityFullJid
in interfaceJid
- 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 ofDomainBareJid
.- Specified by:
isDomainBareJid
in interfaceJid
- 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 ofDomainFullJid
.- Specified by:
isDomainFullJid
in interfaceJid
- 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 ofEntityBareJid
orDomainBareJid
.- Specified by:
hasNoResource
in interfaceJid
- 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 aResourcepart
.- Specified by:
hasResource
in interfaceJid
- 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 aLocalpart
.- Specified by:
hasLocalpart
in interfaceJid
- 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.
-
length
public int length()
- Specified by:
length
in interfacejava.lang.CharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAt
in interfacejava.lang.CharSequence
-
subSequence
public java.lang.CharSequence subSequence(int start, int end)
- Specified by:
subSequence
in interfacejava.lang.CharSequence
-
asEntityBareJidOrThrow
public final EntityBareJid asEntityBareJidOrThrow()
Description copied from interface:Jid
Convert this Jid to aEntityBareJid
or throw anIllegalStateException
if this is not possible.- Specified by:
asEntityBareJidOrThrow
in interfaceJid
- Returns:
- the corresponding
EntityBareJid
.
-
asEntityFullJidOrThrow
public EntityFullJid asEntityFullJidOrThrow()
Description copied from interface:Jid
Convert this Jid to aEntityFullJid
or throw anIllegalStateException
if this is not possible.- Specified by:
asEntityFullJidOrThrow
in interfaceJid
- Returns:
- the corresponding
EntityFullJid
.
-
asEntityJidOrThrow
public EntityJid asEntityJidOrThrow()
Description copied from interface:Jid
Convert this Jid to aEntityJid
or throw anIllegalStateException
if this is not possible.- Specified by:
asEntityJidOrThrow
in interfaceJid
- Returns:
- the corresponding
EntityJid
.
-
asFullJidOrThrow
public EntityFullJid asFullJidOrThrow()
Description copied from interface:Jid
Convert this Jid to aFullJid
or throw anIllegalStateException
if this is not possible.- Specified by:
asFullJidOrThrow
in interfaceJid
- Returns:
- the corresponding
FullJid
.
-
asDomainFullJidOrThrow
public DomainFullJid asDomainFullJidOrThrow()
Description copied from interface:Jid
Convert this Jid to aDomainFullJid
or throw anIllegalStateException
if this is not possible.- Specified by:
asDomainFullJidOrThrow
in interfaceJid
- 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, thennull
is returned.- Specified by:
getResourceOrNull
in interfaceJid
- 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, thenResourcepart.EMPTY
is returned.- Specified by:
getResourceOrEmpty
in interfaceJid
- 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 anIllegalStateException
.If the JID is of form
<localpart@domain.example/resource>
then this method returns 'resource'. If the JID no resourcepart, then anIllegalStateException
is thrown.- Specified by:
getResourceOrThrow
in interfaceJid
- 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, thennull
is returned.- Specified by:
getLocalpartOrNull
in interfaceJid
- 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 anIllegalStateException
.If the JID is of form
<localpart@domain.example>
then this method returns 'localpart'. If the JID has no localpart, thennull
is returned.- Specified by:
getLocalpartOrThrow
in interfaceJid
- 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 interfaceJid
- 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 classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.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 ifequals(charSequence.toString()
would return true.- Specified by:
equals
in interfaceJid
- 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.
-
compareTo
public final int compareTo(Jid other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Jid>
-
intern
public final java.lang.String intern()
Description copied from interface:Jid
Returns the canonical String representation of this JID. SeeString.intern()
for details.
-
asUrlEncodedString
public final java.lang.String asUrlEncodedString()
Description copied from interface:Jid
Get the URL encoded version of this JID.- Specified by:
asUrlEncodedString
in interfaceJid
- Returns:
- the URL encoded version of this JID.
-
-