Package com.pnfsoftware.jeb.util.base
Class Flags
java.lang.Object
com.pnfsoftware.jeb.util.base.Flags
Bit flags object,
int
based (allow 32 bit flags).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addTo
(int f) Add (set) bits to the current flags.int
get()
Get the current flags.boolean
has
(int f) Determine if all of the provided bits are currently set.static boolean
has
(int flags, int bits) Flags utility: determine if the provided bit(s) is/are setboolean
hasNone
(int f) Determine if none of the provided bits are currently set.boolean
hasSome
(int f) Determine if some of the provided bits are currently set.boolean
isValidBit
(int bit) boolean
removeFrom
(int f) Remove (reset) bits from the current flags.boolean
set
(int flags) Set the flags.static int
set
(int flags, int bits, boolean enabled) Flags utility: set or reset bits.boolean
testBit
(int bit) toString()
boolean
update
(int f, boolean add) Add or remove bits to the current flags.void
verify
(int f)
-
Constructor Details
-
Flags
public Flags()Create flags with the initial value 0. -
Flags
public Flags(int initial) Create flags.- Parameters:
initial
- initial flags value
-
Flags
Create flags and specify which bits (0..31) are legal parts of the flags.- Parameters:
initial
- initial flags valueallowed
- legal bit flags; 0xFFFFFFFF (-1) means all bits are legal and can be accessednames
- optional bit names
-
-
Method Details
-
verify
public void verify(int f) -
get
public int get()Get the current flags.- Returns:
-
set
public boolean set(int flags) Set the flags.- Parameters:
flags
-- Returns:
- true if the flags have changed, false otherwise
-
isValidBit
public boolean isValidBit(int bit) -
testBit
public boolean testBit(int bit) -
has
public boolean has(int f) Determine if all of the provided bits are currently set.- Parameters:
f
-- Returns:
-
hasSome
public boolean hasSome(int f) Determine if some of the provided bits are currently set.- Parameters:
f
-- Returns:
-
hasNone
public boolean hasNone(int f) Determine if none of the provided bits are currently set.- Parameters:
f
-- Returns:
-
addTo
public boolean addTo(int f) Add (set) bits to the current flags.- Parameters:
f
-- Returns:
- true if the overall flags have changed, false otherwise
-
removeFrom
public boolean removeFrom(int f) Remove (reset) bits from the current flags.- Parameters:
f
-- Returns:
- true if the overall flags have changed, false otherwise
-
update
public boolean update(int f, boolean add) Add or remove bits to the current flags.- Parameters:
f
-add
- true to add flags, false to remove flags- Returns:
- true if the overall flags have changed, false otherwise
-
toString
-
set
public static int set(int flags, int bits, boolean enabled) Flags utility: set or reset bits.- Parameters:
flags
- current flagsbits
- bit(s) to set or resetenabled
- true to set, false to reset- Returns:
- updated flags
-
has
public static boolean has(int flags, int bits) Flags utility: determine if the provided bit(s) is/are set- Parameters:
flags
- current flagsbits
- bits to check- Returns:
- true if the provided bits are all set, false otherwise
-