Package com.helger.commons.lang
Class BitSetHelper
- java.lang.Object
-
- com.helger.commons.lang.BitSetHelper
-
@Immutable public final class BitSetHelper extends Object
Helper class to work with bit sets.- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BitSetcreateBitSet(byte nValue)Convert the passed byte value to an bit set of size 8.static BitSetcreateBitSet(int nValue)Convert the passed int value to an bit set of size 32.static BitSetcreateBitSet(long nValue)Convert the passed long value to an bit set of size 64.static BitSetcreateBitSet(short nValue)Convert the passed short value to an bit set of size 16.static intgetExtractedIntValue(BitSet aBS)Extract the int representation of the passed bit set.static longgetExtractedLongValue(BitSet aBS)Extract the long representation of the passed bit set.
-
-
-
Method Detail
-
createBitSet
@Nonnull public static BitSet createBitSet(byte nValue)
Convert the passed byte value to an bit set of size 8.- Parameters:
nValue- The value to be converted to a bit set.- Returns:
- The non-
nullbit set.
-
createBitSet
@Nonnull public static BitSet createBitSet(short nValue)
Convert the passed short value to an bit set of size 16.- Parameters:
nValue- The value to be converted to a bit set.- Returns:
- The non-
nullbit set.
-
createBitSet
@Nonnull public static BitSet createBitSet(int nValue)
Convert the passed int value to an bit set of size 32.- Parameters:
nValue- The value to be converted to a bit set.- Returns:
- The non-
nullbit set.
-
createBitSet
@Nonnull public static BitSet createBitSet(long nValue)
Convert the passed long value to an bit set of size 64.- Parameters:
nValue- The value to be converted to a bit set.- Returns:
- The non-
nullbit set.
-
getExtractedIntValue
public static int getExtractedIntValue(@Nonnull BitSet aBS)
Extract the int representation of the passed bit set. To avoid loss of data, the bit set may not have more than 32 bits.- Parameters:
aBS- The bit set to extract the value from. May not benull.- Returns:
- The extracted value. May be negative if the bit set has 32 elements, the highest order bit is set.
-
getExtractedLongValue
public static long getExtractedLongValue(@Nonnull BitSet aBS)
Extract the long representation of the passed bit set. To avoid loss of data, the bit set may not have more than 64 bits.- Parameters:
aBS- The bit set to extract the value from. May not benull.- Returns:
- The extracted value. May be negative if the bit set has 64 elements, the highest order bit is set.
-
-