Package org.apache.jena.atlas.lib
Class BitsInt
- java.lang.Object
-
- org.apache.jena.atlas.lib.BitsInt
-
public final class BitsInt extends java.lang.ObjectUtilities for manipulating a bit pattern which are held in a 32 bit int.- See Also:
BitsLong
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intaccess(int bits, int start, int finish)Get the bits from start (inclusive) to finish (exclusive), leaving them aligned in the int.static intclear(int bits, int bitIndex)Clear the bit specified.static intclear(int bits, int start, int finish)Clear the bits specified.static booleanisSet(int bits, int bitIndex)Test whether a bit is setstatic intmask(int start, int finish)Create a mask that has ones between bit positions start (inc) and finish (exc), and zeros elsewhere.static intmaskZero(int start, int finish)Create a mask that has zeros between bit positions start (inc) and finish (exc), and ones elsewherestatic intpack(int bits, int value, int start, int finish)Place the value into the bit pattern between start and finish and returns the new int.static intset(int bits, int bitIndex)Set the bits specified.static intset(int bits, int start, int finish)Set the bits from start (inc) to finish (exc) to onestatic booleantest(int bits, boolean isSet, int bitIndex)Test whether a bit is the same as isSetstatic booleantest(int bits, int value, int start, int finish)Test whether a range has a specific value or notstatic intunpack(int bits, int start, int finish)Extract the value packed into bits start (inclusive) and finish (exclusive).static intunpack(java.lang.String str, int startChar, int finishChar)Get bits from a hex string.
-
-
-
Method Detail
-
unpack
public static final int unpack(int bits, int start, int finish)Extract the value packed into bits start (inclusive) and finish (exclusive). The value is returned in the low part of the returned int. The low bit is bit zero.- Parameters:
bits-start-finish-- Returns:
- int
-
pack
public static final int pack(int bits, int value, int start, int finish)Place the value into the bit pattern between start and finish and returns the new int. Leaves other bits alone.- Parameters:
bits-value-start-finish-- Returns:
- int
-
unpack
public static final int unpack(java.lang.String str, int startChar, int finishChar)Get bits from a hex string.- Parameters:
str-startChar- Index of first character (counted from the left, string style).finishChar- Index after the last character (counted from the left, string style).- Returns:
- int
- See Also:
access(int, int, int)
-
set
public static final int set(int bits, int bitIndex)Set the bits specified.- Parameters:
bits- PatternbitIndex-- Returns:
- Modified pattern
-
set
public static final int set(int bits, int start, int finish)Set the bits from start (inc) to finish (exc) to one- Parameters:
bits- Patternstart- start (inclusive)finish- finish (exclusive)- Returns:
- Modified pattern
-
test
public static final boolean test(int bits, boolean isSet, int bitIndex)Test whether a bit is the same as isSet- Parameters:
bits- PatternisSet- Test whether is set or not.bitIndex- Bit index- Returns:
- Boolean
-
isSet
public static final boolean isSet(int bits, int bitIndex)Test whether a bit is set- Parameters:
bits- PatternbitIndex- Bit index- Returns:
- Boolean
-
test
public static final boolean test(int bits, int value, int start, int finish)Test whether a range has a specific value or not- Parameters:
bits- Patternvalue- Value to test forstart- start (inclusive)finish- finish (exclusive)- Returns:
- Boolean
-
access
public static final int access(int bits, int start, int finish)Get the bits from start (inclusive) to finish (exclusive), leaving them aligned in the int. See also unpack, returns the value found at that place.- Parameters:
bits-start-finish-- Returns:
- int
- See Also:
unpack(int, int, int)
-
clear
public static final int clear(int bits, int bitIndex)Clear the bit specified.- Parameters:
bits-bitIndex-- Returns:
- int
-
clear
public static final int clear(int bits, int start, int finish)Clear the bits specified.- Parameters:
bits-start-finish-- Returns:
- int
-
mask
public static final int mask(int start, int finish)Create a mask that has ones between bit positions start (inc) and finish (exc), and zeros elsewhere.- Parameters:
start-finish-- Returns:
- int
-
maskZero
public static final int maskZero(int start, int finish)Create a mask that has zeros between bit positions start (inc) and finish (exc), and ones elsewhere- Parameters:
start-finish-- Returns:
- int
-
-