Qizx 2.2 API

com.qizx.api.util
Class PushStreamToSAX

java.lang.Object
  extended bycom.qizx.xdm.AttributeList
      extended bycom.qizx.xdm.XMLPushStreamBase
          extended bycom.qizx.api.util.PushStreamToSAX
All Implemented Interfaces:
Attributes, XMLPushStream

public class PushStreamToSAX
extends com.qizx.xdm.XMLPushStreamBase

An implementation of XMLPushStream that converts to SAX2 events.

This class can be used to export or convert a XML tree from Qizx to any handler accepting SAX2 events.


Field Summary
 
Fields inherited from class com.qizx.xdm.XMLPushStreamBase
baseURI, contextualMappings, docStarted, dtdInternalSubset, dtdName, dtdPublicId, dtdSystemid, elementName, elementStarted, endDocumentDone, maxVolume, spaceNeeded, startDocumentDone, trace, volume, VOLUME_LIMIT
 
Fields inherited from class com.qizx.xdm.AttributeList
attrCnt, attrNames, attrTypes, attrValues, nsContext
 
Fields inherited from interface com.qizx.api.XMLPushStream
NSCOPY_NOPRESERVE_INHERIT, NSCOPY_NOPRESERVE_NOINHERIT, NSCOPY_PRESERVE_INHERIT, NSCOPY_PRESERVE_NOINHERIT
 
Constructor Summary
PushStreamToSAX()
          Creates an adapter without handlers.
PushStreamToSAX(DefaultHandler handler)
          Creates an SAX adapter directly bound to a SAX DefaultHandler.
 
Method Summary
protected  void flushElementStart(boolean empty)
          Implementation of processing of "end of start tag", triggered by element content or end of element.
 ContentHandler getContentHandler()
          Returns the current SAX content handler.
 ErrorHandler getErrorHandler()
          Returns the current SAX error handler.
 LexicalHandler getLexicalHandler()
          Returns the current SAX lexical handler.
 boolean getNsPrefixes()
          Gets the "NS prefixes" option: controls namespace prefix output.
 void putComment(String value)
          Puts a Comment event.
 void putDocumentEnd()
          Puts a Document End event.
 boolean putDocumentStart()
          Puts a Document Start event.
 void putElementEnd(QName name)
          Puts an Element End event.
 boolean putNamespace(String prefix, String namespaceURI)
          Puts a Namespace declaration event for the current element.
 void putProcessingInstruction(String target, String value)
          Puts a Processing-instruction event.
 void putText(String value)
          Puts a Text Fragment event.
 void setContentHandler(ContentHandler handler)
          Sets the current SAX content handler.
 void setErrorHandler(ErrorHandler handler)
          Sets the current SAX error handler.
 void setLexicalHandler(LexicalHandler handler)
          Sets the current SAX lexical output handler.
 void setNsPrefixes(boolean nsPrefixes)
          Sets the "NS prefixes" option: controls namespace prefix output.
 
Methods inherited from class com.qizx.xdm.XMLPushStreamBase
abort, checkCommentValue, checkNameMapping, checkPIValue, completeNameMappings, defineContextMappings, flush, isAtRoot, maxVolumeReached, noSpace, putAtom, putAtomText, putAttribute, putChars, putDTD, putElementStart, putLongAtom, putNamespaces, putNodeCopy, putNodeCopy, reset, resolvePrefix, setMaxVolume, setTrace
 
Methods inherited from class com.qizx.xdm.AttributeList
addAttribute, getAttributeCount, getIndex, getIndex, getIndex, getLength, getLocalName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getQName, getType, getType, getType, getURI, getValue, getValue, getValue, rawAddAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushStreamToSAX

public PushStreamToSAX()
Creates an adapter without handlers.

The SAX handlers must then be defined through the set*Handler methods.


PushStreamToSAX

public PushStreamToSAX(DefaultHandler handler)
Creates an SAX adapter directly bound to a SAX DefaultHandler.

Parameters:
handler - used as content handler and error handler.
Method Detail

getNsPrefixes

public boolean getNsPrefixes()
Gets the "NS prefixes" option: controls namespace prefix output.

Returns:
true if prefixes are output to SAX

setNsPrefixes

public void setNsPrefixes(boolean nsPrefixes)
Sets the "NS prefixes" option: controls namespace prefix output.

Parameters:
nsPrefixes - if false, do not output prefixes in SAX

getContentHandler

public ContentHandler getContentHandler()
Returns the current SAX content handler.

Returns:
the current SAX content handler

setContentHandler

public void setContentHandler(ContentHandler handler)
Sets the current SAX content handler.

Parameters:
handler - SAX content handler used as output (can be null)

getLexicalHandler

public LexicalHandler getLexicalHandler()
Returns the current SAX lexical handler.

Returns:
the current SAX lexical handler

setLexicalHandler

public void setLexicalHandler(LexicalHandler handler)
Sets the current SAX lexical output handler.

Parameters:
handler - SAX lexical handler used as output (can be null)

getErrorHandler

public ErrorHandler getErrorHandler()
Returns the current SAX error handler.

Returns:
the current SAX error handler

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Sets the current SAX error handler.

Parameters:
handler - SAX error handler used (can be null)

putDocumentStart

public boolean putDocumentStart()
                         throws DataModelException
Description copied from interface: XMLPushStream
Puts a Document Start event. This method should be called first if the result is meant to be a well-formed document. However it it possible to omit it (and putDocumentEnd) if the desired result is an element.

Throws:
DataModelException

putDocumentEnd

public void putDocumentEnd()
                    throws DataModelException
Description copied from interface: XMLPushStream
Puts a Document End event.

Throws:
DataModelException

flushElementStart

protected void flushElementStart(boolean empty)
                          throws DataModelException
Description copied from class: com.qizx.xdm.XMLPushStreamBase
Implementation of processing of "end of start tag", triggered by element content or end of element.

Output is normally delayed until this method is called.

Parameters:
empty - true if element has no contents (triggered by elementEnd)
Throws:
DataModelException

putElementEnd

public void putElementEnd(QName name)
                   throws DataModelException
Description copied from interface: XMLPushStream
Puts an Element End event. Should balance putElementStart exactly, else the result could be incorrect.

Throws:
DataModelException

putNamespace

public boolean putNamespace(String prefix,
                            String namespaceURI)
                     throws DataModelException
Description copied from interface: XMLPushStream
Puts a Namespace declaration event for the current element.

Must follow putElementStart and precede the contents of the element. The order is irrelevant. Duplicate namespace declarations are normally an error.

A Namespace declaration associates a prefix with a namespace-URI; it is equivalent to the xmlns: pseudo-attributes of XML markup. The empty prefix may be used for the default element namespace.

Note that such declarations are not mandatory: prefixes can be synthesized automatically by a XMLSerializer if missing.

Throws:
DataModelException

putText

public void putText(String value)
             throws DataModelException
Description copied from interface: XMLPushStream
Puts a Text Fragment event.

A text fragment should appear inside an element. Consecutive text events are coalesced into one. An empty text fragment is discarded.

Parameters:
value - a fragment of text
Throws:
DataModelException - reasons

putProcessingInstruction

public void putProcessingInstruction(String target,
                                     String value)
                              throws DataModelException
Description copied from interface: XMLPushStream
Puts a Processing-instruction event.

Throws:
DataModelException

putComment

public void putComment(String value)
                throws DataModelException
Description copied from interface: XMLPushStream
Puts a Comment event.

Throws:
DataModelException

© 2008 Axyana Software