org.pf.util
Class BitSet

java.lang.Object
  extended by org.pf.util.BitSet

public class BitSet
extends java.lang.Object

Represents a set of 8 bits and provides methods for convenient bit manipulation.

Version:
1.0
Author:
Manfred Duchrow

Constructor Summary
BitSet()
          Initializes the new instance with the default value 0.
BitSet(int initialValue)
          Initializes the new instance with the given value.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns true, if the given arguments equals the receiver.
 int getValue()
          Returns the byte value, that is the combination of the 8 bits.
 int hashCode()
          Returns the receiver's hash value.
 boolean isBitNotSet(int bit)
          Returns true, if the bit defined by the argument is not set.
 boolean isBitSet(int bit)
          Returns true, if the bit defined by the argument is set.
 void setBit(int bit)
          Sets the bit defined by the argument.
 void toggleBit(int bit)
          Switches a set bit to unset and a unset bit to set.
 java.lang.String toString()
          Returns the string representation of the receiver.
 void unsetBit(int bit)
          Unsets the bit defined by the argument.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitSet

public BitSet()
Initializes the new instance with the default value 0.


BitSet

public BitSet(int initialValue)
Initializes the new instance with the given value.

Method Detail

getValue

public int getValue()
Returns the byte value, that is the combination of the 8 bits.


isBitSet

public boolean isBitSet(int bit)
Returns true, if the bit defined by the argument is set.

Parameters:
bit - The bit to test ( 0 - 7 )

isBitNotSet

public boolean isBitNotSet(int bit)
Returns true, if the bit defined by the argument is not set.

Parameters:
bit - The bit to test ( 0 - 7 )

setBit

public void setBit(int bit)
Sets the bit defined by the argument.

Parameters:
bit - The bit to manipulate ( 0 - 7 )

unsetBit

public void unsetBit(int bit)
Unsets the bit defined by the argument.

Parameters:
bit - The bit to manipulate ( 0 - 7 )

toggleBit

public void toggleBit(int bit)
Switches a set bit to unset and a unset bit to set.

Parameters:
bit - The bit to toggle ( 0 - 7 )

toString

public java.lang.String toString()
Returns the string representation of the receiver.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Returns true, if the given arguments equals the receiver.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns the receiver's hash value.

Overrides:
hashCode in class java.lang.Object