Qizx/Open v0.3

net.xfra.qizxopen.dm
Class XMLSerializer

java.lang.Object
  |
  +--net.xfra.qizxopen.dm.XMLEventReceiverBase
        |
        +--net.xfra.qizxopen.dm.XMLSerializer
All Implemented Interfaces:
XMLEventReceiver
Direct Known Subclasses:
HTMLSerializer

public class XMLSerializer
extends XMLEventReceiverBase

Serializes a DataModel Node and its subtree to an output stream.


Constructor Summary
XMLSerializer()
          Constructs a XMLSerializer with default XML output method.
XMLSerializer(java.lang.String method)
          Constructs a XMLSerializer with specification of an output method.
XMLSerializer(java.io.Writer output)
          Constructs a XMLSerializer with an output writer.
 
Method Summary
 void atom(java.lang.String value)
          Emits the text of an atom.
 void comment(java.lang.String value)
          Emits a comment.
 void endDocument()
          Ends a document.
 void endElement(QName name)
          Ends an element.
 void flushElement(boolean empty)
           
 java.lang.String getEncoding()
           
 java.io.PrintWriter getOutput()
          Gets the current output writer.
 void output(Node node)
          Serializes a node and its subtree.
 void pi(java.lang.String target, java.lang.String value)
          Emits a processing-instruction.
 void reset()
          Resets the state prior to use startDocument() or startElement().
 void setDepth(int maxDepth)
          Extension: defines a maximum tree depth.
 void setIndent(int indent)
           
 void setOption(java.lang.String option, java.lang.String value)
          Sets an option.
 void setOutput(java.io.OutputStream output, java.lang.String encoding)
          Defines or redefines the output.
 void setOutput(java.io.Writer output)
          Defines or redefines the output.
 void startDocument()
          Starts a document.
 void terminate()
          Terminates a document or simple subtree.
 void text(java.lang.String value)
          Emits a text chunk.
 void traverse(Node node)
          Lower-level output method.
 
Methods inherited from class net.xfra.qizxopen.dm.XMLEventReceiverBase
attribute, definePrefixHints, maxVolumeReached, namespace, resolvePrefix, setMaxVolume, setTrace, startElement, traverse
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLSerializer

public XMLSerializer()
Constructs a XMLSerializer with default XML output method.


XMLSerializer

public XMLSerializer(java.lang.String method)
              throws DataModelException
Constructs a XMLSerializer with specification of an output method.

Parameters:
method - output method name (case-insensitive): XML, XHTML, HTML, or TEXT.
Throws:
DataModelException - when the method name is invalid.

XMLSerializer

public XMLSerializer(java.io.Writer output)
Constructs a XMLSerializer with an output writer.

Method Detail

output

public void output(Node node)
            throws DataModelException
Serializes a node and its subtree.

Parameters:
node - node to serialize. If it is not a document, the XML header is not generated.
DataModelException

setOutput

public void setOutput(java.io.OutputStream output,
                      java.lang.String encoding)
Defines or redefines the output.


traverse

public void traverse(Node node)
              throws DataModelException
Lower-level output method. Must be preceded by reset(), and optionally startDocument().

DataModelException

setOutput

public void setOutput(java.io.Writer output)
Defines or redefines the output.


getOutput

public java.io.PrintWriter getOutput()
Gets the current output writer.


setOption

public void setOption(java.lang.String option,
                      java.lang.String value)
               throws DataModelException
Sets an option.

Supported options (see setOption):


setDepth

public void setDepth(int maxDepth)
Extension: defines a maximum tree depth. Subtrees deeper than this value appear as an ellipsis '...'.


setIndent

public void setIndent(int indent)

getEncoding

public java.lang.String getEncoding()

reset

public void reset()
Description copied from interface: XMLEventReceiver
Resets the state prior to use startDocument() or startElement().

Specified by:
reset in interface XMLEventReceiver
Overrides:
reset in class XMLEventReceiverBase

terminate

public void terminate()
               throws DataModelException
Description copied from interface: XMLEventReceiver
Terminates a document or simple subtree. May perform consistency checks.

Specified by:
terminate in interface XMLEventReceiver
Overrides:
terminate in class XMLEventReceiverBase
DataModelException

startDocument

public void startDocument()
                   throws DataModelException
Description copied from interface: XMLEventReceiver
Starts a document.

It is not necessarily called, if only a fragment is generated.

Specified by:
startDocument in interface XMLEventReceiver
Overrides:
startDocument in class XMLEventReceiverBase
DataModelException

endDocument

public void endDocument()
                 throws DataModelException
Description copied from interface: XMLEventReceiver
Ends a document. Must be balanced by a corresponding startDocument().

Specified by:
endDocument in interface XMLEventReceiver
Overrides:
endDocument in class XMLEventReceiverBase
DataModelException

flushElement

public void flushElement(boolean empty)
Overrides:
flushElement in class XMLEventReceiverBase

endElement

public void endElement(QName name)
                throws DataModelException
Description copied from interface: XMLEventReceiver
Ends an element. Removes NS mappings.

Specified by:
endElement in interface XMLEventReceiver
Overrides:
endElement in class XMLEventReceiverBase
DataModelException

text

public void text(java.lang.String value)
Description copied from interface: XMLEventReceiver
Emits a text chunk. No space before or after.


atom

public void atom(java.lang.String value)
Description copied from interface: XMLEventReceiver
Emits the text of an atom. The difference with text() is that a space in requested between two atoms.


pi

public void pi(java.lang.String target,
               java.lang.String value)
Description copied from interface: XMLEventReceiver
Emits a processing-instruction.


comment

public void comment(java.lang.String value)
Description copied from interface: XMLEventReceiver
Emits a comment.


 Copyright Xavier FRANC 2003-2004