Class Index | Minimal

Classes


Class jabberwerx.JID (MINIMAL)


Extends jabberwerx.JWModel.

Represents a JID identifier. A JID has the general string form:

node@domain/resource

Where {node} (and its trailing '@') and {resource} (and its leading '/') are optional.

Class Summary
Constructor Attributes Constructor Name and Description
 

Creates a new JID.

Method Summary
Method Attributes Method Name and Description
<static>  
jabberwerx.JID.asJID(val)

Converts an object into a jabberwerx.JID.

<static>  
jabberwerx.JID.clearCache()
Clears the internal cache of JIDs.
 
compareTo(jid)

Compares this JID to the given JID for ordering.

 
equals(jid)

Determines if this JID is equal to the given JID.

<static>  
jabberwerx.JID.escapeNode(input)

Translates the given input into a valid node for a JID.

 

Returns the bare JID form of this JID.

 

Returns the bare JID form of this JID as a string.

 

Retrieves the domain value for this JID.

 

Retrieves the node value for this JID.

 

Retrieves the resource value for this JID.

<inner>  
prepFN(test)
 

Determines if this type should be serialized inline with other primitive (boolean, number, string) or inlinable types.

 

Retrieves the display string representing this JID.

 

Retrieves the string respesenting this JID.

<static>  
jabberwerx.JID.unescapeNode(input)

Translates the given input from a valid node for a JID.

 

Called just after this JID is unserialized.

Methods borrowed from class jabberwerx.JWModel:
applyEvent, event, shouldBeSavedWithGraph
Methods borrowed from class jabberwerx.JWBase:
destroy, getClassName, graphUnserialized, init, invocation, willBeSerialized
Class Detail
jabberwerx.JID(arg)

Creates a new JID.

The value of {arg} must be one of the following:

  • a string representation of a JID (e.g. "username@hostname/resource")
  • An object with the following properties:
    {
                // REQUIRED: domain portion of JID
                domain: "hostname",
                // OPTIONAL: node portion of JID
                node: "username",
                // OPTIONAL: resource portion of JID
                resource: "resource",
                // OPTIONAL: "true" if the node is unescaped, and should
                // be translated via #.escapeNode
                unescaped: true|false
    }

NOTE: The preferred method of obtaining a JID is to use jabberwerx.JID.asJID; it returns cached instances, which can save considerable time.

Parameters:
{String|Object} arg
The string or parts for a JID
Throws:
{jabberwerx.JID.InvalidJIDError}
If a JID cannot be created from {arg}.
Method Detail
<static> {jabberwerx.JID} jabberwerx.JID.asJID(val)

Converts an object into a jabberwerx.JID. This method uses the following algorithm:

  1. If {val} is an instance of jabberwerx.JID, return it
  2. If a JID exists in the internal cache that matches the string value of {val}, return it.
  3. Create a new jabberwerx.JID from val, and cache it
Parameters:
val
The value to convert to a JID
Throws:
{jabberwerx.JID.InvalidJIDError}
If {val} could not be converted into a JID
Returns:
{jabberwerx.JID} The JID object from {val}

<static> jabberwerx.JID.clearCache()
Clears the internal cache of JIDs. NOTE: This does not destroy existing JID instances.

{Number} compareTo(jid)

Compares this JID to the given JID for ordering. The order of two JIDs is determined by their parts as follows:

  1. domain (returns -1 or 1 if not equal)
  2. node (returns -1 or 1 if not equal)
  3. resource (returns -1 or 1 if not equal)
Parameters:
{String|jabberwerx.JID} jid
The JID (or string represting a JID) to compare to
Throws:
{jabberwerx.JID.InvalidJIDError}
If {jid} is not a valid JID
Returns:
{Number} -1, 0, or 1 if this JID is before, equal to, or after {jid}

{Boolean} equals(jid)

Determines if this JID is equal to the given JID.

Parameters:
{String|jabberwerx.JID} jid
The JID (or string representing a JID) to compare to
Returns:
{Boolean} true if this JID and {jid} represent the same JID value

<static> {String} jabberwerx.JID.escapeNode(input)

Translates the given input into a valid node for a JID. This method performs the translation according to the escaping rules in XEP-0106: JID Escaping.

Parameters:
{String} input
The string to translate
Throws:
{TypeError}
if {input} is not a string; or if {input} starts or ends with ' '
Returns:
{String} The translated string
See:
XEP-0106: JID Escaping

{jabberwerx.JID} getBareJID()

Returns the bare JID form of this JID. A bare JID consists of the node and domain, but not the resource. If this JID is already a bare JID, this method returns the current JID. Otherwise, a new JID object is created that contains only the node and domains.

Returns:
{jabberwerx.JID} The "bare" JID from this JID

{String} getBareJIDString()

Returns the bare JID form of this JID as a string. This method is a convenience over calling getBareJID().toString().

Returns:
{String} The "bare" JID, as a string
See:
#getBareJID
#toString

{String} getDomain()

Retrieves the domain value for this JID.

Returns:
{String} The JID's domain

{String} getNode()

Retrieves the node value for this JID. If this JID does not have a node, this method returns "".

Returns:
{String} The JID's node

{String} getResource()

Retrieves the resource value for this JID. If this JID does not have a resource, this method returns "".

Returns:
{String} The JID's resource

<inner> prepFN(test)
Parameters:
test

{Boolean} shouldBeSerializedInline()

Determines if this type should be serialized inline with other primitive (boolean, number, string) or inlinable types.

Returns:
{Boolean} Always true

{String} toDisplayString()

Retrieves the display string representing this JID. This method returns a JID with the node portion unescaped via jabberwerx.JID#.unescapeNode. As such, the returned string may not be a valid JID.

Returns:
{String} The display string representation

{String} toString()

Retrieves the string respesenting this JID.

Returns:
{String} The string representation

<static> {String} jabberwerx.JID.unescapeNode(input)

Translates the given input from a valid node for a JID. This method performs the translation according to the unescaping rules in XEP-0106: JID Escaping.

Parameters:
{String} input
The string to translate
Throws:
{TypeError}
if {input} is not a string
Returns:
{String} The translated string
See:
XEP-0106: JID Escaping

wasUnserialized()

Called just after this JID is unserialized. This method recreates the internal structures from the string representation.


Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 02 2014 13:23:42 GMT-0600 (MDT)