|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.echomine.jabber.JabberMessageHandler
com.echomine.jabber.JDOMMessageHandler
com.echomine.jabber.JDOMXMessageHandler
public class JDOMXMessageHandler
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 |
---|
public JDOMXMessageHandler(JabberMessageParser msgParser)
Method Detail |
---|
public java.util.HashMap getXMessages()
public void startMessage()
JDOMMessageHandler
startMessage
in class JDOMMessageHandler
public void endMessage()
endMessage
in class JDOMMessageHandler
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attr)
JabberMessageHandler
startElement
in class JDOMMessageHandler
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
JabberMessageHandler
endElement
in class JDOMMessageHandler
public void characters(char[] ch, int start, int length)
JabberMessageHandler
characters
in class JDOMMessageHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |