org.glassfish.jersey.message.internal
Class CommittingOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.glassfish.jersey.message.internal.CommittingOutputStream
All Implemented Interfaces:
Closeable, Flushable

public final class CommittingOutputStream
extends OutputStream

An abstract committing output stream adapter that performs a commit and then retrieves the provided output stream before the first byte is written to the provided stream. Concrete implementations of the class typically override the commit operation to perform any initialization on the adapted output stream.

Author:
Paul Sandoz, Marek Potociar (marek.potociar at oracle.com)

Constructor Summary
CommittingOutputStream()
          Construct a new committing output stream using a deferred initialization of the adapted output stream via stream provider.
 
Method Summary
 void close()
           
 void flush()
           
 boolean isCommitted()
          Determines whether the stream was already committed or not.
 void setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
          Set the output stream provider.
 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 committing output stream using a deferred initialization of the adapted output stream via stream provider.

Method Detail

setStreamProvider

public void setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
Set the output stream provider.

Parameters:
streamProvider - output stream provider.

isCommitted

public boolean isCommitted()
Determines whether the stream was already committed or not.

Returns:
true if this stream was already committed, false otherwise.

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


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.