nu.xom.samples
Class NonRecursiveSerializer

java.lang.Object
  extended by nu.xom.Serializer
      extended by nu.xom.samples.NonRecursiveSerializer

public final class NonRecursiveSerializer
extends nu.xom.Serializer

Demonstrates a serializer which, unlike nu.xom.Serializer, is not limited by the Java stack size and can process arbitrarily deep documents.

Version:
1.0
Author:
Elliotte Rusty Harold

Constructor Summary
NonRecursiveSerializer(java.io.OutputStream out)
           
NonRecursiveSerializer(java.io.OutputStream out, java.lang.String encoding)
           
 
Method Summary
static void main(java.lang.String[] args)
           
protected  void write(nu.xom.Element element)
           Serializes an element onto the output stream using the current options.
 
Methods inherited from class nu.xom.Serializer
breakLine, flush, getColumnNumber, getEncoding, getIndent, getLineSeparator, getMaxLength, getPreserveBaseURI, getUnicodeNormalizationFormC, setIndent, setLineSeparator, setMaxLength, setOutputStream, setPreserveBaseURI, setUnicodeNormalizationFormC, write, write, write, write, write, write, writeAttributes, writeAttributeValue, writeChild, writeEmptyElementTag, writeEndTag, writeEscaped, writeNamespaceDeclaration, writeNamespaceDeclarations, writeRaw, writeStartTag, writeXMLDeclaration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonRecursiveSerializer

public NonRecursiveSerializer(java.io.OutputStream out)

NonRecursiveSerializer

public NonRecursiveSerializer(java.io.OutputStream out,
                              java.lang.String encoding)
                       throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException
Method Detail

write

protected final void write(nu.xom.Element element)
                    throws java.io.IOException
Description copied from class: nu.xom.Serializer

Serializes an element onto the output stream using the current options. The result is guaranteed to be well-formed. If element does not have a parent element, the output will also be namespace well-formed.

If the element is empty, this method invokes writeEmptyElementTag. If the element is not empty, then:

  1. It calls writeStartTag.
  2. It passes each of the element's children to writeChild in order.
  3. It calls writeEndTag.

It may break lines or add white space if the serializer has been configured to indent or use a maximum line length.

Overrides:
write in class nu.xom.Serializer
Parameters:
element - the Element to serialize
Throws:
java.io.IOException - if the underlying output stream encounters an I/O error

main

public static void main(java.lang.String[] args)


Copyright 2002-2005 Elliotte Rusty Harold
elharo@metalab.unc.edu