com.sun.grizzly.util
Class Utils
java.lang.Object
com.sun.grizzly.util.Utils
public class Utils
- extends Object
Class contains set of useful operations commonly used in the framework
- Author:
- Alexey Stashok, Jean-Francois Arcand
Constructor Summary |
Utils()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
VERBOSE_TESTS
public static boolean VERBOSE_TESTS
Utils
public Utils()
lookupCharset
public static Charset lookupCharset(String charsetName)
- Lookup a
Charset
by name.
Fixes Charset concurrency issue (http://paul.vox.com/library/post/the-mysteries-of-java-character-set-performance.html)
- Parameters:
charsetName
-
- Returns:
Charset
openSelector
public static Selector openSelector()
throws IOException
- Throws:
IOException
readWithTemporarySelector
public static Utils.Result readWithTemporarySelector(SelectableChannel channel,
ByteBuffer byteBuffer,
long readTimeout)
throws IOException
- Method reads data from
SelectableChannel
to
ByteBuffer
. If data is not immediately available - channel
will be reregistered on temporary Selector
and wait maximum
readTimeout milliseconds for data.
- Parameters:
channel
- SelectableChannel
to read data frombyteBuffer
- ByteBuffer
to store read data toreadTimeout
- maximum time in millis operation will wait for
incoming data
- Returns:
- number of bytes were read
- Throws:
IOException
- if any error was occured during read
IOException
extractBytes
public static byte[] extractBytes(ByteBuffer byteBuffer,
byte startByte,
byte endByte)
- Return the bytes contained between the startByte and the endByte. The ByteBuffer
will be left in the state it was before invoking that method, meaning
its position and limit will be the same.
- Parameters:
byteBuffer
- The bytes.startByte
- the first byte to look forendByte
- the second byte to look for
- Returns:
- The byte[] contained between startByte and endByte
findBytes
public static int findBytes(ByteBuffer byteBuffer,
byte[] b)
- Specialized utility method: find a sequence of lower case bytes inside
a ByteBuffer.
findBytes
public static int findBytes(ByteBuffer bb,
Pattern pattern)
isDebugVM
public static boolean isDebugVM()
dumpOut
public static void dumpOut(Object text)
dumpErr
public static void dumpErr(Object text)
copy
public static byte[] copy(byte[] src)
Copyright © 2012 Oracle Corporation. All Rights Reserved.