J avolution v3.7 (J2SE 1.5+)

javolution.xml
Class XmlOutputStream<T>

java.lang.Object
  extended by java.io.OutputStream
      extended by javolution.xml.XmlOutputStream<T>
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, Reusable

public class XmlOutputStream<T>
extends java.io.OutputStream
implements Reusable

This class represents an object output stream using ObjectWriter for object serialization.

Instances of this class embed their own data buffer, wrapping using a java.io.BufferedOutputStream is therefore unnescessary.

Version:
2.2, January 8, 2005
Author:
Jean-Marie Dautelle
See Also:
XmlInputStream

Constructor Summary
XmlOutputStream()
          Default constructor.
XmlOutputStream(ObjectWriter<T> writer)
          Creates a xml output stream using the specified object writer.
 
Method Summary
 void close()
          Closes and resets this stream for reuse.
 void flush()
          Flushes this output stream and forces any buffered output bytes to be written out.
 void reset()
          Resets the internal state of this object to its default values.
 XmlOutputStream setOutputStream(java.io.OutputStream out)
          Sets the underlying output destination for this stream.
 void write(byte[] b, int off, int len)
          Writes the specified number of bytes from the specified byte array starting at the specified offset to this output stream.
 void write(int b)
          Writes the specified byte to this output stream
 void writeObject(T obj)
          Writes an object to the underlying stream using an ObjectWriter.
 
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

XmlOutputStream

public XmlOutputStream()
Default constructor.


XmlOutputStream

public XmlOutputStream(ObjectWriter<T> writer)
Creates a xml output stream using the specified object writer.

Parameters:
writer - the object writer.
Method Detail

setOutputStream

public XmlOutputStream setOutputStream(java.io.OutputStream out)
Sets the underlying output destination for this stream.

Parameters:
out - the output destination.
Returns:
this
Throws:
java.lang.IllegalStateException - if this stream is being reused and it has not been closed or reset.

writeObject

public void writeObject(T obj)
                 throws java.io.IOException
Writes an object to the underlying stream using an ObjectWriter.

Parameters:
obj - the object writen using its xml representation.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to this output stream

Specified by:
write in class java.io.OutputStream
Parameters:
b - the byte.
Throws:
java.io.IOException - if an I/O error occurs.

flush

public void flush()
           throws java.io.IOException
Flushes this output stream and forces any buffered output bytes to be written out.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes the specified number of bytes from the specified byte array starting at the specified offset to this output stream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs.

close

public void close()
           throws java.io.IOException
Closes and resets this stream for reuse.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - if an I/O error occurs.

reset

public void reset()
Description copied from interface: Reusable
Resets the internal state of this object to its default values.

Specified by:
reset in interface Reusable

J avolution v3.7 (J2SE 1.5+)

Copyright © 2006 Javolution.