|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.util.BitString
public class BitString
String of bits.
A bit string logically consists of a set of '0' and '1' values, of a specified length. The length is preserved even if this means that the bit string has leading '0's.
You can create a bit string from a string of 0s and 1s (BitString(String,int)
or createFromBitString(java.lang.String)
), or from a string of
hex digits (createFromHexString(java.lang.String)
). You can convert it to a byte array
(getAsByteArray()
), to a bit string (toBitString()
), or to a
hex string (toHexString()
). A utility method toByteArrayFromBitString(java.lang.String, int)
converts a bit string directly to a byte array.
This class is immutable: once created, none of the methods modify the value.
Field Summary | |
---|---|
private int |
bitCount
|
private String |
bits
|
private static char[] |
Hexits
|
Constructor Summary | |
---|---|
protected |
BitString(String bits,
int bitCount)
|
Method Summary | |
---|---|
static BitString |
concat(BitString[] args)
Concatenates some BitStrings. |
static BitString |
createFromBitString(String s)
Creates a BitString representation out of a Bit String. |
static BitString |
createFromBytes(byte[] bytes)
Creates a BitString from an array of bytes. |
static BitString |
createFromHexString(String s)
Creates a BitString representation out of a Hex String. |
byte[] |
getAsByteArray()
|
int |
getBitCount()
|
String |
toBitString()
Returns this bit string as a bit string, such as "10110". |
static byte[] |
toByteArrayFromBitString(String bits,
int bitCount)
Converts a bit string to an array of bytes. |
String |
toHexString()
Converts this bit string to a hex string, such as "7AB". |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final char[] Hexits
private String bits
private int bitCount
Constructor Detail |
---|
protected BitString(String bits, int bitCount)
Method Detail |
---|
public static BitString createFromHexString(String s)
s
- a string, in hex notation
NumberFormatException
- if s
is invalid.public static BitString createFromBitString(String s)
s
- a string of 0s and 1s.
NumberFormatException
- if s
is invalid.public String toString()
toString
in class Object
public int getBitCount()
public byte[] getAsByteArray()
public String toBitString()
public String toHexString()
public static byte[] toByteArrayFromBitString(String bits, int bitCount)
public static BitString concat(BitString[] args)
args
- BitString[]public static BitString createFromBytes(byte[] bytes)
bytes
- Bytes
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |