|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.netseeker.ejoe.io.IOUtils
Some useful methods for closing io streams, io readers, channels and Selector quitely, as well as methods for non-blocking, semi-blocking and full blocking io read/write operations.
Field Summary | |
static int |
NIO_MAX_ITERATIONS
|
Constructor Summary | |
IOUtils()
|
Method Summary | |
static java.lang.Object |
adapterDeserialize(SerializeAdapter adapter,
java.io.InputStream in,
boolean compressed)
Invokes a (De)SerializeAdapter for the given Object and handles decompression and buffering |
static void |
adapterSerialize(SerializeAdapter adapter,
java.io.OutputStream out,
java.lang.Object obj,
boolean compressed,
int compressionLevel)
Invokes a SerializeAdapter for the given Object and handles compression and buffering |
static void |
closeQuite(java.nio.channels.Channel channel)
Tries to close an NIO Channel and handles null values and IOExceptions quietly |
static void |
closeQuite(java.io.InputStream in)
Tries to close an InputStream and handles null values and IOExceptions quietly |
static void |
closeQuite(java.io.OutputStream out)
Tries to close an OutputStream and handles null values and IOExceptions quietly |
static void |
closeQuite(java.io.Reader reader)
Tries to close a Reader and handles null values and IOExceptions quietly |
static void |
closeQuite(java.nio.channels.Selector selector)
Tries to close a NIO Selector and handles null values and IOExceptions quietly |
static void |
closeQuite(java.io.Writer out)
Tries to close a Writer and handles null values and IOExceptions quietly |
static ConnectionHeader |
handshake(java.nio.channels.SocketChannel channel,
ConnectionHeader header,
boolean sendBeforeReceive,
long timeout)
Handshake for a socket channel. |
static java.nio.ByteBuffer |
nonBlockingRead(java.nio.channels.ReadableByteChannel channel,
java.nio.ByteBuffer buffer)
Tries to send the given ByteBuffer completely through the given SocketChannel within a given timeout |
static void |
nonBlockingWrite(java.nio.channels.WritableByteChannel channel,
java.nio.ByteBuffer buffer)
Tries to send the given ByteBuffer completely through the given SocketChannel three times |
static int |
readHeader(ConnectionHeader header)
Receives a EJOE specific header containing the size of the next ByteBuffer. |
static java.nio.ByteBuffer |
semiBlockingRead(java.nio.channels.ReadableByteChannel channel,
java.nio.ByteBuffer buffer,
long timeout)
Tries to read ByteBuffer.remaining() bytes the into given ByteBuffer from the given SocketChannel within a given timeout |
static void |
semiBlockingWrite(java.nio.channels.WritableByteChannel channel,
java.nio.ByteBuffer buffer,
long timeout)
Tries to send the given ByteBuffer completely through the given SocketChannel within a given timeout |
static void |
setReceiveBufferSize(java.net.Socket socket,
int size)
Set the SO_RCVBUF hint on a connected socket to the size of the data which are expected to be read next time |
static void |
setSendBufferSize(java.net.Socket socket,
int size)
Set the SO_SNDBUF hint on a connected socket to the size of the data which are expected to be written next time |
static void |
writeHeader(ConnectionHeader header,
java.nio.ByteBuffer buffer)
Sends a EJOE specific header containing the lengh of the given ByteBuffer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NIO_MAX_ITERATIONS
Constructor Detail |
public IOUtils()
Method Detail |
public static void closeQuite(java.io.OutputStream out)
out
- public static void closeQuite(java.io.Writer out)
out
- public static void closeQuite(java.io.InputStream in)
in
- public static void closeQuite(java.io.Reader reader)
reader
- public static void closeQuite(java.nio.channels.Channel channel)
channel
- public static void closeQuite(java.nio.channels.Selector selector)
selector
- public static ConnectionHeader handshake(java.nio.channels.SocketChannel channel, ConnectionHeader header, boolean sendBeforeReceive, long timeout) throws java.io.IOException
channel
- A connected, readable and writeable socket channelsendBeforeReceive
- if true we will try to send one byte then read one byte
otherwise we will use the opposite way around.
java.io.IOException
public static void adapterSerialize(SerializeAdapter adapter, java.io.OutputStream out, java.lang.Object obj, boolean compressed, int compressionLevel) throws java.io.IOException
adapter
- out
- obj
- compressed
-
java.io.IOException
public static java.lang.Object adapterDeserialize(SerializeAdapter adapter, java.io.InputStream in, boolean compressed) throws java.io.IOException
adapter
- in
- compressed
-
java.io.IOException
public static void nonBlockingWrite(java.nio.channels.WritableByteChannel channel, java.nio.ByteBuffer buffer) throws java.io.IOException
channel
- buffer
-
IncompleteIOException
- if the given ByteBuffer could not be send completely
java.io.IOException
public static void semiBlockingWrite(java.nio.channels.WritableByteChannel channel, java.nio.ByteBuffer buffer, long timeout) throws java.io.IOException
channel
- buffer
- timeout
-
IncompleteIOException
- if the given ByteBuffer could not be send completely
java.io.IOException
public static java.nio.ByteBuffer nonBlockingRead(java.nio.channels.ReadableByteChannel channel, java.nio.ByteBuffer buffer) throws java.io.IOException
channel
- buffer
-
java.io.IOException
public static java.nio.ByteBuffer semiBlockingRead(java.nio.channels.ReadableByteChannel channel, java.nio.ByteBuffer buffer, long timeout) throws java.io.IOException
channel
- buffer
- timeout
-
java.io.IOException
public static int readHeader(ConnectionHeader header) throws java.io.IOException
java.io.IOException
public static void writeHeader(ConnectionHeader header, java.nio.ByteBuffer buffer) throws java.io.IOException
buffer
-
java.io.IOException
public static void setSendBufferSize(java.net.Socket socket, int size) throws java.net.SocketException
socket
- the connected socketsize
- size to set for SO_SNDBUF
java.net.SocketException
public static void setReceiveBufferSize(java.net.Socket socket, int size) throws java.net.SocketException
socket
- the connected socketsize
- size to set for SO_RCVBUF
java.net.SocketException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |