LT - the type of the local target
for I/O operations.PT - the type of the peer target
for I/O operations.@ThreadSafe
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public abstract class IOSocket<LT,PT>
extends java.lang.Object
local target.
I/O sockets can be used to copy
data easily and very fast.
When copying data, the local target gets connected to a
peer target.
Once connected, the sockets can then setup the data to be transferred by
the copy method.
This feature enables to avoid data recompression when copying a compressed
archive entry to another archive entry of the same type.| Constructor and Description |
|---|
IOSocket()
You cannot instantiate this class outside its package.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(InputSocket<?> input,
OutputSocket<?> output)
|
boolean |
equals(java.lang.Object that)
Two sockets are considered equal if and only if they are identical.
|
abstract LT |
getLocalTarget()
Returns the local target for I/O operations.
|
abstract PT |
getPeerTarget()
Returns the peer target for I/O operations.
|
int |
hashCode()
Returns a hash code which is consistent with
equals(java.lang.Object). |
java.lang.String |
toString()
Returns a string representing a connection of the local and peer
targets.
|
public abstract LT getLocalTarget() throws java.io.IOException
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.
java.io.IOException@CheckForNull public abstract PT getPeerTarget() throws java.io.IOException
The same considerations as for getLocalTarget() apply here, too.
java.io.IOExceptionpublic static void copy(InputSocket<?> input, OutputSocket<?> output) throws java.io.IOException
created
by the given input socket input to an output stream
created by the given output socket
output.
This is a high performance implementation which uses a pooled background thread to fill a FIFO of pooled buffers which is concurrently flushed by the current thread.
input - an input socket for the input target.output - an output socket for the output target.InputException - if copying the data fails because of an
IOException thrown by the input stream.java.io.IOException - if copying the data fails because of an
IOException thrown by the output stream.public java.lang.String toString()
toString in class java.lang.Objectpublic final boolean equals(@CheckForNull
java.lang.Object that)
equals in class java.lang.Objectpublic final int hashCode()
equals(java.lang.Object).
This can't get overriden.hashCode in class java.lang.ObjectCopyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.