com.realtime.xmpp.dom
Class DomPacketInterpreter

java.lang.Object
  |
  +--com.realtime.xmpp.dom.DomPacketInterpreter

public class DomPacketInterpreter
extends java.lang.Object

Helper class to interpret a DOM XMPP packet. Provides static methods for quick evaluations of documents.

Version:
1.0 Copyright © 2002 Real Time Entertainment Group, LLC - All rights reserved.
Author:
Mike Prince

Constructor Summary
DomPacketInterpreter()
           
 
Method Summary
static org.dom4j.Element getError(org.dom4j.Element packet)
          Provide the element containing the error code and description.
static int getErrorCode(org.dom4j.Element packet)
          Inspect the packet and look for children named error.
static java.lang.String getFrom(org.dom4j.Element packet)
          Provide the 'from' field.
static java.lang.String getId(org.dom4j.Element packet)
          Provide the 'id' field.
static java.lang.String getTo(org.dom4j.Element packet)
          Provide the 'to' field.
static java.lang.String getType(org.dom4j.Element packet)
          Provide the type of the iq packet (get,set, result, or error).
static boolean hasError(org.dom4j.Element packet)
          Inspect the packet and look for children named error.
static boolean isInfoQuery(org.dom4j.Element packet)
          Test if this packet is an InfoQuery.
static boolean isMessage(org.dom4j.Element packet)
          Test if this packet is a message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomPacketInterpreter

public DomPacketInterpreter()
Method Detail

getTo

public static java.lang.String getTo(org.dom4j.Element packet)

Provide the 'to' field.

Returns:
The contents of the 'to' field, or null if the field was not provided.

getFrom

public static java.lang.String getFrom(org.dom4j.Element packet)

Provide the 'from' field.

Returns:
The contents of the 'from' field, or null if the field was not provided.

getId

public static java.lang.String getId(org.dom4j.Element packet)

Provide the 'id' field.

Returns:
The contents of the 'id' field, or null if the field was not provided.

isMessage

public static boolean isMessage(org.dom4j.Element packet)
Test if this packet is a message.

Parameters:
packet - The packet to test.
Returns:
True if this is a message packet.

isInfoQuery

public static boolean isInfoQuery(org.dom4j.Element packet)
Test if this packet is an InfoQuery.

Parameters:
packet - The packet to test.
Returns:
True if this is an InfoQuery packet.

getType

public static java.lang.String getType(org.dom4j.Element packet)

Provide the type of the iq packet (get,set, result, or error).

* @param packet * @return boolean


hasError

public static boolean hasError(org.dom4j.Element packet)

Inspect the packet and look for children named error. If any are found, then return true.

Parameters:
packet - The XMPP packet to inspect. * @return True if any of the packets first level child elements are named error.

getErrorCode

public static int getErrorCode(org.dom4j.Element packet)

Inspect the packet and look for children named error. If any are found, then return the error code.

Parameters:
packet - The XMPP packet to inspect.
Returns:
The error code, is one was present, or 0 for success.

getError

public static org.dom4j.Element getError(org.dom4j.Element packet)

Provide the element containing the error code and description.

Parameters:
packet - The XMPP packet to inspect.
Returns:
The element named 'error' and containing an error code. The element may also contain a description. If no error element was found, this will return null.


Copyright © 2002,2003 Real Time Entertainment Group, LLC. All Rights Reserved.