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 and Description |
|---|
JDOMXMessageHandler(JabberMessageParser msgParser) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
getDOM, getMessagegetMessageParserpublic JDOMXMessageHandler(JabberMessageParser msgParser)
public java.util.HashMap getXMessages()
public void startMessage()
JDOMMessageHandlerstartMessage in class JDOMMessageHandlerpublic void endMessage()
endMessage in class JDOMMessageHandlerpublic void startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attr)
JabberMessageHandlerstartElement in class JDOMMessageHandlerpublic void endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
JabberMessageHandlerendElement in class JDOMMessageHandlerpublic void characters(char[] ch,
int start,
int length)
JabberMessageHandlercharacters in class JDOMMessageHandlerCopyright © 2001-2005 Echomine. All Rights Reserved.