public final class Bits extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
allAreClear(int var,
int flags)
Determine if all of the
flags in the given var are clear. |
static boolean |
allAreClear(long var,
long flags)
Determine if all of the
flags in the given var are clear. |
static boolean |
allAreSet(int var,
int flags)
Determine if all of the
flags in the given var are set. |
static boolean |
allAreSet(long var,
long flags)
Determine if all of the
flags in the given var are set. |
static boolean |
anyAreClear(int var,
int flags)
Determine if any of the
flags in the given var are clear. |
static boolean |
anyAreClear(long var,
long flags)
Determine if any of the
flags in the given var are clear. |
static boolean |
anyAreSet(int var,
int flags)
Determine if any of the
flags in the given var are set. |
static boolean |
anyAreSet(long var,
long flags)
Determine if any of the
flags in the given var are set. |
static char |
charFromBytesBE(byte[] b,
int off)
Get a 16-bit signed big-endian char value from a byte array.
|
static char |
charFromBytesLE(byte[] b,
int off)
Get a 16-bit signed little-endian char value from a byte array.
|
static int |
intBitMask(int low,
int high)
Get an integer bit mask consisting of 1 bits in the given range.
|
static int |
intFromBytesBE(byte[] b,
int off)
Get a 32-bit signed big-endian int value from a byte array.
|
static int |
intFromBytesLE(byte[] b,
int off)
Get a 32-bit signed little-endian int value from a byte array.
|
static long |
longBitMask(int low,
int high)
Get a long bit mask consisting of 1 bits in the given range.
|
static long |
longFromBytesBE(byte[] b,
int off)
Get a 64-bit signed big-endian long value from a byte array.
|
static long |
longFromBytesLE(byte[] b,
int off)
Get a 64-bit signed little-endian long value from a byte array.
|
static int |
mediumFromBytesBE(byte[] b,
int off)
Get a 24-bit signed big-endian int value from a byte array.
|
static int |
mediumFromBytesLE(byte[] b,
int off)
Get a 24-bit signed little-endian int value from a byte array.
|
static short |
shortFromBytesBE(byte[] b,
int off)
Get a 16-bit signed big-endian short value from a byte array.
|
static short |
shortFromBytesLE(byte[] b,
int off)
Get a 16-bit signed little-endian short value from a byte array.
|
static int |
unsigned(byte v)
Convert a signed value to unsigned.
|
static long |
unsigned(int v)
Convert a signed value to unsigned.
|
static int |
unsigned(short v)
Convert a signed value to unsigned.
|
public static int intBitMask(int low, int high)
int
will have bits low
through high
set, and all other bits clear.low
- the low bit valuehigh
- the high bit valuepublic static long longBitMask(int low, int high)
long
will have bits low
through high
set, and all other bits clear.low
- the low bit valuehigh
- the high bit valuepublic static boolean anyAreSet(int var, int flags)
flags
in the given var
are set.var
- the value to testflags
- the flags to test fortrue
if any of flags
are in var
, false
otherwisepublic static boolean allAreSet(int var, int flags)
flags
in the given var
are set.var
- the value to testflags
- the flags to test fortrue
if all of flags
are in var
, false
otherwisepublic static boolean anyAreClear(int var, int flags)
flags
in the given var
are clear.var
- the value to testflags
- the flags to test fortrue
if not all of flags
are in var
, false
otherwisepublic static boolean allAreClear(int var, int flags)
flags
in the given var
are clear.var
- the value to testflags
- the flags to test fortrue
if none of flags
are in var
, false
otherwisepublic static boolean anyAreSet(long var, long flags)
flags
in the given var
are set.var
- the value to testflags
- the flags to test fortrue
if any of flags
are in var
, false
otherwisepublic static boolean allAreSet(long var, long flags)
flags
in the given var
are set.var
- the value to testflags
- the flags to test fortrue
if all of flags
are in var
, false
otherwisepublic static boolean anyAreClear(long var, long flags)
flags
in the given var
are clear.var
- the value to testflags
- the flags to test fortrue
if not all of flags
are in var
, false
otherwisepublic static boolean allAreClear(long var, long flags)
flags
in the given var
are clear.var
- the value to testflags
- the flags to test fortrue
if none of flags
are in var
, false
otherwisepublic static int unsigned(byte v)
v
- the signed bytepublic static int unsigned(short v)
v
- the signed shortpublic static long unsigned(int v)
v
- the signed intpublic static short shortFromBytesLE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static short shortFromBytesBE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static char charFromBytesLE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static char charFromBytesBE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static int mediumFromBytesLE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static int mediumFromBytesBE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static int intFromBytesLE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static int intFromBytesBE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static long longFromBytesLE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arraypublic static long longFromBytesBE(byte[] b, int off)
b
- the byte arrayoff
- the offset in the arrayCopyright © 2019 JBoss by Red Hat. All rights reserved.