TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.socket
Class DecoratingInputSocket<E extends Entry>

java.lang.Object
  extended by de.schlichtherle.truezip.socket.IOSocket<E,Entry>
      extended by de.schlichtherle.truezip.socket.InputSocket<E>
          extended by de.schlichtherle.truezip.socket.DecoratingInputSocket<E>
Type Parameters:
E - The type of the local target.
Direct Known Subclasses:
FsCachingController.EntryCache.ProxyInputSocket, FsCachingController.Input, FsConcurrentController.Input, FsFederatingController.Input, FsStatisticsController.Input, IOCache.Buffer.BufferInputSocket, LazyInputSocket

public abstract class DecoratingInputSocket<E extends Entry>
extends InputSocket<E>

An abstract decorator for an input socket.

Author:
Christian Schlichtherle
See Also:
DecoratingOutputSocket

Field Summary
private  InputSocket<? extends E> delegate
           
 
Constructor Summary
protected DecoratingInputSocket(InputSocket<? extends E> input)
           
 
Method Summary
protected  InputSocket<? extends E> getBoundSocket()
          Binds the decorated socket to this socket and returns it.
 E getLocalTarget()
          Returns the local target for I/O operations.
 Entry getPeerTarget()
          Returns the peer target for I/O operations.
 InputStream newInputStream()
          Returns a new input stream for reading bytes from the local target.
 ReadOnlyFile newReadOnlyFile()
          Optional: Returns a new read only file for reading bytes from the local target in arbitrary order.
 String toString()
          Returns a string representation of this object for debugging and logging purposes.
 
Methods inherited from class de.schlichtherle.truezip.socket.InputSocket
bind, connect
 
Methods inherited from class de.schlichtherle.truezip.socket.IOSocket
copy, equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

delegate

private final InputSocket<? extends E extends Entry> delegate
Constructor Detail

DecoratingInputSocket

protected DecoratingInputSocket(InputSocket<? extends E> input)
Method Detail

getBoundSocket

protected InputSocket<? extends E> getBoundSocket()
                                                         throws IOException
Binds the decorated socket to this socket and returns it.

Returns:
The bound decorated socket.
Throws:
IOException

getLocalTarget

public E getLocalTarget()
                               throws IOException
Description copied from class: IOSocket
Returns the local target for I/O operations.

Note that this interface contract does not state any other terms or conditions for the returned object. In particular, clients need to consider that multiple invocations of this method could return different objects (e.g. defensive copies) which may even fail the Object.equals(java.lang.Object) test. On the other hand, implementations need to consider that clients could attempt to change the state of the returned object in arbitrary manner. Consequently, the result of doing so is undefined, too. In particular, a subsequent I/O operation may not reflect the change or may even fail. Sub-interfaces or implementations may add additional terms and conditions in order to resolve these potential issues.

Specified by:
getLocalTarget in class IOSocket<E extends Entry,Entry>
Returns:
The local target for I/O operations.
Throws:
IOException

getPeerTarget

public Entry getPeerTarget()
                    throws IOException
Description copied from class: InputSocket
Returns the peer target for I/O operations.

The same considerations as for IOSocket.getLocalTarget() apply here, too.

The peer target is null if and only if this socket is not InputSocket.connect(de.schlichtherle.truezip.socket.OutputSocket)ed to another socket.

Overrides:
getPeerTarget in class InputSocket<E extends Entry>
Returns:
The peer target for I/O operations.
Throws:
IOException

newReadOnlyFile

public ReadOnlyFile newReadOnlyFile()
                             throws IOException
Description copied from class: InputSocket
Optional: Returns a new read only file for reading bytes from the local target in arbitrary order.

If this method is supported, implementations must enable calling it any number of times. Furthermore, the returned read only file should not be buffered. Buffering should be addressed by client applications instead.

Specified by:
newReadOnlyFile in class InputSocket<E extends Entry>
Returns:
A new read only file.
Throws:
FileNotFoundException - if the local target does not exist or is not accessible for some reason.
IOException - on any other exceptional condition.

newInputStream

public InputStream newInputStream()
                           throws IOException
Description copied from class: InputSocket
Returns a new input stream for reading bytes from the local target.

Implementations must enable calling this method any number of times. Furthermore, the returned input stream should not be buffered. Buffering should be addressed by the caller instead - see IOSocket.copy(de.schlichtherle.truezip.socket.InputSocket, de.schlichtherle.truezip.socket.OutputSocket).

The implementation in the class InputSocket calls InputSocket.newReadOnlyFile() and wraps the resulting object in a new ReadOnlyFileInputStream as an adapter.

Overrides:
newInputStream in class InputSocket<E extends Entry>
Returns:
A new input stream.
Throws:
FileNotFoundException - if the local target does not exist or is not accessible for some reason.
IOException - on any other exceptional condition.

toString

public String toString()
Returns a string representation of this object for debugging and logging purposes.

Overrides:
toString in class IOSocket<E extends Entry,Entry>

TrueZIP Kernel 7.0-rc2

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