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.
Constructor Attributes | Constructor Name and Description |
---|---|
jabberwerx.JID(arg)
Creates a new JID. |
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. |
|
getNode()
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. |
|
toString()
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
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}.
Converts an object into a jabberwerx.JID. This method uses the following algorithm:
- If {val} is an instance of jabberwerx.JID, return it
- If a JID exists in the internal cache that matches the string value of {val}, return it.
- 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}
Compares this JID to the given JID for ordering. The order of two JIDs is determined by their parts as follows:
- domain (returns -1 or 1 if not equal)
- node (returns -1 or 1 if not equal)
- 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}
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
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
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
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
Retrieves the domain value for this JID.
- Returns:
- {String} The JID's domain
Retrieves the node value for this JID. If this JID does not have a node, this method returns "".
- Returns:
- {String} The JID's node
Retrieves the resource value for this JID. If this JID does not have a resource, this method returns "".
- Returns:
- {String} The JID's resource
- Parameters:
- test
Determines if this type should be serialized inline with other primitive (boolean, number, string) or inlinable types.
- Returns:
- {Boolean} Always true
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
Retrieves the string respesenting this JID.
- Returns:
- {String} The string representation
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
Called just after this JID is unserialized. This method recreates the internal structures from the string representation.