|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.iapi.services.io.FormatableBitSet
FormatableBitSet is implemented as a packed array of bytes.
Field Summary | |
private short |
bitsInLastByte
|
private static char[] |
decodeArray
|
private int |
lengthAsBits
|
private byte[] |
value
Bits are stored as an array of bytes. |
Constructor Summary | |
FormatableBitSet()
Niladic Constructor |
|
FormatableBitSet(byte[] newValue)
Constructs a Bit from an array of bytes. |
|
FormatableBitSet(byte[] newValue,
int numBits)
Constructs a Bit from an array of bytes. |
|
FormatableBitSet(FormatableBitSet original)
Copy constructor |
|
FormatableBitSet(int numBits)
Constructs a Bit with the initial number of bits |
Method Summary | |
void |
and(FormatableBitSet otherBit)
Bitwise AND this Bit with another Bit. |
int |
anySetBit()
If any bit is set, return the bit number of a bit that is set. |
int |
anySetBit(int beyondBit)
Like anySetBit(), but return any set bit whose number is bigger than beyondBit. |
private int |
calculateLength(int realByteLength)
|
void |
clear()
Clear all the bits in this FormatableBitSet |
void |
clear(int position)
Bit clear |
java.lang.Object |
clone()
|
int |
compare(FormatableBitSet other)
Bit comparison. |
FormatableBitSet |
concatenate(FormatableBitSet other)
Bit concatenation. |
boolean |
equals(FormatableBitSet other)
Bit equivalence. |
boolean |
get(int position)
Bit get -- alias for isSet() |
byte[] |
getByteArray()
Get the value of the byte array |
int |
getLength()
Get the length in bits |
int |
getLengthInBytes()
Get the length in bytes of a Bit value |
int |
getNumBitsSet()
Get a count of the number of bits that are set. |
int |
getTypeFormatId()
Get the formatID which corresponds to this class. |
void |
grow(int n)
Grow (widen) a FormatableBitSet to N bis |
int |
hashCode()
Produce a hash code by putting the value bytes into an int, exclusive OR'ing if there are more than 4 bytes. |
private static byte |
hexCharToByte(char hexChar)
Translate a hex character to a byte. |
private void |
initializeBits(int numBits)
|
boolean |
isNull()
Set the value of the byte array |
boolean |
isSet(int position)
Bit isSet |
static int |
maxBitsForSpace(int numBytes)
Statically calculates how many bits can fit into the number of bytes if this Bit object is externalized. |
private static short |
numBitsInLastByte(int bits)
Figure out how many bits are in the last byte from the total number of bits. |
protected static int |
numBytesFromBits(int bits)
Figure out how many bytes are needed to store the input number of bits. |
void |
or(FormatableBitSet otherBit)
Bitwise OR this Bit with another Bit. |
void |
readExternal(java.io.ObjectInput in)
Note: gracefully handles zero length bits -- will create a zero length array with no bits being used. |
void |
readExternalFromArray(ArrayInputStream in)
|
void |
set(int position)
Bit set |
FormatableBitSet |
shrink(int n)
Shrink (narrow) a FormatableBitSet to N bits |
int |
size()
Get the length in bits -- alias for getLength() |
java.lang.String |
toString()
Format the string into BitSet format: {0, 2, 4, 8} if bits 0, 2, 4, 8 are set. |
void |
writeExternal(java.io.ObjectOutput out)
Format: int length in bits byte[] |
void |
xor(FormatableBitSet set)
Logically XORs this FormatableBitSet with the specified FormatableBitSet. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private byte[] value
private short bitsInLastByte
private transient int lengthAsBits
private static char[] decodeArray
Constructor Detail |
public FormatableBitSet()
public FormatableBitSet(int numBits)
public FormatableBitSet(byte[] newValue)
newValue
- The array of bytes to make up the new Bitpublic FormatableBitSet(byte[] newValue, int numBits)
newValue
- The array of bytes to make up the new BitnumBits
- The number of bitspublic FormatableBitSet(FormatableBitSet original)
original
- the FormatableBitSet to make a copy fromMethod Detail |
private void initializeBits(int numBits)
public java.lang.Object clone()
public int getLengthInBytes()
public int getLength()
private int calculateLength(int realByteLength)
public int size()
public byte[] getByteArray()
public boolean isNull()
public void grow(int n)
n
- The number of bits you want. The bits are
always added as 0 and are appended to the
least significant end of the bit array.
ASSUMPTIONS: that all extra bits in the last byte
are zero.public FormatableBitSet shrink(int n)
n
- The number of bits the caller wants. The
bits are always removed from the
least significant end of the bit array.public boolean equals(FormatableBitSet other)
other
- the other bit to compare to
public int compare(FormatableBitSet other)
other
- the other bit to compare to
public FormatableBitSet concatenate(FormatableBitSet other)
other
- the other bit to append to this
public int hashCode()
public final boolean isSet(int position)
position
- the bit to checkpublic final boolean get(int position)
position
- the bit to checkpublic void set(int position)
position
- the bit to setpublic void clear(int position)
position
- the bit to clearpublic void clear()
protected static int numBytesFromBits(int bits)
bits
- bits
private static short numBitsInLastByte(int bits)
bits
- bits
private static byte hexCharToByte(char hexChar)
hexChar
- A character with the value [0-9a-fA-F].
public java.lang.String toString()
public static int maxBitsForSpace(int numBytes)
public int anySetBit()
public int anySetBit(int beyondBit)
beyondBit
- only look at bit that is greater than this bit number
public void or(FormatableBitSet otherBit)
otherBit
- the other BitBit#or
public void and(FormatableBitSet otherBit)
otherBit
- the other BitBit#or
public void xor(FormatableBitSet set)
set
- The FormatableBitSet to be XORed with.public int getNumBitsSet()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
Externalizable.writeExternal(java.io.ObjectOutput)
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
WARNING: this method cannot be changed w/o changing SQLBit because SQLBit calls this directly w/o calling read/writeObject(), so the format id is not stored in that case.
readExternal
in interface java.io.Externalizable
java.io.IOException
Externalizable.readExternal(java.io.ObjectInput)
public void readExternalFromArray(ArrayInputStream in) throws java.io.IOException
java.io.IOException
public int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |