| java.lang.Object org.xmpp.packet.JID
JID | public class JID implements Comparable<JID>,Externalizable(Code) | | An XMPP address (JID). A JID is made up of a node (generally a username), a domain,
and a resource. The node and resource are optional; domain is required. In simple
ABNF form:
jid = [ node "@" ] domain [ "/" resource ]
Some sample JID's:
- user@example.com
- user@example.com/home
- example.com
Each allowable portion of a JID (node, domain, and resource) must not be more
than 1023 bytes in length, resulting in a maximum total size (including the '@'
and '/' separators) of 3071 bytes.
author: Matt Tucker |
Constructor Summary | |
public | JID() Constructor added for Externalizable. | public | JID(String jid) Constructs a JID from it's String representation. | public | JID(String node, String domain, String resource) Constructs a JID given a node, domain, and resource. | public | 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. |
Method Summary | |
public int | compareTo(JID jid) | public boolean | equals(Object object) | public static boolean | equals(String jid1, String jid2) Returns true if two JID's are equivalent. | public static String | escapeNode(String node) Escapes the node portion of a JID according to "JID Escaping" (JEP-0106).
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. | public String | getDomain() Returns the domain. | public String | getNode() Returns the node, or null if this JID does not contain node information. | static String[] | getParts(String jid) Returns a String array with the parsed node, domain and resource.
No Stringprep is performed while parsing the textual representation.
Parameters: jid - the textual JID representation. | public String | getResource() Returns the resource, or null if this JID does not contain resource information. | public int | hashCode() | public void | readExternal(ObjectInput in) | public static String | resourceprep(String resource) | public String | toBareJID() Returns the String representation of the bare JID, which is the JID with
resource information removed. | public String | toString() Returns a String representation of the JID. | public static String | unescapeNode(String node) Un-escapes the node portion of a JID according to "JID Escaping" (JEP-0106).
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. | public void | writeExternal(ObjectOutput out) |
JID | public JID()(Code) | | Constructor added for Externalizable. Do not use this constructor.
|
JID | public JID(String node, String domain, String resource)(Code) | | Constructs a JID given a node, domain, and resource.
Parameters: node - the node. Parameters: domain - the domain, which must not be null. Parameters: resource - the resource. throws: IllegalArgumentException - if the JID is not valid. |
JID | public JID(String node, String domain, String resource, boolean skipStringprep)(Code) | | Constructs a JID given a node, domain, and resource being able to specify if stringprep
should be applied or not.
Parameters: node - the node. Parameters: domain - the domain, which must not be null. Parameters: resource - the resource. Parameters: skipStringprep - true if stringprep should not be applied. throws: IllegalArgumentException - if the JID is not valid. |
equals | public static boolean equals(String jid1, String jid2)(Code) | | Returns true if two JID's are equivalent. The JID components are compared using
the following rules:
- Nodes are normalized using nodeprep (case insensitive).
- Domains are normalized using IDNA and then nameprep (case insensitive).
- Resources are normalized using resourceprep (case sensitive).
These normalization rules ensure, for example, that
User@EXAMPLE.com/home is considered equal to user@example.com/home.
Parameters: jid1 - a JID. Parameters: jid2 - a JID. true if the JIDs are equivalent; false otherwise. throws: IllegalArgumentException - if either JID is not valid. |
escapeNode | public static String escapeNode(String node)(Code) | | Escapes the node portion of a JID according to "JID Escaping" (JEP-0106).
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.
Parameters: node - the node. the escaped version of the node. |
getDomain | public String getDomain()(Code) | | Returns the domain.
the domain. |
getNode | public String getNode()(Code) | | Returns the node, or null if this JID does not contain node information.
the node. |
getParts | static String[] getParts(String jid)(Code) | | Returns a String array with the parsed node, domain and resource.
No Stringprep is performed while parsing the textual representation.
Parameters: jid - the textual JID representation. a string array with the parsed node, domain and resource. |
getResource | public String getResource()(Code) | | Returns the resource, or null if this JID does not contain resource information.
the resource. |
hashCode | public int hashCode()(Code) | | |
resourceprep | public static String resourceprep(String resource) throws StringprepException(Code) | | |
toBareJID | public String toBareJID()(Code) | | Returns the String representation of the bare JID, which is the JID with
resource information removed.
the bare JID. |
toString | public String toString()(Code) | | Returns a String representation of the JID.
a String representation of the JID. |
unescapeNode | public static String unescapeNode(String node)(Code) | | Un-escapes the node portion of a JID according to "JID Escaping" (JEP-0106).
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.
Parameters: node - the escaped version of the node. the un-escaped version of the node. |
|
|