Class jabberwerx.Stanza (MINIMAL)
Extends
jabberwerx.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. |
|
<static> |
jabberwerx.Stanza.generateID()
Generate a secure stanza ID
Result will be a string suitable for any stanza id attribute.
|
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. |
- Methods borrowed from class jabberwerx.JWModel:
- applyEvent, event, shouldBeSavedWithGraph
- Methods borrowed from class jabberwerx.JWBase:
- destroy, getClassName, graphUnserialized, init, invocation, shouldBeSerializedInline, toString
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.
- Returns:
- {jabberwerx.Stanza} The cloned stanza
- 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
- Returns:
- {String} The 'secure' stanza Identifier.
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
- 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.
Generates the XML string representation of this Stanza.
- Returns:
- {String} The XML