Class BitString
-
- All Implemented Interfaces:
DataObject,Serializable
- Direct Known Subclasses:
BitStringWithNamedBits
public class BitString extends AbstractDataObject
Represents ASN.1 BIT STRING types.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BitStringclear()Clears all bits in this bit string.BitStringclear(int bitInteger)Clears the bit for the given number to false.BitStringclone()Constructs a copy of this.static BitStringcopyOf(BitString from)Creates a new object of this type, initialising its field values from those of the given object.booleanequals(Object obj)Compares some other object to this one for equality by value (not reference).booleanget(int bitInteger)Gets whether the bit for the given number is set or not.inthashCode()Gets a hash code value for this object.intlength()Returns the number of bits represented by this bit string.intnextSetBit(int fromIndex)Returns the index of the first bit that is set to true that occurs on or after the specified starting index.BitStringset(int bitInteger)Sets the bit for the given number to true.StringtoString()Returns a string describing this set of bits, using numbers for bits.-
Methods inherited from class com.opencloud.util.AbstractDataObject
checkModify, isReadOnly, setReadOnly
-
-
-
-
Field Detail
-
bitSet
protected BitSet bitSet
Set of bit values.
-
-
Method Detail
-
length
public int length()
Returns the number of bits represented by this bit string.- Returns:
- int length
-
get
public boolean get(int bitInteger)
Gets whether the bit for the given number is set or not.- Parameters:
bitInteger- the number of the bit to be got- Returns:
- whether the bit is set
-
set
public BitString set(int bitInteger)
Sets the bit for the given number to true.- Parameters:
bitInteger- the number of the bit to be set- Returns:
- this
-
clear
public BitString clear()
Clears all bits in this bit string.- Returns:
- this
-
clear
public BitString clear(int bitInteger)
Clears the bit for the given number to false.- Parameters:
bitInteger- the number of the bit to be cleared- Returns:
- this
-
nextSetBit
public int nextSetBit(int fromIndex)
Returns the index of the first bit that is set to true that occurs on or after the specified starting index. If no such bit exists then -1 is returned. To iterate over the true bits in a BitSet, use the following loop: for(int i=bs.nextSetBit(0); i>=0; i=bs.nextSetBit(i+1)) { // operate on index i here }
-
toString
public String toString()
Returns a string describing this set of bits, using numbers for bits. For example, "{1,3,4}" could be the string for a set of four bits in which the second bit is currently not set. The bits are described in order.
-
equals
public boolean equals(Object obj)
Compares some other object to this one for equality by value (not reference).
-
hashCode
public int hashCode()
Gets a hash code value for this object.
-
clone
public BitString clone()
Constructs a copy of this.- Specified by:
clonein interfaceDataObject- Specified by:
clonein classAbstractDataObject- Returns:
- a new object that is a deep copy of this object; for immutable objects, the same object may optionally be returned.
-
-