@Immutable public class JID extends Object implements Comparable<JID>, Serializable
| 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 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 |
This process is useful when the node comes from an external source that doesn't conform to nodeprep. For example, a username in LDAP may be "Joe Smith". Because the <space> character isn't a valid part of a node, the username should be escaped to "Joe\20Smith" before being made into a JID (e.g. "joe\20smith@example.com" after case-folding, etc. has been applied).
All node escaping and un-escaping must be performed manually at the appropriate time; the JID class will not escape or un-escape automatically.
node - the node.public static String unescapeNode(String node)
Escaping replaces characters prohibited by node-prep with escape sequences, as follows:
| Unescaped Character | Encoded Sequence |
| <space> | \20 |
| " | \22 |
| & | \26 |
| ' | \27 |
| / | \2f |
| : | \3a |
| < | \3c |
| > | \3e |
| @ | \40 |
| \ | \5c |
This process is useful when the node comes from an external source that doesn't conform to nodeprep. For example, a username in LDAP may be "Joe Smith". Because the <space> character isn't a valid part of a node, the username should be escaped to "Joe\20Smith" before being made into a JID (e.g. "joe\20smith@example.com" after case-folding, etc. has been applied).
All node escaping and un-escaping must be performed manually at the appropriate time; the JID class will not escape or un-escape automatically.
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.IllegalStateException - If the UTF-8 charset is not supported by the system. This
exception wraps an UnsupportedEncodingException.IllegalArgumentException - if node is not a valid JID node.public static String domainprep(String domain) throws gnu.inet.encoding.StringprepException
IllegalArgumentException if
the provided argument cannot be represented as a valid JID domain part
(e.g. if Stringprepping fails).domain - The raw domain value.IllegalStateException - If the UTF-8 charset is not supported by the system. This
exception wraps an UnsupportedEncodingException.IllegalArgumentException - if domain is not a valid JID domain part.gnu.inet.encoding.StringprepExceptionpublic static String resourceprep(String resource) throws gnu.inet.encoding.StringprepException
IllegalArgumentException if the
provided argument cannot be represented as a valid JID resource (e.g. if
StringPrepping fails).resource - The raw resource value.IllegalStateException - If the UTF-8 charset is not supported by the system. This
exception wraps an UnsupportedEncodingException.IllegalArgumentException - if resource is not a valid JID resource.gnu.inet.encoding.StringprepExceptionpublic String getNode()
public String getDomain()
public String getResource()
public String toBareJID()
public JID asBareJID()
public String toFullJID()
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)
jid1 - a JID.jid2 - a JID.IllegalArgumentException - if either JID is not valid.Copyright © 2009–2017 Ignite Realtime. All rights reserved.