org.backsource.utils.io
Class DOMOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.PipedOutputStream
          extended byorg.backsource.utils.io.DOMOutputStream

public class DOMOutputStream
extends java.io.PipedOutputStream

Write to a DOM Document.

Much like a FileOutputStream writes the stream to a File this class writes the stream directly to a DOM tree. This is however done with the use of two threads; so this class should probably not be used in EJB:s. When the writing is finished it is possible to get the Document with getDocument().

Version:
$Revision: 1.1.1.1 $
Author:
Peter Antman

Constructor Summary
DOMOutputStream()
           
 
Method Summary
 void close()
          Close the stream.
 org.w3c.dom.Document getDocument()
          Get the document written to, if the stream was not closed before this methods was called it will be closed by it.
protected  void startDOMReader()
          Start the DOM reader thread.
 void write(byte[] b, int off, int len)
          Write to the DOM tree, if its the first write start the DOM reader.
 void write(int b)
          Write to the DOM tree, if its the first write start the DOM reader.
 
Methods inherited from class java.io.PipedOutputStream
connect, flush
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMOutputStream

public DOMOutputStream()
Method Detail

write

public void write(int b)
           throws java.io.IOException
Write to the DOM tree, if its the first write start the DOM reader.

Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Write to the DOM tree, if its the first write start the DOM reader.

Throws:
java.io.IOException

startDOMReader

protected void startDOMReader()
                       throws java.io.IOException
Start the DOM reader thread.

Throws:
java.io.IOException

getDocument

public org.w3c.dom.Document getDocument()
                                 throws java.io.IOException
Get the document written to, if the stream was not closed before this methods was called it will be closed by it.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Close the stream.

The stream will be flushed and the wait for the DOM reader to finish. Any exceptions thrown in the reader thread will also be reported.

Throws:
java.io.IOException


Copyright © 2000-2004 Backsource. All Rights Reserved.