com.echomine.jabber
Class JDOMXMessageHandler

java.lang.Object
  extended by com.echomine.jabber.JabberMessageHandler
      extended by com.echomine.jabber.JDOMMessageHandler
          extended by com.echomine.jabber.JDOMXMessageHandler

public class JDOMXMessageHandler
extends JDOMMessageHandler

This handler adds support for handling any jabber extensions. If your message does not support X Namespaces, then there is no need to subclass from this handler as it'll just cause extra message processing overhead.

First, the handler looks at X elements (ie. elements with the name "x") only. Second, once the entire message is parsed, the handler will create a list of X Messages that contains the data. It does this by consulting the Message Builder List and for each X Namespace that is recognized, it will create a JabberMessage instance for that X Message and store the JabberMessage in the list for retrieval. If it doesn't find a message builder, it will create a JabberJDOMMessage as default message type.

If you want to work with X Messages, you can subclass from this handler. Then, the procedure works like this:

1. In your startMessage(), you call super.startMessage() to initialize the X Message Handler elements as well.
2. In your startElement(), you call super.startElement() to let the X Message Handler work its magic. Then you proceed to process your the elements the way you want to.
3. In your endElement(), you call super.endElement().
4. In your endMessage(), you call super.endMessage().
5. In your getMessage(), you can then retrieve all the X Messages from the X Message Handler by calling getXMessages(), which will return a List.
6. You then add it to the JabberMessage you created or use it however you like.


Constructor Summary
JDOMXMessageHandler(JabberMessageParser msgParser)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          the methods that must be implemented to work with the XML content that's coming in
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          the methods that must be implemented to work with the XML content that's coming in
 void endMessage()
          This method will save the X Messages into the message object
 java.util.HashMap getXMessages()
           
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attr)
          the methods that must be implemented to work with the XML content that's coming in
 void startMessage()
          This method is called when the beginning of the message is received.
 
Methods inherited from class com.echomine.jabber.JDOMMessageHandler
getDOM, getMessage
 
Methods inherited from class com.echomine.jabber.JabberMessageHandler
getMessageParser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDOMXMessageHandler

public JDOMXMessageHandler(JabberMessageParser msgParser)
Method Detail

getXMessages

public java.util.HashMap getXMessages()
Returns:
a list of JabberMessage instances of the X Namespace

startMessage

public void startMessage()
Description copied from class: JDOMMessageHandler
This method is called when the beginning of the message is received. Any sort of resetting or initializing should be done here.

Overrides:
startMessage in class JDOMMessageHandler

endMessage

public void endMessage()
This method will save the X Messages into the message object

Overrides:
endMessage in class JDOMMessageHandler

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attr)
Description copied from class: JabberMessageHandler
the methods that must be implemented to work with the XML content that's coming in

Overrides:
startElement in class JDOMMessageHandler

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
Description copied from class: JabberMessageHandler
the methods that must be implemented to work with the XML content that's coming in

Overrides:
endElement in class JDOMMessageHandler

characters

public void characters(char[] ch,
                       int start,
                       int length)
Description copied from class: JabberMessageHandler
the methods that must be implemented to work with the XML content that's coming in

Overrides:
characters in class JDOMMessageHandler


Copyright © 2001-2005 Echomine. All Rights Reserved.