|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmpp.packet.JID
@Immutable public class JID
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:
Constructor Summary | |
---|---|
JID(java.lang.String jid)
Constructs a JID from it's String representation. |
|
JID(java.lang.String jid,
boolean skipStringPrep)
Constructs a JID from it's String representation. |
|
JID(java.lang.String node,
java.lang.String domain,
java.lang.String resource)
Constructs a JID given a node, domain, and resource. |
|
JID(java.lang.String node,
java.lang.String domain,
java.lang.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 | |
---|---|
int |
compareTo(JID jid)
|
static java.lang.String |
domainprep(java.lang.String domain)
Returns a valid representation of a JID domain part, based on the provided input. |
boolean |
equals(java.lang.Object object)
|
static boolean |
equals(java.lang.String jid1,
java.lang.String jid2)
Returns true if two JID's are equivalent. |
static java.lang.String |
escapeNode(java.lang.String node)
Escapes the node portion of a JID according to "JID Escaping" (XEP-0106). |
java.lang.String |
getDomain()
Returns the domain. |
java.lang.String |
getNode()
Returns the node, or null if this JID does not contain node information. |
java.lang.String |
getResource()
Returns the resource, or null if this JID does not contain resource information. |
int |
hashCode()
|
static java.lang.String |
nodeprep(java.lang.String node)
Returns a valid representation of a JID node, based on the provided input. |
static java.lang.String |
resourceprep(java.lang.String resource)
Returns a valid representation of a JID resource, based on the provided input. |
java.lang.String |
toBareJID()
Returns the String representation of the bare JID, which is the JID with resource information removed. |
java.lang.String |
toFullJID()
Returns the String representation of the full JID, for example: username@domain.com/mobile. |
java.lang.String |
toString()
Returns a String representation of the JID. |
static java.lang.String |
unescapeNode(java.lang.String node)
Un-escapes the node portion of a JID according to "JID Escaping" (XEP-0106). |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JID(java.lang.String jid)
jid
- a valid JID.
java.lang.IllegalArgumentException
- if the JID is not valid.public JID(java.lang.String jid, boolean skipStringPrep)
jid
- a valid JID.skipStringprep
- true if stringprep should not be applied.
java.lang.IllegalArgumentException
- if the JID is not valid.public JID(java.lang.String node, java.lang.String domain, java.lang.String resource)
node
- the node.domain
- the domain, which must not be null.resource
- the resource.
java.lang.NullPointerException
- if domain is null.
java.lang.IllegalArgumentException
- if the JID is not valid.public JID(java.lang.String node, java.lang.String domain, java.lang.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.
java.lang.NullPointerException
- if domain is null.
java.lang.IllegalArgumentException
- if the JID is not valid.Method Detail |
---|
public static java.lang.String escapeNode(java.lang.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 java.lang.String unescapeNode(java.lang.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 java.lang.String nodeprep(java.lang.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.
java.lang.IllegalStateException
- If the UTF-8 charset is not supported by the system. This
exception wraps an UnsupportedEncodingException.
java.lang.IllegalArgumentException
- if node is not a valid JID node.public static java.lang.String domainprep(java.lang.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.
java.lang.IllegalStateException
- If the UTF-8 charset is not supported by the system. This
exception wraps an UnsupportedEncodingException.
java.lang.IllegalArgumentException
- if domain is not a valid JID domain part.
gnu.inet.encoding.StringprepException
public static java.lang.String resourceprep(java.lang.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.
java.lang.IllegalStateException
- If the UTF-8 charset is not supported by the system. This
exception wraps an UnsupportedEncodingException.
java.lang.IllegalArgumentException
- if resource is not a valid JID resource.
gnu.inet.encoding.StringprepException
public java.lang.String getNode()
public java.lang.String getDomain()
public java.lang.String getResource()
public java.lang.String toBareJID()
public java.lang.String toFullJID()
java.lang.IllegalStateException
- If no resource was provided in the constructor used to create
this instance.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int compareTo(JID jid)
compareTo
in interface java.lang.Comparable<JID>
public static boolean equals(java.lang.String jid1, java.lang.String jid2)
jid1
- a JID.jid2
- a JID.
java.lang.IllegalArgumentException
- if either JID is not valid.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |