com.realtime.xmpp.dom
Class Xmpp2DomTransformer

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--org.dom4j.io.SAXContentHandler
              |
              +--com.realtime.xmpp.dom.Xmpp2DomTransformer
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler

public class Xmpp2DomTransformer
extends org.dom4j.io.SAXContentHandler

XMPP transformer that creates DOMs from XMPP streams using the SAX event model.

To use this transformer, construct an instance using the XMPP stream to the Jabber server. Then register as a transformer listener to receive all incoming packets.

If you just want to send one packet and process the response packet, use the DomPacketSender.

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

Field Summary
static int HEAD
          Make new listener the first to get packets.
protected  java.util.List m_listeners
          The packet listeners.
protected  XmppSession m_session
          The XMPP session we are listening to.
static int TAIL
          Make new listener the last to get new packets.
 
Constructor Summary
Xmpp2DomTransformer(XmppSession session)
          Construct a transformer for an XMPP stream.
 
Method Summary
 void addListener(DomPacketListener listener)
          Add a packet listener to the builder.
 void addListener(DomPacketListener listener, int pos)
          Add a packet listener to the builder.
 void endDocument()
          This event is not propogated to the XMPP interpreter.
 void endElement(java.lang.String sUri, java.lang.String sLocalName, java.lang.String sQName)
          Intercept endElement to kludge localname.
 XmppSession getSession()
          Provide the XMPP session we are using.
 void removeListener(DomPacketListener listener)
          Remove a packet listener from the builder.
 void startElement(java.lang.String sUri, java.lang.String sLocalName, java.lang.String sQName, org.xml.sax.Attributes attributes)
          Intercept startElement to kludge localname.
 
Methods inherited from class org.dom4j.io.SAXContentHandler
addAttributes, addDeclaredNamespaces, addDTDDeclaration, addExternalDTDDeclaration, attributeDecl, characters, comment, completeCurrentTextNode, createDocument, createElementStack, elementDecl, endCDATA, endDTD, endEntity, endPrefixMapping, error, externalEntityDecl, fatalError, getDocument, getElementStack, getEntityResolver, getInputSource, internalEntityDecl, isIgnorableEntity, isIncludeExternalDTDDeclarations, isIncludeInternalDTDDeclarations, isMergeAdjacentText, isStripWhitespaceText, notationDecl, processingInstruction, setElementStack, setEntityResolver, setIncludeExternalDTDDeclarations, setIncludeInternalDTDDeclarations, setInputSource, setMergeAdjacentText, setStripWhitespaceText, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
ignorableWhitespace, resolveEntity, setDocumentLocator, skippedEntity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEAD

public static final int HEAD
Make new listener the first to get packets.

See Also:
Constant Field Values

TAIL

public static final int TAIL
Make new listener the last to get new packets.

See Also:
Constant Field Values

m_listeners

protected java.util.List m_listeners
The packet listeners.


m_session

protected XmppSession m_session
The XMPP session we are listening to.

Constructor Detail

Xmpp2DomTransformer

public Xmpp2DomTransformer(XmppSession session)

Construct a transformer for an XMPP stream. Automatically registers this transformer with the stream.

Parameters:
session - The XMPP session to the Jabber server.
Method Detail

getSession

public XmppSession getSession()

Provide the XMPP session we are using.

* @return XmppSession we are using.


startElement

public void startElement(java.lang.String sUri,
                         java.lang.String sLocalName,
                         java.lang.String sQName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException

Intercept startElement to kludge localname. This is done to fix the SAXContentHandlers (mis)interpretation of the qualified name.

* @param sUri The URI.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.dom4j.io.SAXContentHandler
Parameters:
sLocalName - The element local name.
sQName - The elements qualified name.
attributes - The specified or defaulted attributes.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

endElement

public void endElement(java.lang.String sUri,
                       java.lang.String sLocalName,
                       java.lang.String sQName)

Intercept endElement to kludge localname. This is done to fix the SAXContentHandlers (mis)interpretation of the qualified name.

* @param sUri The URI.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.dom4j.io.SAXContentHandler
Parameters:
sLocalName - The element local name.
sQName - The elements qualified name.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

addListener

public void addListener(DomPacketListener listener)

Add a packet listener to the builder. Each new XMPP packet will be sent to each registered listener. It is important that each listener NOT modify the packet. The SAME packet object graph is handed to each listener.

This listener will become the last listener on the list. If you want control over the position of the listener, use the addListener( listener, position ) method.

Parameters:
listener - The DOM packet listener.

addListener

public void addListener(DomPacketListener listener,
                        int pos)

Add a packet listener to the builder. Each new XMPP packet will be sent to each registered listener. It is important that each listener NOT modify the packet. The SAME packet object graph is handed to each listener.

* @param listener The DOM packet listener.

Parameters:
pos - The listener position, as defined in this class.

removeListener

public void removeListener(DomPacketListener listener)

Remove a packet listener from the builder.

* @param listener


endDocument

public void endDocument()
                 throws org.xml.sax.SAXException

This event is not propogated to the XMPP interpreter. Instead, the last element of each XMPP packet causes this event to be fired.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.dom4j.io.SAXContentHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endDocument()


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