com.echomine.jabber
Class DefaultMessageParser

java.lang.Object
  extended by com.echomine.jabber.DefaultMessageParser
All Implemented Interfaces:
JabberCode, JabberMessageParser

public class DefaultMessageParser
extends java.lang.Object
implements JabberMessageParser, JabberCode

Contains a list of message parsers. Essentially, for each type of message, there should be a registered parser for it that will be able to process the incoming data.

When a handler receives a message, it will lookup a message class name that can be instantiated to parse the incoming message. Thus, for each custom message that you create, you should register that message's class name. This includes classes that are contained inside the IQ Message. In fact, the way that the IQMessageParser works is it calls this class again to retrieve a second parser for the message contained inside the IQ Message.


Field Summary
 
Fields inherited from interface com.echomine.jabber.JabberCode
MSG_CHAT, MSG_INIT, MSG_IQ, MSG_IQ_AGENTS, MSG_IQ_AUTH, MSG_IQ_BROWSE, MSG_IQ_DISCO_INFO, MSG_IQ_DISCO_ITEMS, MSG_IQ_GATEWAY, MSG_IQ_LAST, MSG_IQ_OOB, MSG_IQ_PRIVATE, MSG_IQ_REGISTER, MSG_IQ_ROSTER, MSG_IQ_SEARCH, MSG_IQ_TIME, MSG_IQ_VACATION, MSG_IQ_VCARD, MSG_IQ_VERSION, MSG_IQ_XMLRPC, MSG_PRESENCE, MSG_UNKNOWN, MSG_X_DATA, MSG_X_DELAY, MSG_X_EVENT, MSG_X_EXPIRE, MSG_X_OOB, MSG_X_PGP_ENCRYPTED, MSG_X_PGP_SIGNED, MSG_X_ROSTER, PARSER_CHAT, PARSER_IQ, PARSER_IQ_AGENTS, PARSER_IQ_AUTH, PARSER_IQ_BROWSE, PARSER_IQ_DISCO_INFO, PARSER_IQ_DISCO_ITEMS, PARSER_IQ_GATEWAY, PARSER_IQ_LAST, PARSER_IQ_OOB, PARSER_IQ_PRIVATE, PARSER_IQ_REGISTER, PARSER_IQ_ROSTER, PARSER_IQ_SEARCH, PARSER_IQ_TIME, PARSER_IQ_VACATION, PARSER_IQ_VCARD, PARSER_IQ_VERSION, PARSER_IQ_XMLRPC, PARSER_PRESENCE, PARSER_X_DATA, PARSER_X_DELAY, PARSER_X_EVENT, PARSER_X_EXPIRE, PARSER_X_OOB, PARSER_X_PGP_ENCRYPTED, PARSER_X_PGP_SIGNED, PARSER_X_ROSTER, XMLNS_CHAT, XMLNS_ERROR_STANZA, XMLNS_ERROR_STREAM, XMLNS_IQ, XMLNS_IQ_AGENTS, XMLNS_IQ_AUTH, XMLNS_IQ_BROWSE, XMLNS_IQ_DISCO_INFO, XMLNS_IQ_DISCO_ITEMS, XMLNS_IQ_GATEWAY, XMLNS_IQ_LAST, XMLNS_IQ_OOB, XMLNS_IQ_PRIVATE, XMLNS_IQ_REGISTER, XMLNS_IQ_ROSTER, XMLNS_IQ_SEARCH, XMLNS_IQ_TIME, XMLNS_IQ_VACATION, XMLNS_IQ_VCARD, XMLNS_IQ_VERSION, XMLNS_IQ_XMLRPC, XMLNS_PRESENCE, XMLNS_STREAM, XMLNS_X_DATA, XMLNS_X_DELAY, XMLNS_X_EVENT, XMLNS_X_EXPIRE, XMLNS_X_OOB, XMLNS_X_PGP_ENCRYPTED, XMLNS_X_PGP_SIGNED, XMLNS_X_ROSTER
 
Constructor Summary
DefaultMessageParser()
           
 
Method Summary
 JabberMessage createMessage(java.lang.String qName, Namespace ns, Element msgTree)
          instantiate a message object by looking at the DOM tree.
 void removeParser(java.lang.String qName, Namespace ns)
          removes the message parser associated with a specific namespace tag
 void setParser(java.lang.String qName, Namespace ns, java.lang.String msgClass)
          sets a message parser to handle a specific namespace.
 boolean supportsParsingFor(java.lang.String qName, Namespace ns)
          checks whether a parser is registered for the specified qname and namespace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMessageParser

public DefaultMessageParser()
Method Detail

supportsParsingFor

public boolean supportsParsingFor(java.lang.String qName,
                                  Namespace ns)
checks whether a parser is registered for the specified qname and namespace


removeParser

public void removeParser(java.lang.String qName,
                         Namespace ns)
removes the message parser associated with a specific namespace tag


setParser

public void setParser(java.lang.String qName,
                      Namespace ns,
                      java.lang.String msgClass)
               throws ParseException
sets a message parser to handle a specific namespace. If a parser already exists for the specific namespace, the new parser will replace the old one. This way, if you decide to override the default parsers, you can do so in an easy manner.

Parameters:
qName - the fully qualified tag name
ns - the Namespace for the tag element
msgClass - the message class that will be instantiated
Throws:
ParseException - thrown when class is not found or class is not a message parser

createMessage

public JabberMessage createMessage(java.lang.String qName,
                                   Namespace ns,
                                   Element msgTree)
                            throws MessageNotSupportedException
instantiate a message object by looking at the DOM tree. It does this through reflection.

Specified by:
createMessage in interface JabberMessageParser
Throws:
MessageNotSupportedException - if no class is able to parse this message


Copyright © 2001-2005 Echomine. All Rights Reserved.