org.enhydra.xml.io
Class DOMFormatter

java.lang.Object
  |
  +--org.enhydra.xml.io.DOMFormatter

public class DOMFormatter
extends Object

Class for formatting DOMs into a documents. The class handles XML and HTML pages, looking up the approriate formatting routines based on the document type. It has an associated OutputOptions object that controls the formatting. Instances are reusable and multithreaded.


Constructor Summary
DOMFormatter()
          Construct a new XML formatter with default output options.
DOMFormatter(OutputOptions outputOptions)
          Construct a new XML formatter with the specified output options.
 
Method Summary
static OutputOptions getDefaultOutputOptions(Document doc)
          Get the default OutputOptions for a document.
static Formatter getFormatter(Node node, OutputOptions outputOptions, boolean forPreFormatting)
           
 OutputOptions getOutputOptions()
          Get the output options.
 void setOutputOptions(OutputOptions outputOptions)
          Set the output options.
 byte[] toBytes(Node node)
          Format a document or any node and its children into a byte array using the current encoding.
 String toString(Node node)
          Format a document or any node and its children into a string.
 void write(Node node, File out)
          Output a document or any node and its children to a File.
 void write(Node node, OutputStream out)
          Output a document or any node and its children to a OutputStream.
 void write(Node node, Writer writer)
          Output a document or any node and its children to a Writer.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMFormatter

public DOMFormatter(OutputOptions outputOptions)
Construct a new XML formatter with the specified output options.
Parameters:
outputOptions - The OutputOptions to use for formatters obtained from this object.

DOMFormatter

public DOMFormatter()
Construct a new XML formatter with default output options.
Method Detail

getOutputOptions

public OutputOptions getOutputOptions()
Get the output options.

setOutputOptions

public void setOutputOptions(OutputOptions outputOptions)
Set the output options.

getDefaultOutputOptions

public static OutputOptions getDefaultOutputOptions(Document doc)
Get the default OutputOptions for a document. The encoding will not be set, which signals to use the default encoding.

getFormatter

public static Formatter getFormatter(Node node,
                                     OutputOptions outputOptions,
                                     boolean forPreFormatting)

toString

public String toString(Node node)
Format a document or any node and its children into a string.

toBytes

public byte[] toBytes(Node node)
               throws IOException
Format a document or any node and its children into a byte array using the current encoding.

write

public void write(Node node,
                  Writer writer)
           throws IOException
Output a document or any node and its children to a Writer.

write

public void write(Node node,
                  OutputStream out)
           throws IOException
Output a document or any node and its children to a OutputStream.

write

public void write(Node node,
                  File out)
           throws IOException
Output a document or any node and its children to a File.


Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.