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 Object
A key feature of an I/O socket is that it's targets can be resolved lazily, i.e. the local or peer target may get resolved by a method of a sub class.
| 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(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 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@CheckForNull public abstract PT getPeerTarget() throws IOException
The same considerations as for getLocalTarget() apply here, too.
IOExceptionpublic 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 stream.IOException - if copying the data fails because of an
IOException thrown by the output stream.public String toString()
public final boolean equals(@CheckForNull
Object that)
public final int hashCode()
equals(java.lang.Object).
This can't get overriden.Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.