Package zmq.util
Class Utils
- java.lang.Object
-
- zmq.util.Utils
-
public class Utils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.security.SecureRandom>random
-
Constructor Summary
Constructors Modifier Constructor Description privateUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]bytes(java.nio.ByteBuffer buf)static voidcheckArgument(boolean expression, java.lang.String errorMessage)static voidcheckArgument(boolean expression, Supplier<java.lang.String> errorMessage)static booleandelete(java.io.File path)static java.lang.Stringdump(java.nio.ByteBuffer buffer, int pos, int limit)static intfindOpenPort()static AddressgetPeerIpAddress(java.nio.channels.SocketChannel fd)static byte[]randomBytes(int length)static intrandomInt()static intrandomInt(int bound)static byte[]realloc(byte[] src, int size)static <T> T[]realloc(java.lang.Class<T> klass, T[] src, int size, boolean ended)static voidunblockSocket(java.nio.channels.SelectableChannel... channels)static java.lang.Stringunhash(int port)Finds a string whose hashcode is the number in input.private static java.lang.StringBuilderunhash(java.lang.StringBuilder builder, int port, char boundary)
-
-
-
Method Detail
-
randomInt
public static int randomInt()
-
randomInt
public static int randomInt(int bound)
-
randomBytes
public static byte[] randomBytes(int length)
-
unhash
public static java.lang.String unhash(int port)
Finds a string whose hashcode is the number in input.- Parameters:
port- the port to find String hashcode-equivalent of. Has to be positive or 0.- Returns:
- a String whose hashcode is the number in input.
-
unhash
private static java.lang.StringBuilder unhash(java.lang.StringBuilder builder, int port, char boundary)
-
findOpenPort
public static int findOpenPort() throws java.io.IOException- Throws:
java.io.IOException
-
unblockSocket
public static void unblockSocket(java.nio.channels.SelectableChannel... channels) throws java.io.IOException- Throws:
java.io.IOException
-
realloc
public static <T> T[] realloc(java.lang.Class<T> klass, T[] src, int size, boolean ended)
-
bytes
public static byte[] bytes(java.nio.ByteBuffer buf)
-
realloc
public static byte[] realloc(byte[] src, int size)
-
delete
public static boolean delete(java.io.File path)
-
getPeerIpAddress
public static Address getPeerIpAddress(java.nio.channels.SocketChannel fd)
-
dump
public static java.lang.String dump(java.nio.ByteBuffer buffer, int pos, int limit)
-
checkArgument
public static void checkArgument(boolean expression, java.lang.String errorMessage)
-
checkArgument
public static void checkArgument(boolean expression, Supplier<java.lang.String> errorMessage)
-
-