|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.directory.api.asn1.util.BitString
public class BitString
Implement the Bit String primitive type. A BitString is internally stored as an array of byte.
| Field Summary | |
|---|---|
static BitString |
EMPTY_STRING
A null MutableString |
| Constructor Summary | |
|---|---|
BitString(byte[] bytes)
Creates a BitString from a byte[]. |
|
BitString(int length)
Creates a BitString with a specific length (length is the number of bits). |
|
| Method Summary | |
|---|---|
void |
clearBit(int pos)
Clear a bit at a specified position. |
boolean |
getBit(int pos)
Get the bit stored into the BitString at a specific position. |
byte[] |
getData()
Get the representation of a BitString. |
byte |
getUnusedBits()
Get the number of unused bits |
void |
setBit(int pos)
Set a bit at a specified position. |
void |
setData(byte[] bytes)
Set a new BitString in the BitString. |
int |
size()
|
String |
toString()
Return a native String representation of the BitString. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final BitString EMPTY_STRING
| Constructor Detail |
|---|
public BitString(int length)
length - The BitString length (it's a number of bits)public BitString(byte[] bytes)
bytes - The value to store. The first byte contains the number of
unused bits| Method Detail |
|---|
public void setData(byte[] bytes)
bytes - The string to storepublic byte[] getData()
public byte getUnusedBits()
public void setBit(int pos)
pos - The bit to setpublic void clearBit(int pos)
pos - The bit to clearpublic boolean getBit(int pos)
With '1001 000x', where x is an unused bit,
^ ^ ^
| | |
| | |
| | +----- getBit(6) = 0
| +---------- getBit(2) = 0
+------------ getBit(0) = 1
pos - The position of the requested bit.
true if the bit is set, false otherwisepublic int size()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||