Class MalformedJid
- java.lang.Object
-
- rocks.xmpp.addr.MalformedJid
-
- All Implemented Interfaces:
Serializable
,CharSequence
,Comparable<Jid>
,Jid
public final class MalformedJid extends Object
Represents a malformed JID in order to handle thejid-malformed
error.This class is not intended to be publicly instantiable, but is used for malformed JIDs during parsing automatically.
- See Also:
- RFC 6120, 8.3.3.8. jid-malformed, Serialized Form
-
-
Field Summary
-
Fields inherited from interface rocks.xmpp.addr.Jid
ESCAPING_FEATURE, MAX_BARE_JID_LENGTH, MAX_FULL_JID_LENGTH
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Jid
asBareJid()
Gets the bare JID representation of this JID, i.e. removes the resource part.Jid
atSubdomain(CharSequence subdomain)
Creates a new JID at a subdomain and at the same domain as this JID.char
charAt(int index)
int
compareTo(Jid o)
Compares this JID with another JID.boolean
equals(Object o)
Throwable
getCause()
Gets the cause why the JID is malformed.String
getDomain()
Gets the domain part.String
getEscapedLocal()
Gets the escaped local part of the JID.String
getLocal()
Gets the local part of the JID, also known as the name or node.String
getResource()
Gets the resource part.int
hashCode()
boolean
isBareJid()
Checks if the JID is a bare JID.boolean
isDomainJid()
Checks if the JID is a domain JID, i.e. if it has no local part.boolean
isFullJid()
Checks if the JID is a full JID.int
length()
CharSequence
subSequence(int start, int end)
String
toEscapedString()
Returns the JID in escaped form as described in XEP-0106: JID Escaping.String
toString()
Returns the JID in its string representation, i.e. [ localpart "@" ] domainpart [ "/" resourcepart ].Jid
withLocal(CharSequence local)
Creates a new JID with a new local part and the same domain and resource part of the current JID.Jid
withResource(CharSequence resource)
Creates a new full JID with a resource and the same local and domain part of the current JID.-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Method Detail
-
asBareJid
public final Jid asBareJid()
Description copied from interface:Jid
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:
Jid.withResource(CharSequence)
-
withLocal
public Jid withLocal(CharSequence local)
Description copied from interface:Jid
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.
- See Also:
Jid.withResource(CharSequence)
-
withResource
public Jid withResource(CharSequence resource)
Description copied from interface:Jid
Creates a new full JID with a resource and the same local and domain part of the current JID.- Parameters:
resource
- The resource.- Returns:
- The full JID with a resource.
- See Also:
Jid.asBareJid()
,Jid.withLocal(CharSequence)
-
atSubdomain
public Jid atSubdomain(CharSequence subdomain)
Description copied from interface:Jid
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.
-
getLocal
public final String getLocal()
Description copied from interface:Jid
Gets the local part of the JID, also known as the name or node.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:
Jid.getEscapedLocal()
-
getEscapedLocal
public final String getEscapedLocal()
Description copied from interface:Jid
Gets the escaped local part of the JID.- Returns:
- The escaped local part or null.
- See Also:
Jid.getLocal()
-
getDomain
public final String getDomain()
Description copied from interface:Jid
Gets the domain part.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
public final String getResource()
Description copied from interface:Jid
Gets the resource part.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.
-
getCause
public final Throwable getCause()
Gets the cause why the JID is malformed.- Returns:
- The cause.
-
isFullJid
public final 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).
-
isBareJid
public final 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).
-
isDomainJid
public final boolean isDomainJid()
Description copied from interface:Jid
Checks if the JID is a domain JID, i.e. if it has no local part.- Specified by:
isDomainJid
in interfaceJid
- Returns:
- True, if the JID is a domain JID, i.e. if it has no local part.
-
compareTo
public final int compareTo(Jid o)
Compares this JID with another JID. First domain parts are compared. If these are equal, local parts are compared and if these are equal, too, resource parts are compared.- Specified by:
compareTo
in interfaceComparable<Jid>
- Parameters:
o
- The other JID.- Returns:
- The comparison result.
-
length
public final int length()
- Specified by:
length
in interfaceCharSequence
-
charAt
public final char charAt(int index)
- Specified by:
charAt
in interfaceCharSequence
-
subSequence
public final CharSequence subSequence(int start, int end)
- Specified by:
subSequence
in interfaceCharSequence
-
toString
public final String toString()
Returns the JID in its string representation, i.e. [ localpart "@" ] domainpart [ "/" resourcepart ].- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
- Returns:
- The JID.
- See Also:
Jid.toEscapedString()
-
toEscapedString
public final String toEscapedString()
Description copied from interface:Jid
Returns the JID in escaped form as described in XEP-0106: JID Escaping.- Specified by:
toEscapedString
in interfaceJid
- Returns:
- The escaped JID.
- See Also:
CharSequence.toString()
-
-