
public final class ByteArrayUtil extends Object
ByteArrayOutputStream and DataInputStream
 doesn't seem appropriate.
 
 C.f. DataOutputStream and
 ByteArrayOutputStream| Modifier and Type | Class and Description | 
|---|---|
| static class  | ByteArrayUtil.ByteSerializerSerializer for byte objects. | 
| static class  | ByteArrayUtil.DoubleSerializerSerializer for double objects. | 
| static class  | ByteArrayUtil.FloatSerializerSerializer for float objects. | 
| static class  | ByteArrayUtil.IntegerSerializerSerializer for integer objects. | 
| static class  | ByteArrayUtil.LongSerializerSerializer for long objects. | 
| static class  | ByteArrayUtil.ShortSerializerSerializer for short objects. | 
| static class  | ByteArrayUtil.StringSerializerSerializer for String objects. | 
| static class  | ByteArrayUtil.VarintSerializerSerializer for Integer objects using a variable size encoding. | 
| Modifier and Type | Field and Description | 
|---|---|
| static ByteArrayUtil.ByteSerializer | BYTE_SERIALIZERStatic instance. | 
| static ByteArrayUtil.DoubleSerializer | DOUBLE_SERIALIZERStatic instance. | 
| static ByteArrayUtil.FloatSerializer | FLOAT_SERIALIZERStatic instance. | 
| static ByteArrayUtil.IntegerSerializer | INT_SERIALIZERStatic instance. | 
| static ByteArrayUtil.LongSerializer | LONG_SERIALIZERStatic instance. | 
| static ByteArrayUtil.ShortSerializer | SHORT_SERIALIZERStatic instance. | 
| static int | SIZE_BYTESize of a byte in bytes. | 
| static int | SIZE_DOUBLESize of a double in bytes. | 
| static int | SIZE_FLOATSize of a float in bytes. | 
| static int | SIZE_INTSize of an integer in bytes. | 
| static int | SIZE_LONGSize of a long in bytes. | 
| static int | SIZE_SHORTSize of a short in bytes. | 
| static ByteArrayUtil.StringSerializer | STRING_SERIALIZERStatic instance. | 
| static ByteArrayUtil.VarintSerializer | VARINT_SERIALIZERStatic instance. | 
| Modifier | Constructor and Description | 
|---|---|
| private  | ByteArrayUtil()Fake constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| static int | getSignedVarintLongSize(long val)Compute the size of the varint encoding for this signed integer. | 
| static int | getSignedVarintSize(int val)Compute the size of the varint encoding for this signed integer. | 
| static int | getStringSize(String s)Compute the size of the string after encoding. | 
| static int | getUnsignedVarintLongSize(long obj)Compute the size of the varint encoding for this unsigned integer. | 
| static int | getUnsignedVarintSize(int obj)Compute the size of the varint encoding for this unsigned integer. | 
| static double | readDouble(byte[] array,
          int offset)Read a double from the byte array at the given offset. | 
| static float | readFloat(byte[] array,
         int offset)Read a float from the byte array at the given offset. | 
| static int | readInt(byte[] array,
       int offset)Read an integer from the byte array at the given offset. | 
| static long | readLong(byte[] array,
        int offset)Read a long from the byte array at the given offset. | 
| static short | readShort(byte[] array,
         int offset)Read a short from the byte array at the given offset. | 
| static int | readSignedVarint(ByteBuffer buffer)Read a signed integer. | 
| static long | readSignedVarintLong(ByteBuffer buffer)Read a signed long. | 
| static String | readString(ByteBuffer buffer)Read a string from the buffer. | 
| static int | readUnsignedShort(byte[] array,
                 int offset)Read an unsigned short from the byte array at the given offset. | 
| static int | readUnsignedVarint(ByteBuffer buffer)Read an unsigned integer. | 
| static long | readUnsignedVarintLong(ByteBuffer buffer)Read an unsigned long. | 
| static void | unmapByteBuffer(MappedByteBuffer map)Unmap a byte buffer. | 
| static int | writeDouble(byte[] array,
           int offset,
           double v)Write a double to the byte array at the given offset. | 
| static int | writeFloat(byte[] array,
          int offset,
          float v)Write a float to the byte array at the given offset. | 
| static int | writeInt(byte[] array,
        int offset,
        int v)Write an integer to the byte array at the given offset. | 
| static int | writeLong(byte[] array,
         int offset,
         long v)Write a long to the byte array at the given offset. | 
| static int | writeShort(byte[] array,
          int offset,
          int v)Write a short to the byte array at the given offset. | 
| static void | writeSignedVarint(ByteBuffer buffer,
                 int val)Write an signed integer using a variable-length encoding. | 
| static void | writeSignedVarintLong(ByteBuffer buffer,
                     long val)Write a signed long using a variable-length encoding. | 
| static void | writeString(ByteBuffer buffer,
           String s)Write a string to the buffer. | 
| static void | writeUnsignedVarint(ByteBuffer buffer,
                   int val)Write an unsigned integer using a variable-length encoding. | 
| static void | writeUnsignedVarintLong(ByteBuffer buffer,
                       long val)Write an unsigned long using a variable-length encoding. | 
public static final int SIZE_BYTE
public static final int SIZE_SHORT
public static final int SIZE_INT
public static final int SIZE_LONG
public static final int SIZE_FLOAT
public static final int SIZE_DOUBLE
public static final ByteArrayUtil.ByteSerializer BYTE_SERIALIZER
public static final ByteArrayUtil.ShortSerializer SHORT_SERIALIZER
public static final ByteArrayUtil.IntegerSerializer INT_SERIALIZER
public static final ByteArrayUtil.LongSerializer LONG_SERIALIZER
public static final ByteArrayUtil.FloatSerializer FLOAT_SERIALIZER
public static final ByteArrayUtil.DoubleSerializer DOUBLE_SERIALIZER
public static final ByteArrayUtil.StringSerializer STRING_SERIALIZER
public static final ByteArrayUtil.VarintSerializer VARINT_SERIALIZER
public static int writeShort(byte[] array,
             int offset,
             int v)
array - Array to write tooffset - Offset to write tov - datapublic static int writeInt(byte[] array,
           int offset,
           int v)
array - Array to write tooffset - Offset to write tov - datapublic static int writeLong(byte[] array,
            int offset,
            long v)
array - Array to write tooffset - Offset to write tov - datapublic static int writeFloat(byte[] array,
             int offset,
             float v)
array - Array to write tooffset - Offset to write tov - datapublic static int writeDouble(byte[] array,
              int offset,
              double v)
array - Array to write tooffset - Offset to write tov - datapublic static short readShort(byte[] array,
              int offset)
array - Array to read fromoffset - Offset to read atpublic static int readUnsignedShort(byte[] array,
                    int offset)
array - Array to read fromoffset - Offset to read atpublic static int readInt(byte[] array,
          int offset)
array - Array to read fromoffset - Offset to read atpublic static long readLong(byte[] array,
            int offset)
array - Array to read fromoffset - Offset to read atpublic static float readFloat(byte[] array,
              int offset)
array - Array to read fromoffset - Offset to read atpublic static double readDouble(byte[] array,
                int offset)
array - Array to read fromoffset - Offset to read atpublic static void writeSignedVarint(ByteBuffer buffer, int val)
buffer - Buffer to write toval - number to writepublic static void writeSignedVarintLong(ByteBuffer buffer, long val)
buffer - Buffer to write toval - number to writepublic static void writeUnsignedVarint(ByteBuffer buffer, int val)
buffer - Buffer to write toval - number to writepublic static void writeUnsignedVarintLong(ByteBuffer buffer, long val)
writeUnsignedVarint(java.nio.ByteBuffer, int)buffer - Buffer to write toval - number to writepublic static void writeString(ByteBuffer buffer, String s)
ByteArrayUtil.StringSerializer for details.buffer - Buffer to write tos - String to writepublic static int getSignedVarintSize(int val)
val - integer to writepublic static int getUnsignedVarintSize(int obj)
obj - integer to writepublic static int getSignedVarintLongSize(long val)
val - integer to writepublic static int getUnsignedVarintLongSize(long obj)
obj - integer to writepublic static int getStringSize(String s)
s - String to encodepublic static int readSignedVarint(ByteBuffer buffer)
buffer - Buffer to read frompublic static int readUnsignedVarint(ByteBuffer buffer)
buffer - Buffer to read frompublic static long readSignedVarintLong(ByteBuffer buffer)
buffer - Buffer to read frompublic static long readUnsignedVarintLong(ByteBuffer buffer)
buffer - Buffer to read frompublic static String readString(ByteBuffer buffer)
null value
 and the empty string are encoded the same way.buffer - Buffer to read from.public static void unmapByteBuffer(MappedByteBuffer map)
map - Byte buffer to unmap.