LT
- the type of the local target
for I/O operations.PT
- the type of the peer target
for I/O operations.@ThreadSafe public abstract class IOSocket<LT,PT> extends Object
local target
.
I/O sockets are designed to copy
data fast and easily.
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.
For example, this feature can get used to avoid data recompression when
copying a compressed archive entry to another archive entry of the same
type.Modifier and Type | Method and Description |
---|---|
static void |
copy(InputSocket<?> input,
OutputSocket<?> output)
|
boolean |
equals(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) . |
String |
toString()
Returns a string representing a connection of the local and peer
targets.
|
public static void copy(InputSocket<?> input, OutputSocket<?> output) throws 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 socket.IOException
- if copying the data fails because of an
IOException
thrown by the output socket.public final boolean equals(@CheckForNull Object that)
public abstract LT getLocalTarget() throws 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.
IOException
- On any I/O failure.@CheckForNull public abstract PT getPeerTarget() throws IOException
The same considerations as for getLocalTarget()
apply here, too.
IOException
- On any I/O failure.public final int hashCode()
equals(java.lang.Object)
.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.