Class jabberwerx.Stanza (MINIMAL)
Extends
JWModel.
A representation of an XMPP stanza.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
jabberwerx.Stanza(root)
Creates a new Stanza with the given root element or root name. |
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
jabberwerx.Stanza.ERR_BAD_REQUEST
ErrorInfo for a bad request error. |
| <static> |
jabberwerx.Stanza.ERR_CONFLICT
ErrorInfo for a conflict error. |
| <static> |
jabberwerx.Stanza.ERR_FEATURE_NOT_IMPLEMENTED
ErrorInfo for a feature not implemented error. |
| <static> |
jabberwerx.Stanza.ERR_FORBIDDEN
ErrorInfo for a forbidden error. |
| <static> |
jabberwerx.Stanza.ERR_INTERNAL_SERVER_ERROR
ErrorInfo for an internal server error. |
| <static> |
jabberwerx.Stanza.ERR_ITEM_NOT_FOUND
ErrorInfo for a non-existent item. |
| <static> |
jabberwerx.Stanza.ERR_JID_MALFORMED
ErrorInfo for a malformed JID error. |
| <static> |
jabberwerx.Stanza.ERR_NOT_ACCEPTABLE
ErrorInfo for a not acceptable error. |
| <static> |
jabberwerx.Stanza.ERR_NOT_ALLOWED
ErrorInfo for a not allowed error. |
| <static> |
jabberwerx.Stanza.ERR_NOT_AUTHORIZED
ErrorInfo for a not authorized error. |
| <static> |
jabberwerx.Stanza.ERR_REMOTE_SERVER_TIMEOUT
ErrorInfo for a remote server timeout error. |
| <static> |
jabberwerx.Stanza.ERR_SERVICE_UNAVAILABLE
ErrorInfo for a service unavailable error. |
|
The timestamp of this Stanza. |
| Method Attributes | Method Name and Description |
|---|---|
|
clone()
Creates a duplicate of this stanza. |
|
| <static> |
jabberwerx.Stanza.createWithNode(node)
Factory method for creating a stanza from an XML node. |
|
errorReply(err)
Creates an error stanza based on this Stanza. |
|
|
getDoc()
Retrieves the document that owns this Stanza's XML element. |
|
|
Returns an ErrorInfo object containing the error information of this stanza if there is any. |
|
|
getFrom()
Retrieves the "from" address for this Stanza. |
|
|
Retrieves the "from" address for this Stanza as a JID. |
|
|
getID()
Retrieves the ID for this Stanza. |
|
|
getNode()
Retrieves the XML element representing this Stanza. |
|
|
getTo()
Retrieves the "to" address for this Stanza. |
|
|
getToJID()
Retrieves the "to" address for this Stanza as a JID. |
|
|
getType()
Retrieves the type for this Stanza. |
|
|
isError()
Determines if this Stanza is reporting an error. |
|
|
pType()
Retrieves the stanza-type for this Stanza. |
|
|
setFrom(addr)
Changes or removes the "from" address for this Stanza. |
|
|
setID(id)
Changes or removes the ID for this Stanza. |
|
|
setTo(addr)
Changes or removes the "to" address for this Stanza. |
|
|
setType(type)
Changes or removes the type for this Stanza. |
|
|
swap(include_from)
Creates a stanza with the addresses reversed. |
|
|
Called after this Stanza is deserialized from persistence. |
|
|
Called before this Stanza is serialized for persistence. |
|
|
xml()
Generates the XML string representation of this Stanza. |
Creates a new Stanza with the given root element or root name.
- Parameters:
- {Element|String} root
- The element name of the stanza
- Throws:
- {TypeError}
- If {root} is not a valid Element or String
ErrorInfo for a bad request error.
ErrorInfo for a conflict error.
ErrorInfo for a feature not implemented error.
ErrorInfo for a forbidden error.
ErrorInfo for an internal server error.
ErrorInfo for a non-existent item.
ErrorInfo for a malformed JID error.
ErrorInfo for a not acceptable error.
ErrorInfo for a not allowed error.
ErrorInfo for a not authorized error.
ErrorInfo for a remote server timeout error.
ErrorInfo for a service unavailable error.
The timestamp of this Stanza. If this stanza contains a "{urn:xmpp:time}delay" or "{jabber:x:delay}x" child element, this value reflects the date specified by that element. Otherwise, it is the timestamp at which this stanza was created.
Creates a duplicate of this stanza. This method performs a deep copy of the DOM.
- Returns:
- {jabberwerx.Stanza} The cloned stanza
Factory method for creating a stanza from an XML node.
- Parameters:
- {Element} node
- An XML node.
- Returns:
- {jabberwerx.Stanza} The Stanza object wrapping the given node
Creates an error stanza based on this Stanza. This method calls #swap, sets the type to "error", and appends an <error/> element with the data from {err}.
- Parameters:
- {jabberwerx.Stanza.ErrorInfo} err
- The error information
- Throws:
- {TypeError}
- If {err} is not a ErrorInfo
- Returns:
- {jabberwerx.Stanza} The error stanza
Retrieves the document that owns this Stanza's XML element.
- Returns:
- {Document} The owning document for the Stanza's element
Returns an ErrorInfo object containing the error information of this stanza if there is any. Otherwise it returns null.
- Returns:
- {jabberwerx.Stanza.ErrorInfo} The ErrorInfo object
Retrieves the "from" address for this Stanza.
- Returns:
- {String} The address this Stanza is from
Retrieves the "from" address for this Stanza as a JID. This method will attempt to convert the "from" address string into a JID, or return null if unable to.
- Returns:
- {jabberwerx.JID} The JID this Stanza is from
Retrieves the ID for this Stanza.
- Returns:
- {String} The ID
Retrieves the XML element representing this Stanza.
- Returns:
- {Element} The Stanza's element
Retrieves the "to" address for this Stanza.
- Returns:
- {String} The address this Stanza is to
Retrieves the "to" address for this Stanza as a JID. This method will attempt to convert the "to" address string into a JID, or return null if unable to.
- Returns:
- {jabberwerx.JID} The JID this Stanza is to
Retrieves the type for this Stanza. This is equivalent to retrieving the "type" attribute from #getNode.
- Returns:
- {String} The type
Determines if this Stanza is reporting an error.
- Returns:
- {Boolean} true if this is a Stanza of type error
Retrieves the stanza-type for this Stanza. This is equivalent to retrieving the node name from #getNode.
- Returns:
- {String} The type of stanza (e.g. "message")
Changes or removes the "from" address for this Stanza.
- Parameters:
- {String|jabberwerx.JID} addr Optional
- The new from address
Changes or removes the ID for this Stanza.
If {id} is "", undefined, or null, any current value is removed.
- Parameters:
- {String} id Optional
- The new ID
Changes or removes the "to" address for this Stanza.
- Parameters:
- {String|jabberwerx.JID} addr Optional
- The new to address
Changes or removes the type for this Stanza.
If {type} is "", undefined, or null, any current value is removed.
- Parameters:
- {String} type Optional
- The new type
Creates a stanza with the addresses reversed. This method clones this Stanza, sets the "to" address to be the original "from" address, then (optionally) sets the "from" address to be the original "to" address.
- Parameters:
- {Boolean} include_from Optional
- true if the new stanza should include a "from" address (default is false)
- Returns:
- {jabberwerx.Stanza} The cloned stanza, with addresses swapped.
Called after this Stanza is deserialized from persistence. This method rebuilds the DOM structure from the saved XML string and converts the timestamp from a number into a Date object.
Called before this Stanza is serialized for persistence. This method saves a string representation of the XMPP stanza and converts the timestamp from a Date object into a number.
Generates the XML string representation of this Stanza.
- Returns:
- {String} The XML