org.mozilla.jss.asn1
public class BIT_STRING extends Object implements ASN1Value
BIT STRING
, which is an ordered sequence of bits.
The bits are stored the same way they are encoded in BER: as an array
of bytes with 0-7 unused bits at the end.
Nested Class Summary | |
---|---|
static class | BIT_STRING.Template
A class for decoding a BIT_STRING from its BER encoding. |
Field Summary | |
---|---|
static Form | FORM |
static Tag | TAG |
Constructor Summary | |
---|---|
BIT_STRING(byte[] bits, int padCount) | |
BIT_STRING(BitSet bs, int numBits)
Constructs a BIT_STRING from a BitSet. |
Method Summary | |
---|---|
void | encode(OutputStream ostream) |
void | encode(Tag implicitTag, OutputStream ostream) |
byte[] | getBits()
Returns the bits packed into an array of bytes, with padding
at the end. |
int | getPadCount()
Returns the number of padding bits at the end of the array.
|
boolean | getRemoveTrailingZeroes()
Determines whether the DER-encoding of this bitstring will have
its trailing zeroes removed. |
Tag | getTag() |
static BIT_STRING.Template | getTemplate() |
void | setRemoveTrailingZeroes(boolean removeTrailingZeroes)
Determines whether the DER-encoding of this bitstring will have
its trailing zeroes removed. |
BitSet | toBitSet()
Copies this BIT STRING into a Java BitSet. |
boolean[] | toBooleanArray()
Copies this BIT STRING into a boolean array. |
Parameters: bits The bits packed into an array of bytes, with padding
at the end. The array may be empty (but not null), in which case
padCount
must be zero. The array is referenced,
not cloned. padCount The number of padding bits at the end of the array.
Must be in the range [0,7]
.
Throws: NumberFormatException If padCount
is not in
the range [0,7]
, or bits
is
empty and padCount
is non-zero.
Parameters: bs A BitSet. numBits The number of bits to copy from the BitSet. This is necessary because the size of a BitSet is always padded up to a multiple of 64, but not all of these bits may be significant.
Throws: NumberFormatException If numBits
is larger
than bs.size()
or less than zero.
padCount
must be zero. The array is referenced,
not cloned.[0,7]
.true
for 1 and false
for 0.