com.gc.iotools.stream.reader
Class CloseShieldReader<T extends Reader>

java.lang.Object
  extended by java.io.Reader
      extended by java.io.FilterReader
          extended by com.gc.iotools.stream.reader.CloseShieldReader<T>
Type Parameters:
T - Type of the Reader passed in the constructor.
All Implemented Interfaces:
Closeable, Readable

public class CloseShieldReader<T extends Reader>
extends FilterReader

A CloseShieldReader wraps some other Reader, which it uses as its basic source of data. The class CloseShieldReader pass all requests to the contained stream, except the close() method that is not to the underlying stream.

This class is typically used in cases where a Reader needs to be passed to a component that wants to explicitly close the stream even if more input would still be available to other components.

Since:
1.2.8
Version:
$Id: CloseShieldReader.java 529 2014-02-26 20:52:01Z gabriele.contini@gmail.com $
Author:
dvd.smnt

Field Summary
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
CloseShieldReader(T source)
          Construct a CloseShieldReader that forwards the calls to the source Reader passed in the constructor.
 
Method Summary
 void close()
          
 int getCloseCount()
          Returns the number of time that close was called.
 T getWrappedReader()
           Returns the wrapped (original) Reader passed in the constructor.
 
Methods inherited from class java.io.FilterReader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CloseShieldReader

public CloseShieldReader(T source)
Construct a CloseShieldReader that forwards the calls to the source Reader passed in the constructor.

Type Parameters:
T - a T object.
Parameters:
source - original Reader
Method Detail

close

public void close()
           throws IOException

Multiple invocation of this method will result in only one invocation of the close() on the underlying stream.

Specified by:
close in interface Closeable
Overrides:
close in class FilterReader
Throws:
IOException

getCloseCount

public int getCloseCount()
Returns the number of time that close was called.

Returns:
Number of times that close was called

getWrappedReader

public T getWrappedReader()

Returns the wrapped (original) Reader passed in the constructor.

Returns:
The original Reader passed in the constructor


Copyright © 2008–2014. All rights reserved.