Class BitArray
java.lang.Object
org.mozilla.jss.netscape.security.util.BitArray
A packed array of booleans.
- Version:
- 1.2 97/12/10
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private int
private static final byte[][]
private byte[]
-
Constructor Summary
ConstructorsModifierConstructorDescriptionBitArray
(boolean[] bits) Create a BitArray whose bits are those of the given array of Booleans.BitArray
(int length) Creates a BitArray of the specified size, initialized to zeros.BitArray
(int length, byte[] a) Creates a BitArray of the specified size, initialized from the specified byte array.private
Copy constructor (for cloning). -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
boolean
get
(int index) Returns the indexed bit in this BitArray.int
hashCode()
Returns a hash code value for this bit array.int
length()
Returns the length of this BitArray.private static int
position
(int idx) void
set
(int index, boolean value) Sets the indexed bit in this BitArray.private static int
subscript
(int idx) boolean[]
Return a boolean array with the same bit values a this BitArray.byte[]
Returns a Byte array containing the contents of this BitArray.toString()
Returns a string representation of this BitArray.
-
Field Details
-
repn
private byte[] repn -
length
private int length -
BITS_PER_UNIT
private static final int BITS_PER_UNIT- See Also:
-
NYBBLE
private static final byte[][] NYBBLE -
BYTES_PER_LINE
private static final int BYTES_PER_LINE- See Also:
-
-
Constructor Details
-
BitArray
Creates a BitArray of the specified size, initialized to zeros.- Throws:
IllegalArgumentException
-
BitArray
Creates a BitArray of the specified size, initialized from the specified byte array. The most significant bit of a[0] gets index zero in the BitArray. The array a must be large enough to specify a value for every bit in the BitArray. In other words,8*a.length >= length
.- Throws:
IllegalArgumentException
-
BitArray
public BitArray(boolean[] bits) Create a BitArray whose bits are those of the given array of Booleans. -
BitArray
Copy constructor (for cloning).
-
-
Method Details
-
subscript
private static int subscript(int idx) -
position
private static int position(int idx) -
get
Returns the indexed bit in this BitArray.- Throws:
ArrayIndexOutOfBoundsException
-
set
Sets the indexed bit in this BitArray.- Throws:
ArrayIndexOutOfBoundsException
-
length
public int length()Returns the length of this BitArray. -
toByteArray
public byte[] toByteArray()Returns a Byte array containing the contents of this BitArray. The bit stored at index zero in this BitArray will be copied into the most significant bit of the zeroth element of the returned byte array. The last byte of the returned byte array will be contain zeros in any bits that do not have corresponding bits in the BitArray. (This matters only if the BitArray's size is not a multiple of 8.) -
equals
-
toBooleanArray
public boolean[] toBooleanArray()Return a boolean array with the same bit values a this BitArray. -
hashCode
public int hashCode()Returns a hash code value for this bit array. -
clone
-
toString
Returns a string representation of this BitArray.
-