org.openjena.atlas.lib
Class BitsInt

java.lang.Object
  extended by org.openjena.atlas.lib.BitsInt

public final class BitsInt
extends Object

Utilities for manipulating a bit pattern which held in a 32 bit int


Method Summary
static int access(int bits, int start, int finish)
          Get the bits from start (inclusive) to finish (exclusive), leaving them aligned in the int.
static int clear(int bits, int start, int finish)
           
static boolean isSet(int bits, int bitIndex)
           
static int mask(int start, int finish)
          Create a mask that has ones between bit positions start (inc) and finish (exc)
static int maskZero(int start, int finish)
          Create a mask that has zeros between bit positions start (inc) and finish (exc) and ones elsewhere
static int pack(int bits, int value, int start, int finish)
          Place the value into the bit pattern between start and finish; leaves other bits aint.
static int set(int bits, int bitIndex)
          Set the bits specificied.
static int set(int bits, int start, int finish)
          Set the bits from string (inc) to finish (exc) to one
static boolean test(int bits, boolean isSet, int bitIndex)
           
static boolean test(int bits, int value, int start, int finish)
           
static int unpack(int bits, int start, int finish)
          Extract the value packed into bits start (inclusive) and finish (exclusive), the value is returned the low part of the returned int.
static int unpack(String str, int startChar, int finishChar)
          Get bits from a hex string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 the low part of the returned int. The low bit is bit zero.


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; leaves other bits aint.


unpack

public static final int unpack(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

set

public static final int set(int bits,
                            int bitIndex)
Set the bits specificied.

Parameters:
bits - Pattern
bitIndex -
Returns:
Modified pattern

set

public static final int set(int bits,
                            int start,
                            int finish)
Set the bits from string (inc) to finish (exc) to one

Parameters:
bits - Pattern
start - start (inclusive)
finish - finish (exclusive)
Returns:
Modified pattern

test

public static final boolean test(int bits,
                                 boolean isSet,
                                 int bitIndex)

isSet

public static final boolean isSet(int bits,
                                  int bitIndex)

test

public static final boolean test(int bits,
                                 int value,
                                 int start,
                                 int finish)

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.


clear

public static final int clear(int bits,
                              int start,
                              int finish)

mask

public static final int mask(int start,
                             int finish)
Create a mask that has ones between bit positions start (inc) and finish (exc)


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



Licenced under the Apache License, Version 2.0