@Immutable public class JID extends Object implements Comparable<JID>, Serializable
user@example.comuser@example.com/homeexample.com| Modifier and Type | Field and Description |
|---|---|
static com.github.benmanes.caffeine.cache.Cache<String,ValueWrapper<String>> |
DOMAINPREP_CACHE |
static com.github.benmanes.caffeine.cache.Cache<String,ValueWrapper<String>> |
NODEPREP_CACHE |
static com.github.benmanes.caffeine.cache.Cache<String,ValueWrapper<String>> |
RESOURCEPREP_CACHE |
| Constructor and Description |
|---|
JID(String jid)
Constructs a JID from it's String representation.
|
JID(String jid,
boolean skipStringPrep)
Constructs a JID from it's String representation.
|
JID(String node,
String domain,
String resource)
Constructs a JID given a node, domain, and resource.
|
JID(String node,
String domain,
String resource,
boolean skipStringprep)
Constructs a JID given a node, domain, and resource being able to specify if stringprep
should be applied or not.
|
| Modifier and Type | Method and Description |
|---|---|
JID |
asBareJID()
Returns the bare JID representation of this JID, which is the JID with
resource information removed.
|
int |
compareTo(JID jid) |
static String |
domainprep(String domain)
Returns a valid representation of a JID domain part, based on the
provided input.
|
boolean |
equals(Object object) |
static boolean |
equals(String jid1,
String jid2)
Returns true if two JID's are equivalent.
|
static String |
escapeNode(String node)
Escapes the node portion of a JID according to "JID Escaping" (XEP-0106).
|
String |
getDomain()
Returns the domain.
|
String |
getNode()
Returns the node, or
null if this JID does not contain node information. |
String |
getResource()
Returns the resource, or
null if this JID does not contain resource information. |
int |
hashCode() |
static String |
nodeprep(String node)
Returns a valid representation of a JID node, based on the provided
input.
|
static String |
resourceprep(String resource)
Returns a valid representation of a JID resource, based on the provided
input.
|
String |
toBareJID()
Returns the String representation of the bare JID, which is the JID with
resource information removed.
|
String |
toFullJID()
Returns the String representation of the full JID, for example:
username@domain.com/mobile. |
String |
toString()
Returns a String representation of the JID.
|
static String |
unescapeNode(String node)
Un-escapes the node portion of a JID according to "JID Escaping" (XEP-0106).
|
public static final com.github.benmanes.caffeine.cache.Cache<String,ValueWrapper<String>> NODEPREP_CACHE
public static final com.github.benmanes.caffeine.cache.Cache<String,ValueWrapper<String>> DOMAINPREP_CACHE
public static final com.github.benmanes.caffeine.cache.Cache<String,ValueWrapper<String>> RESOURCEPREP_CACHE
public JID(String jid)
jid - a valid JID.IllegalArgumentException - if the JID is not valid.public JID(String jid, boolean skipStringPrep)
jid - a valid JID.skipStringPrep - true if stringprep should not be applied.IllegalArgumentException - if the JID is not valid.public JID(String node, String domain, String resource)
node - the node.domain - the domain, which must not be null.resource - the resource.NullPointerException - if domain is null.IllegalArgumentException - if the JID is not valid.public JID(String node, String domain, String resource, boolean skipStringprep)
node - the node.domain - the domain, which must not be null.resource - the resource.skipStringprep - true if stringprep should not be applied.NullPointerException - if domain is null.IllegalArgumentException - if the JID is not valid.public static String escapeNode(String node)
| Unescaped Character | Encoded Sequence |
| <space> | \20 |
| " | \22 |
| & | \26 |
| ' | \27 |
| / | \2f |
| : | \3a |
| < | \3c |
| > | \3e |
| @ | \40 |
| \ | \5c |
node - the node.public static String unescapeNode(String node)
| Unescaped Character | Encoded Sequence |
| <space> | \20 |
| " | \22 |
| & | \26 |
| ' | \27 |
| / | \2f |
| : | \3a |
| < | \3c |
| > | \3e |
| @ | \40 |
| \ | \5c |
node - the escaped version of the node.public static String nodeprep(String node)
IllegalArgumentException if the
provided argument cannot be represented as a valid JID node (e.g. if
StringPrepping fails).node - The raw node value.IllegalArgumentException - if node is not a valid JID node.public static String domainprep(String domain)
IllegalArgumentException if
the provided argument cannot be represented as a valid JID domain part
(e.g. if Stringprepping fails).domain - The raw domain value.IllegalArgumentException - if domain is not a valid JID domain part.public static String resourceprep(String resource)
IllegalArgumentException if the
provided argument cannot be represented as a valid JID resource (e.g. if
StringPrepping fails).resource - The raw resource value.IllegalArgumentException - if resource is not a valid JID resource.public String getNode()
null if this JID does not contain node information.public String getDomain()
public String getResource()
null if this JID does not contain resource information.public String toBareJID()
username@domain.compublic JID asBareJID()
username@domain.compublic String toFullJID()
username@domain.com/mobile.
If no resource has been provided in the constructor of this object, an
IllegalStateException is thrown.IllegalStateException - If no resource was provided in the constructor used to create
this instance.public String toString()
public int compareTo(JID jid)
compareTo in interface Comparable<JID>public static boolean equals(String jid1, String jid2)
User@EXAMPLE.com/home is considered equal to user@example.com/home.jid1 - a JID.jid2 - a JID.IllegalArgumentException - if either JID is not valid.Copyright © 2009–2021 Ignite Realtime. All rights reserved.