|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.realtime.xmpp.SaxEventManager
Interpret a stream of SAX events and pass the events to interested listeners. This class is used by the XmppStream to propogate SAX events to XMPP stream interpreters, or "transformers". Each transformer creates an in-memory representation of packets, and then signals packet listeners.
This plugable architecture provides the freedom to adopt whichever packet object model suits the task at hand.
As per the XMPP-Core draft document "XML streams are used to transport a subset of XML. Specifically, XML streams SHOULD NOT contain processing instructions, non-predefined entities (as defined in Section 4.6 of the XML 1.0 specification [8]), comments, or DTDs. Any such XML data SHOULD be ignored." As such, unecessary/illegal SAX events are not propogated.
Field Summary | |
protected org.xml.sax.ContentHandler[] |
m_contentHandlers
The list of ContentHandlers. |
protected int |
m_elementDepth
The current element depth. |
protected org.xml.sax.ContentHandler[] |
m_newTransformers
The list of new transformers, which will take affect just before the next packet event set starts. |
protected java.util.Map |
m_streamAttributes
Stream attributes. |
Constructor Summary | |
SaxEventManager()
Simple default constructor. |
Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data inside an element. |
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)
Receive notification of the end of an element. |
void |
endPrefixMapping(java.lang.String sPrefix)
Receive notification of the end of a Namespace mapping. |
void |
error(org.xml.sax.SAXParseException e)
Receive notification of a recoverable parser error. |
void |
fatalError(org.xml.sax.SAXParseException e)
Report a fatal XML parsing error. |
java.lang.String |
getAttribute(java.lang.String sQName)
Provide an attribute from the <stream:stream> top level element. |
boolean |
hasAttributes()
Determine if this stream has provided any attributes. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
void |
processingInstruction(java.lang.String sTarget,
java.lang.String sData)
XMPP SHOULD NOT contain processing instructions! |
void |
reset()
Reset this event manager so it's ready to start accepting a fresh set of SAX events. |
void |
setDocumentLocator(org.xml.sax.Locator locator)
Receive a Locator object for document events. |
void |
setTransformers(org.xml.sax.ContentHandler[] transformers)
Set the list of transformers to use for each SAX event. |
void |
skippedEntity(java.lang.String name)
Receive notification of a skipped entity. |
void |
startDocument()
This event is NOT propogated to the XMPP interpreter. |
void |
startElement(java.lang.String sUri,
java.lang.String sLocalName,
java.lang.String sQName,
org.xml.sax.Attributes attributes)
Receive notification of the start of an element. |
void |
startPrefixMapping(java.lang.String sPrefix,
java.lang.String sUri)
Receive notification of the start of a Namespace mapping. |
protected void |
startXmppPacket()
This method is called before the start of each NEW XMPP packet in the XML stream. |
void |
warning(org.xml.sax.SAXParseException e)
Receive notification of a parser warning. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Map m_streamAttributes
protected org.xml.sax.ContentHandler[] m_newTransformers
protected org.xml.sax.ContentHandler[] m_contentHandlers
protected int m_elementDepth
Constructor Detail |
public SaxEventManager()
Method Detail |
public void reset()
public void setTransformers(org.xml.sax.ContentHandler[] transformers)
Set the list of transformers to use for each SAX event. This list DOES NOT go into effect until the start of the next XMPP packet.
transformers
- An array of transformers to handle each SAX event.protected void startXmppPacket()
public void setDocumentLocator(org.xml.sax.Locator locator)
Receive a Locator object for document events. Perhaps this is useful for locating the position in a XMPP stream for SAX events.
setDocumentLocator
in interface org.xml.sax.ContentHandler
locator
- A locator for all SAX document events.ContentHandler.setDocumentLocator(org.xml.sax.Locator)
,
Locator
public void startDocument() throws org.xml.sax.SAXException
This event is NOT propogated to the XMPP interpreter. Instead, the first element of each XMPP packet causes this event to be fired.
startDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.startDocument()
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.
endDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.endDocument()
public void startPrefixMapping(java.lang.String sPrefix, java.lang.String sUri) throws org.xml.sax.SAXException
Receive notification of the start of a Namespace mapping.
startPrefixMapping
in interface org.xml.sax.ContentHandler
sPrefix
- The Namespace prefix being declared.sUri
- The Namespace URI mapped to the prefix.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
public void endPrefixMapping(java.lang.String sPrefix) throws org.xml.sax.SAXException
Receive notification of the end of a Namespace mapping.
endPrefixMapping
in interface org.xml.sax.ContentHandler
sPrefix
- The Namespace prefix being declared.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.endPrefixMapping(java.lang.String)
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
Receive notification of the start of an element.
If this is the first element in the stream then the attributes are cached and made available through getAttribute().
Second level elements trigger a startDocument() event.
startElement
in interface org.xml.sax.ContentHandler
sUri
- The URI.sLocalName
- The element local name.sQName
- The elements qualified name.attributes
- The specified or defaulted attributes.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endElement(java.lang.String sUri, java.lang.String sLocalName, java.lang.String sQName) throws org.xml.sax.SAXException
Receive notification of the end of an element.
Send level elements trigger an endDocument() event.
endElement
in interface org.xml.sax.ContentHandler
sUri
- The URI.sLocalName
- The local name of the element.sQName
- The qualified name of the element.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
Receive notification of character data inside an element.
characters
in interface org.xml.sax.ContentHandler
ch
- The characters.start
- The start position in the character array.length
- The number of characters to use from the
character array.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.characters(char[], int, int)
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
Receive notification of ignorable whitespace in element content.
ignorableWhitespace
in interface org.xml.sax.ContentHandler
ch
- The whitespace characters.start
- The start position in the character array.length
- The number of characters to use from the
character array.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(java.lang.String sTarget, java.lang.String sData)
processingInstruction
in interface org.xml.sax.ContentHandler
sTarget
- The processing instruction target.sData
- The processing instruction data, or null if
none is supplied.public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
skippedEntity
in interface org.xml.sax.ContentHandler
name
- The name of the skipped entity.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.processingInstruction(java.lang.String, java.lang.String)
public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
Receive notification of a parser warning.
The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each warning, such as inserting the message in a log file or printing it to the console.
warning
in interface org.xml.sax.ErrorHandler
e
- The warning information encoded as an exception.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ErrorHandler.warning(org.xml.sax.SAXParseException)
,
SAXParseException
public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
Receive notification of a recoverable parser error.
The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each error, such as inserting the message in a log file or printing it to the console.
error
in interface org.xml.sax.ErrorHandler
e
- The warning information encoded as an exception.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ErrorHandler.warning(org.xml.sax.SAXParseException)
,
SAXParseException
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
Report a fatal XML parsing error.
The default implementation throws a SAXParseException. Application writers may override this method in a subclass if they need to take specific actions for each fatal error (such as collecting all of the errors into a single report): in any case, the application must stop all regular processing when this method is invoked, since the document is no longer reliable, and the parser may no longer report parsing events.
fatalError
in interface org.xml.sax.ErrorHandler
e
- The error information encoded as an exception.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ErrorHandler.fatalError(org.xml.sax.SAXParseException)
,
SAXParseException
public java.lang.String getAttribute(java.lang.String sQName)
Provide an attribute from the <stream:stream> top level element. Typical attributes are id and from.
* @param sQName The name of the attribute. * @return The value of the attribute,
public boolean hasAttributes()
Determine if this stream has provided any attributes. This can also be used to determine if the session opening <stream:stream> element has been received yet.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |