com.hazelcast.nio
Class Bits

java.lang.Object
  extended by com.hazelcast.nio.Bits

public final class Bits
extends Object

Access and manipulate bits, bytes, primitives ...


Field Summary
static int CHAR_SIZE_IN_BYTES
          Char size in bytes
static int DOUBLE_SIZE_IN_BYTES
          Double size in bytes
static int FLOAT_SIZE_IN_BYTES
          Float size in bytes
static int INT_SIZE_IN_BYTES
          Integer size in bytes
static int LONG_SIZE_IN_BYTES
          Long size in bytes
static int SHORT_SIZE_IN_BYTES
          Short size in bytes
 
Method Summary
static byte clearBit(byte value, int bit)
          Clears n-th bit of the byte value
static int clearBit(int value, int bit)
          Clears n-th bit of the integer value
static int combineToInt(short x, short y)
          Combines two short integer values into an integer.
static long combineToLong(int x, int y)
          Combines two integer values into a long integer.
static int extractInt(long value, boolean lowerBits)
           
static short extractShort(int value, boolean lowerBits)
           
static byte invertBit(byte value, int bit)
          Inverts n-th bit of the byte value
static int invertBit(int value, int bit)
          Inverts n-th bit of the integer value
static boolean isBitSet(int value, int bit)
          Returns true if n-th bit of the value is set, false otherwise
static char readChar(byte[] buffer, int pos, boolean bigEndian)
           
static char readCharB(byte[] buffer, int pos)
           
static char readCharL(byte[] buffer, int pos)
           
static int readInt(byte[] buffer, int pos, boolean bigEndian)
           
static int readIntB(byte[] buffer, int pos)
           
static int readIntL(byte[] buffer, int pos)
           
static long readLong(byte[] buffer, int pos, boolean bigEndian)
           
static long readLongB(byte[] buffer, int pos)
           
static long readLongL(byte[] buffer, int pos)
           
static short readShort(byte[] buffer, int pos, boolean bigEndian)
           
static short readShortB(byte[] buffer, int pos)
           
static short readShortL(byte[] buffer, int pos)
           
static byte setBit(byte value, int bit)
          Sets n-th bit of the byte value
static int setBit(int value, int bit)
          Sets n-th bit of the integer value
static void writeChar(byte[] buffer, int pos, char v, boolean bigEndian)
           
static void writeCharB(byte[] buffer, int pos, char v)
           
static void writeCharL(byte[] buffer, int pos, char v)
           
static void writeInt(byte[] buffer, int pos, int v, boolean bigEndian)
           
static void writeIntB(byte[] buffer, int pos, int v)
           
static void writeIntL(byte[] buffer, int pos, int v)
           
static void writeLong(byte[] buffer, int pos, long v, boolean bigEndian)
           
static void writeLongB(byte[] buffer, int pos, long v)
           
static void writeLongL(byte[] buffer, int pos, long v)
           
static void writeShort(byte[] buffer, int pos, short v, boolean bigEndian)
           
static void writeShortB(byte[] buffer, int pos, short v)
           
static void writeShortL(byte[] buffer, int pos, short v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHORT_SIZE_IN_BYTES

public static final int SHORT_SIZE_IN_BYTES
Short size in bytes

See Also:
Constant Field Values

CHAR_SIZE_IN_BYTES

public static final int CHAR_SIZE_IN_BYTES
Char size in bytes

See Also:
Constant Field Values

INT_SIZE_IN_BYTES

public static final int INT_SIZE_IN_BYTES
Integer size in bytes

See Also:
Constant Field Values

FLOAT_SIZE_IN_BYTES

public static final int FLOAT_SIZE_IN_BYTES
Float size in bytes

See Also:
Constant Field Values

LONG_SIZE_IN_BYTES

public static final int LONG_SIZE_IN_BYTES
Long size in bytes

See Also:
Constant Field Values

DOUBLE_SIZE_IN_BYTES

public static final int DOUBLE_SIZE_IN_BYTES
Double size in bytes

See Also:
Constant Field Values
Method Detail

readChar

public static char readChar(byte[] buffer,
                            int pos,
                            boolean bigEndian)

readCharB

public static char readCharB(byte[] buffer,
                             int pos)

readCharL

public static char readCharL(byte[] buffer,
                             int pos)

writeChar

public static void writeChar(byte[] buffer,
                             int pos,
                             char v,
                             boolean bigEndian)

writeCharB

public static void writeCharB(byte[] buffer,
                              int pos,
                              char v)

writeCharL

public static void writeCharL(byte[] buffer,
                              int pos,
                              char v)

readShort

public static short readShort(byte[] buffer,
                              int pos,
                              boolean bigEndian)

readShortB

public static short readShortB(byte[] buffer,
                               int pos)

readShortL

public static short readShortL(byte[] buffer,
                               int pos)

writeShort

public static void writeShort(byte[] buffer,
                              int pos,
                              short v,
                              boolean bigEndian)

writeShortB

public static void writeShortB(byte[] buffer,
                               int pos,
                               short v)

writeShortL

public static void writeShortL(byte[] buffer,
                               int pos,
                               short v)

readInt

public static int readInt(byte[] buffer,
                          int pos,
                          boolean bigEndian)

readIntB

public static int readIntB(byte[] buffer,
                           int pos)

readIntL

public static int readIntL(byte[] buffer,
                           int pos)

writeInt

public static void writeInt(byte[] buffer,
                            int pos,
                            int v,
                            boolean bigEndian)

writeIntB

public static void writeIntB(byte[] buffer,
                             int pos,
                             int v)

writeIntL

public static void writeIntL(byte[] buffer,
                             int pos,
                             int v)

readLong

public static long readLong(byte[] buffer,
                            int pos,
                            boolean bigEndian)

readLongB

public static long readLongB(byte[] buffer,
                             int pos)

readLongL

public static long readLongL(byte[] buffer,
                             int pos)

writeLong

public static void writeLong(byte[] buffer,
                             int pos,
                             long v,
                             boolean bigEndian)

writeLongB

public static void writeLongB(byte[] buffer,
                              int pos,
                              long v)

writeLongL

public static void writeLongL(byte[] buffer,
                              int pos,
                              long v)

setBit

public static byte setBit(byte value,
                          int bit)
Sets n-th bit of the byte value

Parameters:
value - byte value
bit - n-th bit
Returns:
value

clearBit

public static byte clearBit(byte value,
                            int bit)
Clears n-th bit of the byte value

Parameters:
value - byte value
bit - n-th bit
Returns:
value

invertBit

public static byte invertBit(byte value,
                             int bit)
Inverts n-th bit of the byte value

Parameters:
value - byte value
bit - n-th bit
Returns:
value

setBit

public static int setBit(int value,
                         int bit)
Sets n-th bit of the integer value

Parameters:
value - integer value
bit - n-th bit
Returns:
value

clearBit

public static int clearBit(int value,
                           int bit)
Clears n-th bit of the integer value

Parameters:
value - integer value
bit - n-th bit
Returns:
value

invertBit

public static int invertBit(int value,
                            int bit)
Inverts n-th bit of the integer value

Parameters:
value - integer value
bit - n-th bit
Returns:
value

isBitSet

public static boolean isBitSet(int value,
                               int bit)
Returns true if n-th bit of the value is set, false otherwise


combineToInt

public static int combineToInt(short x,
                               short y)
Combines two short integer values into an integer.


extractShort

public static short extractShort(int value,
                                 boolean lowerBits)

combineToLong

public static long combineToLong(int x,
                                 int y)
Combines two integer values into a long integer.


extractInt

public static int extractInt(long value,
                             boolean lowerBits)


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.