JSJaC

## Class JSJaCPacket

    Object
       |
       +--JSJaCPacket

Direct Known Subclasses:
  JSJaCMessage, JSJaCIQ, JSJaCPresence

class JSJaCPacket

Somewhat abstract base class for all kinds of specialised packets
Defined in JSJaCPacket.js

Field Summary
`String` | `xml` Returns a string representation of the raw xml content of this packet.

Constructor Summary
`JSJaCPacket(<String> name)` Creates a new packet with given root tag name (for internal use)

Method Summary
`JSJaCPacket` | `appendNode(<String> element)` Appends node created by buildNode to this packets parent node.
`Node` | `buildNode(elementName)` Builds a node using script.aculo.us' Dom Builder notation.
`JSJaCPacket` | `clone()` Returns a copy of this node
`JSJaCPacket` | `errorReply(<STANZA_ERROR> stanza_error)` Returns an error condition reply according to XEP-0086.
`Node` | `getChild(<String> name, <String> ns)` Gets a child element of this packet.
`String` | `getChildVal(<String> name, <String> ns)` Gets the node value of a child element of this packet.
`Document` | `getDoc()` Gets the associated Document for this packet.
`String` | `getFrom()` Gets the 'from' attribute of this packet.
`JSJaCJID` | `getFromJID()` Gets the 'from' attribute of this packet as a JSJaCJID object
`String` | `getID()` Gets the 'id' of this packet
`Node` | `getNode()` Gets the root node of this packet
`String` | `getTo()` Gets the 'to' attribute of this packet
`JSJaCJID` | `getToJID()` Gets the 'to' attribute of this packet as a JSJaCJID object
`String` | `getType()` Gets the 'type' of this packet
`String` | `getXMLLang()` Gets the 'xml:lang' of this packet
`String` | `getXMLNS()` Gets the 'xmlns' (xml namespace) of the root node of this packet
`boolean` | `isError()` Checks if packet is of type 'error'
`String` | `pType()` Gets the type (name of root element) of this packet, i.e.
`JSJaCPacket` | `setFrom(from)` Sets the 'from' attribute of the root node of this packet.
`JSJaCPacket` | `setID(<String> id)` Sets 'id' attribute of the root node of this packet.
`JSJaCPacket` | `setTo(<String> to)` Sets the 'to' attribute of the root node of this packet
`JSJaCPacket` | `setType(<String> type)` Sets the 'type' attribute of the root node of this packet.
`JSJaCPacket` | `setXMLLang(<String> xmllang)` Sets 'xml:lang' for this packet
`<static> JSJaCPacket` | `wrapNode(<Node> node)` Tries to transform a w3c DOM node to JSJaC's internal representation (JSJaCPacket type, one of JSJaCPresence, JSJaCMessage, JSJaCIQ)

Field Detail

### xml

    String xml

Returns a string representation of the raw xml content of this packet.

Constructor Detail

### JSJaCPacket

    JSJaCPacket(<String> name)

Creates a new packet with given root tag name (for internal use)

Parameters:

`name` - The root tag name of the packet (i.e. one of 'message', 'iq' or 'presence')

Method Detail

### appendNode

    JSJaCPacket appendNode(<String> element)

Appends node created by buildNode to this packets parent node.

Parameters:

`element` - A name plus an object hash with attributes (optional) plus an array of childnodes (optional)

`link` - http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247 Node} element The node to append or

Returns:

This packet

See:

- buildNode()

### buildNode

    Node buildNode(elementName)

Builds a node using script.aculo.us' Dom Builder notation. This code is taken from script.aculo.us' Dom Builder and has been modified to suit our needs.
The original parts of the code do have the following copyright and license notice:
Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.acu lo.us)
script.aculo.us is freely distributable under the terms of an MIT-style licen se. // For details, see the script.aculo.us web site: http://script.aculo.us/

Returns:

The newly created node

Author: Thomas Fuchs , Stefan Strigler

### clone

    JSJaCPacket clone()

Returns a copy of this node

Returns:

a copy of this node

### errorReply

    JSJaCPacket errorReply(<STANZA_ERROR> stanza_error)

Returns an error condition reply according to XEP-0086. Creates a clone of the calling packet with senders and recipient exchanged and error stanza appended.

Parameters:

`stanza_error` - an error stanza containing error cody, type and condition of the error to be indicated

Returns:

an error reply packet

### getChild

    Node getChild(<String> name, <String> ns)

Gets a child element of this packet. If no params given returns first child.

Parameters:

`name` - Tagname of child to retrieve. Use '*' to match any tag. [optional]

`ns` - Namespace of child. Use '*' to match any ns.[optional]

Returns:

The child node, null if none found

### getChildVal

    String getChildVal(<String> name, <String> ns)

Gets the node value of a child element of this packet.

Parameters:

`name` - Tagname of child to retrieve.

`ns` - Namespace of child

Returns:

The value of the child node, empty string if none found

### getDoc

    Document getDoc()

Gets the associated Document for this packet.

### getFrom

    String getFrom()

Gets the 'from' attribute of this packet.

### getFromJID

    JSJaCJID getFromJID()

Gets the 'from' attribute of this packet as a JSJaCJID object

### getID

    String getID()

Gets the 'id' of this packet

### getNode

    Node getNode()

Gets the root node of this packet

### getTo

    String getTo()

Gets the 'to' attribute of this packet

### getToJID

    JSJaCJID getToJID()

Gets the 'to' attribute of this packet as a JSJaCJID object

### getType

    String getType()

Gets the 'type' of this packet

### getXMLLang

    String getXMLLang()

Gets the 'xml:lang' of this packet

### getXMLNS

    String getXMLNS()

Gets the 'xmlns' (xml namespace) of the root node of this packet

### isError

    boolean isError()

Checks if packet is of type 'error'

Returns:

'true' if this packet is of type 'error', 'false' otherwise

### pType

    String pType()

Gets the type (name of root element) of this packet, i.e. one of 'presence', 'message' or 'iq'

Returns:

the top level tag name

### setFrom

    JSJaCPacket setFrom(from)

Sets the 'from' attribute of the root node of this packet. Usually this is not needed as the server will take care of this automatically.

### setID

    JSJaCPacket setID(<String> id)

Sets 'id' attribute of the root node of this packet.

Parameters:

`id` - The id of the packet.

### setTo

    JSJaCPacket setTo(<String> to)

Sets the 'to' attribute of the root node of this packet

Parameters:

`to` -

### setType

    JSJaCPacket setType(<String> type)

Sets the 'type' attribute of the root node of this packet.

Parameters:

`type` - The type of the packet.

### setXMLLang

    JSJaCPacket setXMLLang(<String> xmllang)

Sets 'xml:lang' for this packet

Parameters:

`xmllang` - The xml:lang of the packet.

### wrapNode

    <static> JSJaCPacket wrapNode(<Node> node)

Tries to transform a w3c DOM node to JSJaC's internal representation (JSJaCPacket type, one of JSJaCPresence, JSJaCMessage, JSJaCIQ)

Parameters:

`node` - The node to be transformed

Returns:

A JSJaCPacket representing the given node. If node's root elemenent is not one of 'message', 'presence' or 'iq', `null` is being returned.

JSJaC

Documentation generated by JSDoc on Tue Jan 5 02:48:26 2021