Qizx fe-4.4p2 API

com.qizx.api.util
Class PushStreamToSAX

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

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 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
 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, defineContextMappings, flush, getNSPrefix, getNSURI, isAtRoot, maxVolumeReached, noSpace, putAtom, putAtomText, putAttribute, putChars, putDTD, putElementStart, putLongAtom, putNamespaces, putNodeCopy, putNodeCopy, putNodeText, reset, setCheckNS, 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
 
Methods inherited from class java.lang.Object
equals, 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.

Specified by:
putDocumentStart in interface XMLPushStream
Overrides:
putDocumentStart in class com.qizx.xdm.XMLPushStreamBase
Returns:
false if the current stream position is already inside a node (this event is then ignored)
Throws:
DataModelException - reasons

putDocumentEnd

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

Specified by:
putDocumentEnd in interface XMLPushStream
Overrides:
putDocumentEnd in class com.qizx.xdm.XMLPushStreamBase
Throws:
DataModelException - reasons

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.

Specified by:
putElementEnd in interface XMLPushStream
Overrides:
putElementEnd in class com.qizx.xdm.XMLPushStreamBase
Parameters:
name - qualified name of the element
Throws:
DataModelException - reasons

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.

Specified by:
putNamespace in interface XMLPushStream
Overrides:
putNamespace in class com.qizx.xdm.XMLPushStreamBase
Parameters:
prefix - prefix of the namespace, can be the empty string, but not null
namespaceURI - URI of the namespace: may not be null. The empty string means that the namespace-URI associated with the current prefix is erased (a XML 1.1 feature)
Returns:
false if the declaration was redundant
Throws:
DataModelException - reasons

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.

Specified by:
putProcessingInstruction in interface XMLPushStream
Overrides:
putProcessingInstruction in class com.qizx.xdm.XMLPushStreamBase
Parameters:
target - target (name) of the PI
value - contents of the PI
Throws:
DataModelException - reasons

putComment

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

Specified by:
putComment in interface XMLPushStream
Overrides:
putComment in class com.qizx.xdm.XMLPushStreamBase
Parameters:
value - contents of a comment.
Throws:
DataModelException - reasons

© 2010 Axyana Software