com.sun.jersey.api.client
Class CommittingOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.sun.jersey.api.client.CommittingOutputStream
All Implemented Interfaces:
Closeable, Flushable

public abstract class CommittingOutputStream
extends OutputStream

A commiting output stream that commits before the first byte is written to the adapted OutputStream.

This class may be overridden to provide the commit functionality.

Author:
Paul.Sandoz@Sun.Com

Constructor Summary
CommittingOutputStream()
          Construct a new instance.
CommittingOutputStream(OutputStream o)
          Construct a new instance with an output stream to adapt.
 
Method Summary
 void close()
           
protected abstract  void commit()
          Perform the commit functionality.
 void flush()
           
protected  OutputStream getOutputStream()
          Get the adapted output stream.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommittingOutputStream

public CommittingOutputStream()
Construct a new instance.

The method getOutputStream() MUST be overridden to return an output stream.


CommittingOutputStream

public CommittingOutputStream(OutputStream o)
Construct a new instance with an output stream to adapt.

Parameters:
o - the adapted output stream.
Throws:
IllegalArgumentException - if o is null.
Method Detail

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

getOutputStream

protected OutputStream getOutputStream()
                                throws IOException
Get the adapted output stream.

This method MUST be overriden if the empty constructor is utilized to construct an instance of this class.

Returns:
the adapted output stream.
Throws:
IOException

commit

protected abstract void commit()
                        throws IOException
Perform the commit functionality.

Throws:
IOException


Copyright © 2013 Oracle Corporation. All Rights Reserved.