TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.io
Class SynchronizedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by de.schlichtherle.truezip.io.DecoratingInputStream
          extended by de.schlichtherle.truezip.io.SynchronizedInputStream
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
ConcurrentInputShop.SynchronizedConcurrentInputStream

public class SynchronizedInputStream
extends DecoratingInputStream

A decorator which synchronizes all access to an InputStream via an object provided to its constructor.

Author:
Christian Schlichtherle
See Also:
SynchronizedOutputStream

Field Summary
protected  Object lock
          The object to synchronize on - never null.
 
Fields inherited from class de.schlichtherle.truezip.io.DecoratingInputStream
delegate
 
Constructor Summary
SynchronizedInputStream(InputStream in)
          Constructs a new synchronized input stream.
SynchronizedInputStream(InputStream in, Object lock)
          Constructs a new synchronized input stream.
 
Method Summary
 int available()
           
 void close()
           
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class de.schlichtherle.truezip.io.DecoratingInputStream
read, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lock

protected final Object lock
The object to synchronize on - never null.

Constructor Detail

SynchronizedInputStream

public SynchronizedInputStream(InputStream in)
Constructs a new synchronized input stream. This object will synchronize on itself.

Parameters:
in - the input stream to wrap in this decorator.

SynchronizedInputStream

public SynchronizedInputStream(InputStream in,
                               Object lock)
Constructs a new synchronized input stream.

Parameters:
in - the input stream to wrap in this decorator.
lock - the object to synchronize on. If null, then this object is used, not the stream.
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class DecoratingInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class DecoratingInputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class DecoratingInputStream
Throws:
IOException

available

public int available()
              throws IOException
Overrides:
available in class DecoratingInputStream
Throws:
IOException

close

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

mark

public void mark(int readlimit)
Overrides:
mark in class DecoratingInputStream

reset

public void reset()
           throws IOException
Overrides:
reset in class DecoratingInputStream
Throws:
IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class DecoratingInputStream

TrueZIP Kernel 7.0-rc2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.