|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.kafka.common.utils.Utils
public class Utils
| Field Summary | |
|---|---|
static java.lang.String |
NL
|
| Constructor Summary | |
|---|---|
Utils()
|
|
| Method Summary | ||
|---|---|---|
static int |
abs(int n)
Get the absolute value of the given number. |
|
static java.lang.String |
formatAddress(java.lang.String host,
java.lang.Integer port)
Formats hostname and port number as a "host:port" address string, surrounding IPv6 addresses with braces '[', ']' |
|
static java.lang.String |
getHost(java.lang.String address)
Extracts the hostname from a "host:port" address string. |
|
static java.lang.Integer |
getPort(java.lang.String address)
Extracts the port number from a "host:port" address string. |
|
static int |
murmur2(byte[] data)
Generates 32 bit murmur2 hash from byte array |
|
static java.lang.Object |
newInstance(java.lang.Class<?> c)
Instantiate the class |
|
static
|
notNull(T t)
Check that the parameter t is not null |
|
static long |
readUnsignedInt(java.nio.ByteBuffer buffer)
Read an unsigned integer from the current position in the buffer, incrementing the position by 4 bytes |
|
static long |
readUnsignedInt(java.nio.ByteBuffer buffer,
int index)
Read an unsigned integer from the given position without modifying the buffers position |
|
static int |
readUnsignedIntLE(byte[] buffer,
int offset)
Read an unsigned integer stored in little-endian format from a byte array at a given offset. |
|
static int |
readUnsignedIntLE(java.io.InputStream in)
Read an unsigned integer stored in little-endian format from the InputStream. |
|
static byte[] |
toArray(java.nio.ByteBuffer buffer)
Read the given byte buffer into a byte array |
|
static byte[] |
toArray(java.nio.ByteBuffer buffer,
int offset,
int size)
Read a byte array from the given offset and size in the buffer |
|
static java.lang.String |
utf8(byte[] bytes)
Turn the given UTF8 byte array into a string |
|
static byte[] |
utf8(java.lang.String string)
Turn a string into a utf8 byte[] |
|
static int |
utf8Length(java.lang.CharSequence s)
Get the length for UTF8-encoding a string without encoding it first |
|
static void |
writetUnsignedInt(java.nio.ByteBuffer buffer,
long value)
Write the given long value as a 4 byte unsigned integer. |
|
static void |
writeUnsignedInt(java.nio.ByteBuffer buffer,
int index,
long value)
Write the given long value as a 4 byte unsigned integer. |
|
static void |
writeUnsignedIntLE(byte[] buffer,
int offset,
int value)
Write an unsigned integer in little-endian format to a byte array at a given offset. |
|
static void |
writeUnsignedIntLE(java.io.OutputStream out,
int value)
Write an unsigned integer in little-endian format to the OutputStream. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static java.lang.String NL
| Constructor Detail |
|---|
public Utils()
| Method Detail |
|---|
public static java.lang.String utf8(byte[] bytes)
bytes - The byte array
public static byte[] utf8(java.lang.String string)
string - The string
public static long readUnsignedInt(java.nio.ByteBuffer buffer)
buffer - The buffer to read from
public static long readUnsignedInt(java.nio.ByteBuffer buffer,
int index)
buffer - the buffer to read fromindex - the index from which to read the integer
public static int readUnsignedIntLE(java.io.InputStream in)
throws java.io.IOException
InputStream.
in - The stream to read from
java.io.IOException
public static int readUnsignedIntLE(byte[] buffer,
int offset)
buffer - The byte array to read fromoffset - The position in buffer to read from
public static void writetUnsignedInt(java.nio.ByteBuffer buffer,
long value)
buffer - The buffer to write tovalue - The value to write
public static void writeUnsignedInt(java.nio.ByteBuffer buffer,
int index,
long value)
buffer - The buffer to write toindex - The position in the buffer at which to begin writingvalue - The value to write
public static void writeUnsignedIntLE(java.io.OutputStream out,
int value)
throws java.io.IOException
OutputStream.
out - The stream to write tovalue - The value to write
java.io.IOException
public static void writeUnsignedIntLE(byte[] buffer,
int offset,
int value)
buffer - The byte array to write tooffset - The position in buffer to write tovalue - The value to writepublic static int abs(int n)
public static int utf8Length(java.lang.CharSequence s)
s - The string to calculate the length for
public static byte[] toArray(java.nio.ByteBuffer buffer)
public static byte[] toArray(java.nio.ByteBuffer buffer,
int offset,
int size)
public static <T> T notNull(T t)
t - The object to check
java.lang.NullPointerException - if t is null.public static java.lang.Object newInstance(java.lang.Class<?> c)
public static int murmur2(byte[] data)
data - byte array to hash
public static java.lang.String getHost(java.lang.String address)
address - address string to parse
public static java.lang.Integer getPort(java.lang.String address)
address - address string to parse
public static java.lang.String formatAddress(java.lang.String host,
java.lang.Integer port)
host - hostnameport - port number
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||