com.android.sdklib.io
Class NonClosingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.android.sdklib.io.NonClosingInputStream
All Implemented Interfaces:
java.io.Closeable

public class NonClosingInputStream
extends java.io.FilterInputStream

Wraps an InputStream to change its closing behavior: this makes it possible to ignore close operations or have them perform a InputStream.reset() instead (if supported by the underlying stream) or plain ignored.


Nested Class Summary
static class NonClosingInputStream.CloseBehavior
           
 
Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
NonClosingInputStream(java.io.InputStream in)
          Wraps an existing stream into this filtering stream.
 
Method Summary
 void close()
          Performs the requested close() operation, depending on the current NonClosingInputStream.CloseBehavior.
 NonClosingInputStream.CloseBehavior getCloseBehavior()
          Returns the current NonClosingInputStream.CloseBehavior.
 NonClosingInputStream setCloseBehavior(NonClosingInputStream.CloseBehavior closeBehavior)
          Changes the current NonClosingInputStream.CloseBehavior.
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonClosingInputStream

public NonClosingInputStream(@NonNull
                             java.io.InputStream in)
Wraps an existing stream into this filtering stream.

Parameters:
in - A non-null input stream.
Method Detail

getCloseBehavior

@NonNull
public NonClosingInputStream.CloseBehavior getCloseBehavior()
Returns the current NonClosingInputStream.CloseBehavior.

Returns:
the current NonClosingInputStream.CloseBehavior. Never null.

setCloseBehavior

public NonClosingInputStream setCloseBehavior(@NonNull
                                              NonClosingInputStream.CloseBehavior closeBehavior)
Changes the current NonClosingInputStream.CloseBehavior.

Parameters:
closeBehavior - A new non-null NonClosingInputStream.CloseBehavior.
Returns:
Self for chaining.

close

public void close()
           throws java.io.IOException
Performs the requested close() operation, depending on the current NonClosingInputStream.CloseBehavior.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterInputStream
Throws:
java.io.IOException