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:
java.io.Closeable, java.io.Flushable

public abstract class CommittingOutputStream
extends java.io.OutputStream

A committing 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

Constructor Summary
CommittingOutputStream()
          Construct a new instance.
CommittingOutputStream(java.io.OutputStream adaptedOutput)
          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  java.io.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(java.io.OutputStream adaptedOutput)
Construct a new instance with an output stream to adapt.

Parameters:
adaptedOutput - the adapted output stream.
Throws:
java.lang.IllegalArgumentException - if adaptedOutput is null.
Method Detail

write

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

write

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

write

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

flush

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

close

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

getOutputStream

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

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

Returns:
the adapted output stream.
Throws:
java.io.IOException - if obtaining of an output stream fails (e.g. connection problem).

commit

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

Throws:
java.io.IOException


Copyright © 2013 Oracle Corporation. All Rights Reserved.