| java.lang.Object org.apache.derby.iapi.services.io.FormatableBitSet
FormatableBitSet | final public class FormatableBitSet implements Formatable,Cloneable(Code) | | FormatableBitSet is implemented as a packed array of bytes.
author: Jamie -- originally coded by Jeff |
Method Summary | |
public void | and(FormatableBitSet otherBit) Bitwise AND this Bit with another Bit. | public int | anySetBit() If any bit is set, return the bit number of a bit that is set. | public int | anySetBit(int beyondBit) Like anySetBit(), but return any set bit whose number is bigger than
beyondBit. | public void | clear(int position) | public void | clear() | public Object | clone() | public int | compare(FormatableBitSet other) Bit comparison. | public FormatableBitSet | concatenate(FormatableBitSet other) Bit concatenation. | public boolean | equals(FormatableBitSet other) Bit equivalence. | final public boolean | get(int position) | public byte[] | getByteArray() | public int | getLength() Get the length in bits
The length in bits for this valueNOTE: could possibly be changed to a long. | public int | getLengthInBytes() | public int | getNumBitsSet() Get a count of the number of bits that are set. | public int | getTypeFormatId() Get the formatID which corresponds to this class. | public void | grow(int n) Grow (widen) a FormatableBitSet to N bis
Parameters: n - The number of bits you want. | public int | hashCode() Produce a hash code by putting the value bytes into an int, exclusive OR'ing
if there are more than 4 bytes. | public boolean | isNull() | final public boolean | isSet(int position) | public static int | maxBitsForSpace(int numBytes) Statically calculates how many bits can fit into the number of
bytes if this Bit object is externalized. | protected static int | numBytesFromBits(int bits) Figure out how many bytes are needed to
store the input number of bits. | public void | or(FormatableBitSet otherBit) Bitwise OR this Bit with another Bit. | public void | readExternal(ObjectInput in) Note: gracefully handles zero length
bits -- will create a zero length array
with no bits being used. | public void | readExternalFromArray(ArrayInputStream in) | public void | set(int position) | public FormatableBitSet | shrink(int n) Shrink (narrow) a FormatableBitSet to N bits
Parameters: n - The number of bits the caller wants. | public int | size() | public String | toString() Format the string into BitSet format: {0, 2, 4, 8} if bits 0, 2, 4, 8
are set. | public void | writeExternal(ObjectOutput out) | public void | xor(FormatableBitSet set) Logically XORs this FormatableBitSet with the specified FormatableBitSet. |
FormatableBitSet | public FormatableBitSet()(Code) | | Niladic Constructor
|
FormatableBitSet | public FormatableBitSet(int numBits)(Code) | | Constructs a Bit with the initial number of bits
|
FormatableBitSet | public FormatableBitSet(byte[] newValue)(Code) | | Constructs a Bit from an array of bytes. Assume
bytes are all being used.
Parameters: newValue - The array of bytes to make up the new Bit |
FormatableBitSet | public FormatableBitSet(byte[] newValue, int numBits)(Code) | | Constructs a Bit from an array of bytes.
Parameters: newValue - The array of bytes to make up the new Bit Parameters: numBits - The number of bits |
FormatableBitSet | public FormatableBitSet(FormatableBitSet original)(Code) | | Copy constructor
Parameters: original - the FormatableBitSet to make a copy from |
and | public void and(FormatableBitSet otherBit)(Code) | | Bitwise AND this Bit with another Bit.
Parameters: otherBit - the other Bit |
anySetBit | public int anySetBit()(Code) | | If any bit is set, return the bit number of a bit that is set.
If no bit is set, return -1;
the bit number of a bit that is set, or -1 if no bit is set |
anySetBit | public int anySetBit(int beyondBit)(Code) | | Like anySetBit(), but return any set bit whose number is bigger than
beyondBit. If no bit is set after beyondBit, -1 is returned.
By using anySetBit() and anySetBit(beyondBit), one can quickly go
thru the entire bit array to return all set bit.
Parameters: beyondBit - only look at bit that is greater than this bit number the bit number of a bit that is set, or -1 if no bit afterbeyondBit is set |
clear | public void clear(int position)(Code) | | Bit clear
Parameters: position - the bit to clear |
clear | public void clear()(Code) | | Clear all the bits in this FormatableBitSet
|
compare | public int compare(FormatableBitSet other)(Code) | | Bit comparison. Compare this with other.
Will always do a byte by byte compare.
Given 2 similar bits of unequal lengths (x and y),
where x.getLength() < y.getLength() but where:
x[0..x.getLength()] == y[0..x.getLength()]
then x < y.
Parameters: other - the other bit to compare to -1 - if other < this0 - if other == this1 - if other > this |
equals | public boolean equals(FormatableBitSet other)(Code) | | Bit equivalence. Compare this with other.
If the length is different, then cannot be
equal so short circuit. Otherwise, rely on
compare(). Note that two zero length bits are
considered equal.
Parameters: other - the other bit to compare to TRUE|FALSE |
get | final public boolean get(int position)(Code) | | Bit get -- alias for isSet()
Parameters: position - the bit to check |
getByteArray | public byte[] getByteArray()(Code) | | Get the value of the byte array
The value of the byte array |
getLength | public int getLength()(Code) | | Get the length in bits
The length in bits for this valueNOTE: could possibly be changed to a long. As iswe are restricted to 2^(31-3) -> 256meg insteadof 2^31 (Integer.MAX_VALUE) like other datatypes(or 2 gig). If it is ever changed to a longbe sure to change read/writeExternal which writeout the length in bits. |
getLengthInBytes | public int getLengthInBytes()(Code) | | Get the length in bytes of a Bit value
The length in bytes of this value |
getNumBitsSet | public int getNumBitsSet()(Code) | | Get a count of the number of bits that are set.
The number of bits that are set. |
getTypeFormatId | public int getTypeFormatId()(Code) | | Get the formatID which corresponds to this class.
the formatID of this class |
grow | public void grow(int n)(Code) | | Grow (widen) a FormatableBitSet to N bis
Parameters: n - The number of bits you want. The bits arealways added as 0 and are appended to theleast significant end of the bit array.ASSUMPTIONS: that all extra bits in the last byteare zero. |
hashCode | public int hashCode()(Code) | | Produce a hash code by putting the value bytes into an int, exclusive OR'ing
if there are more than 4 bytes.
the hash code |
isNull | public boolean isNull()(Code) | | Set the value of the byte array
The value of the byte array |
isSet | final public boolean isSet(int position)(Code) | | Bit isSet
Parameters: position - the bit to check |
maxBitsForSpace | public static int maxBitsForSpace(int numBytes)(Code) | | Statically calculates how many bits can fit into the number of
bytes if this Bit object is externalized. Only valid for this
implementation of Bit.
|
numBytesFromBits | protected static int numBytesFromBits(int bits)(Code) | | Figure out how many bytes are needed to
store the input number of bits.
Parameters: bits - bits the number of bytes |
or | public void or(FormatableBitSet otherBit)(Code) | | Bitwise OR this Bit with another Bit.
Parameters: otherBit - the other Bit |
readExternal | public void readExternal(ObjectInput in) throws IOException(Code) | | Note: gracefully handles zero length
bits -- will create a zero length array
with no bits being used. Fortunately
in.read() is ok with a zero length array
so no special code.
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.
See Also: java.io.Externalizable.readExternal |
set | public void set(int position)(Code) | | Bit set
Parameters: position - the bit to set |
shrink | public FormatableBitSet shrink(int n)(Code) | | Shrink (narrow) a FormatableBitSet to N bits
Parameters: n - The number of bits the caller wants. Thebits are always removed from theleast significant end of the bit array. |
size | public int size()(Code) | | Get the length in bits -- alias for getLength()
The length in bits for this value |
toString | public String toString()(Code) | | Format the string into BitSet format: {0, 2, 4, 8} if bits 0, 2, 4, 8
are set.
A new String containing the formatted Bit value |
xor | public void xor(FormatableBitSet set)(Code) | | Logically XORs this FormatableBitSet with the specified FormatableBitSet.
Parameters: set - The FormatableBitSet to be XORed with. |
|
|