Home » db-derby-10.5.3.0 » org.apache.derby.iapi.services.io » [javadoc | source]
org.apache.derby.iapi.services.io
public final class: FormatableBitSet [javadoc | source]
java.lang.Object
   org.apache.derby.iapi.services.io.FormatableBitSet

All Implemented Interfaces:
    Cloneable, Formatable

FormatableBitSet is implemented as a packed array of bytes.
Constructor:
 public FormatableBitSet() 
 public FormatableBitSet(int numBits) 
 public FormatableBitSet(byte[] newValue) 
 public FormatableBitSet(FormatableBitSet original) 
    Copy constructor
    Parameters:
    original - the FormatableBitSet to make a copy from
Method from org.apache.derby.iapi.services.io.FormatableBitSet Summary:
and,   anySetBit,   anySetBit,   clear,   clear,   clone,   compare,   equals,   get,   getByteArray,   getLength,   getLengthInBytes,   getNumBitsSet,   getTypeFormatId,   grow,   hashCode,   invariantHolds,   isSet,   maxBitsForSpace,   or,   readExternal,   set,   shrink,   size,   toString,   writeExternal,   xor
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.derby.iapi.services.io.FormatableBitSet Detail:
 public  void and(FormatableBitSet otherBit) 
    Bitwise AND this FormatableBitSet with another FormatableBitSet. The result is stored in this bitset. The operand is unaffected. A null operand is treated as an empty bitset (i.e. clearing this bitset). A bitset that is smaller than its operand is expanded to the same size.
 public int anySetBit() 
    If any bit is set, return the zero-based bit index of the first bit that is set. If no bit is set, return -1. By using anySetBit() and anySetBit(beyondBit), one can quickly go thru the entire bit array to return all set bit.
 public int anySetBit(int beyondBit) 
    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.
 public  void clear() 
    Clear all the bits in this FormatableBitSet
 public  void clear(int position) 
    Bit clear
 public Object clone() 
 public int compare(FormatableBitSet other) 
    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.
 public boolean equals(FormatableBitSet other) 
    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.
 public final boolean get(int position) 
    Bit get -- alias for isSet()
 public byte[] getByteArray() 
    Get the value of the byte array
 public int getLength() 
    Get the length in bits
 public int getLengthInBytes() 
    Get the length in bytes of a Bit value
 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 so that it contains at least N bits. If the bitset already has more than n bits, this is a noop. Negative values of n are not allowed. ASSUMPTIONS: that all extra bits in the last byte are zero.
 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 invariantHolds() 
    This method returns true if the following conditions hold: 1. The number of bits in the bitset will fit into the allocated byte array. 2. 'lengthAsBits' and 'bitsInLastByte' are consistent. 3. All unused bits in the byte array are unset. This represents an invariant for the class, so this method should always return true. The method is public, but is primarily intended for testing and ASSERTS.
 public final boolean isSet(int position) 
    Bit isSet
 public static int maxBitsForSpace(int numBytes) 
    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.
 public  void or(FormatableBitSet otherBit) 
    Bitwise OR this FormatableBitSet with another FormatableBitSet. The result is stored in this bitset. The operand is unaffected. A null operand is treated as an empty bitset (i.e. a noop). A bitset that is smaller than its operand is expanded to the same size.
 public  void readExternal(ObjectInput in) throws IOException 
    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.

 public  void set(int position) 
    Bit set
 public  void shrink(int n) 
    Shrink (narrow) a FormatableBitSet to N bits. N may not be larger than the current bitset size, or negative.
 public int size() 
    Get the length in bits -- alias for getLength()
 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) throws IOException 
    Format:
    • int length in bits
    • byte[]
 public  void xor(FormatableBitSet otherBit) 
    Bitwise XOR this FormatableBitSet with another FormatableBitSet. The result is stored in this bitset. The operand is unaffected. A null operand is treated as an empty bitset (i.e. a noop). A bitset that is smaller than its operand is expanded to the same size.