|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbyucc.jhdl.base.Flags
This class defines a set of flag manipulation utilities designed for
optimal use of memory. Simply use an int to hold your flags.
For example, this sets bits 2 and 4 to true if bit 3 is true:
int flags;
...
if (Flags.get(flags, BIT_3))
flags = Flags.set(flags, BIT_2 | BIT_4);
Field Summary | |
static int |
ALL_BITS
Mask for all 32 bits. |
static int |
BIT_0
Masks for each bit possible. |
static int |
BIT_1
Masks for each bit possible. |
static int |
BIT_10
Masks for each bit possible. |
static int |
BIT_11
Masks for each bit possible. |
static int |
BIT_12
Masks for each bit possible. |
static int |
BIT_13
Masks for each bit possible. |
static int |
BIT_14
Masks for each bit possible. |
static int |
BIT_15
Masks for each bit possible. |
static int |
BIT_16
Masks for each bit possible. |
static int |
BIT_17
Masks for each bit possible. |
static int |
BIT_18
Masks for each bit possible. |
static int |
BIT_19
Masks for each bit possible. |
static int |
BIT_2
Masks for each bit possible. |
static int |
BIT_20
Masks for each bit possible. |
static int |
BIT_21
Masks for each bit possible. |
static int |
BIT_22
Masks for each bit possible. |
static int |
BIT_23
Masks for each bit possible. |
static int |
BIT_24
Masks for each bit possible. |
static int |
BIT_25
Masks for each bit possible. |
static int |
BIT_26
Masks for each bit possible. |
static int |
BIT_27
Masks for each bit possible. |
static int |
BIT_28
Masks for each bit possible. |
static int |
BIT_29
Masks for each bit possible. |
static int |
BIT_3
Masks for each bit possible. |
static int |
BIT_30
Masks for each bit possible. |
static int |
BIT_31
Masks for each bit possible. |
static int |
BIT_4
Masks for each bit possible. |
static int |
BIT_5
Masks for each bit possible. |
static int |
BIT_6
Masks for each bit possible. |
static int |
BIT_7
Masks for each bit possible. |
static int |
BIT_8
Masks for each bit possible. |
static int |
BIT_9
Masks for each bit possible. |
Constructor Summary | |
Flags()
|
Method Summary | |
static int |
clear(int flags,
int mask)
Clears all masked bits, short for set(flags, mask, false) . |
static int |
clearAll()
Clears all bits. |
static boolean |
equal(int flag1,
int flag2,
int mask)
Checks if all masked bits of flagset 1 equal corresponding bits in flagset 2. |
static boolean |
get(int flags,
int mask)
Checks if all masked bits are true. |
static boolean |
getAny(int flags,
int mask)
Checks if any masked bit is true. |
static int |
set(int flags,
int mask)
Sets all masked bits, short for set(flags, mask, true) . |
static int |
set(int flags,
int mask,
boolean value)
Sets all masked bits to value. |
static int |
set(int flag1,
int flag2,
int mask)
Sets all masked bits in flagset 1 to value of corresponding bits in flagset 2. For example, set(BIT_0 | BIT_1 | BIT_2, BIT_0 | BIT_2 | BIT_3, BIT_1 | BIT_2)
returns BIT_0 | BIT_2 , leaving bits 0 and 3 of flag1 unchanged,
and setting bits 1 and 2 to their current value in flag2. |
static int |
setAll()
Sets all bits. |
static int |
toggle(int flags,
int mask)
Toggles masked bits between true and false. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int BIT_0
public static final int BIT_1
public static final int BIT_2
public static final int BIT_3
public static final int BIT_4
public static final int BIT_5
public static final int BIT_6
public static final int BIT_7
public static final int BIT_8
public static final int BIT_9
public static final int BIT_10
public static final int BIT_11
public static final int BIT_12
public static final int BIT_13
public static final int BIT_14
public static final int BIT_15
public static final int BIT_16
public static final int BIT_17
public static final int BIT_18
public static final int BIT_19
public static final int BIT_20
public static final int BIT_21
public static final int BIT_22
public static final int BIT_23
public static final int BIT_24
public static final int BIT_25
public static final int BIT_26
public static final int BIT_27
public static final int BIT_28
public static final int BIT_29
public static final int BIT_30
public static final int BIT_31
public static final int ALL_BITS
Constructor Detail |
public Flags()
Method Detail |
public static final int set(int flags, int mask)
set(flags, mask, true)
.
flags
- The flag set to modify.mask
- The bits to set.
public static final int set(int flags, int mask, boolean value)
flags
- The flag set to modify.mask
- The bits to set.value
- The value to set bits to.
public static final int set(int flag1, int flag2, int mask)
set(BIT_0 | BIT_1 | BIT_2, BIT_0 | BIT_2 | BIT_3, BIT_1 | BIT_2)
returns BIT_0 | BIT_2
, leaving bits 0 and 3 of flag1 unchanged,
and setting bits 1 and 2 to their current value in flag2.
flag1
- The flag set to modify.flag2
- The flag set to read from.mask
- The bits to set.
public static final int clear(int flags, int mask)
set(flags, mask, false)
.
flags
- The flag set to modify.mask
- The bits to clear.
public static final boolean get(int flags, int mask)
flags
- The flag set to read.mask
- The bits to read.
public static final boolean getAny(int flags, int mask)
flags
- The flag set to read.mask
- The bits to read.
public static final boolean equal(int flag1, int flag2, int mask)
flag1
- The first flag set.flag2
- The second flag set.mask
- The bits to compare.
public static final int toggle(int flags, int mask)
flags
- The flag set to modify.mask
- The bits to toggle.
public static final int clearAll()
public static final int setAll()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |