Package org.osgi.test.common.bitmaps
Class Bitmap
java.lang.Object
org.osgi.test.common.bitmaps.Bitmap
Useful class for producing human-friendly dumps of bit fields. Has support
functions for single-bit values (
toString(int) and multi-bit fields
maskToString(int).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintstatic booleanhasSingleBit(int type) Checks to see if it has exactly one bit set.maskToString(int mask) Return a string representation of the given type mask.toString(int type) Return a string representation of the given type.static booleantypeMatchesMask(int type, int mask)
-
Constructor Details
-
Bitmap
Constructs a bitmap- Parameters:
types- the full set of known allowed field values in this bit map.mappingFunction- function to produce a human-friendly string for the given map.
-
Bitmap
-
-
Method Details
-
getKnownMask
public int getKnownMask()- Returns:
- A mask of all known allowed values in this bit mask.
-
getUnknownMask
public int getUnknownMask()- Returns:
- A mask of all values that are not known to be allowed in this bit mask.
-
hasSingleBit
public static boolean hasSingleBit(int type) Checks to see if it has exactly one bit set.- Parameters:
type- the bit field to check- Returns:
trueif only one bit set, otherwisefalse.
-
toString
Return a string representation of the given type. Expects to be passed a field with exactly one bit set - if you want to dump a bit mask, then please usemaskToString(int)- Parameters:
type- the field being converted.- Returns:
- Description of the given field.
- Throws:
IllegalArgumentException- if the field has more than one bit set.- See Also:
-
maskToString
Return a string representation of the given type mask. If the mask contains multiple bits, their string representations are separated by pipes (" | ").- Parameters:
mask- the field being converted.- Returns:
- Description of the given field.
- See Also:
-
typeMatchesMask
public static boolean typeMatchesMask(int type, int mask)
-