LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.info
Class LyBitSet

java.lang.Object
  extended by leon.info.LyBitSet
All Implemented Interfaces:
java.lang.Cloneable

public final class LyBitSet
extends java.lang.Object
implements java.lang.Cloneable

This class adds methods to be used on BitSets. It's not an extension of the standard class java.util.BitSet because this class is final. Its only purpose is to add convenient methods for testing properties and to hold further optimizations.

See Also:
BitSet

Nested Class Summary
static class LyBitSet.Type
           
 
Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LyBitSet(LyBitSet.Type type, java.util.BitSet marks)
          Constructor.
LyBitSet(LyBitSet.Type type, java.lang.String[] specificMarks)
          Constructor.
 
Method Summary
 java.lang.Object clone()
          Creates a new object of the same class as this object.
 boolean equals(java.lang.Object object)
          Compares the current BitSet and the given BitSet values.
 boolean get(int mark)
          Gets the value of the bit with the specified index.
 java.util.BitSet getBitSet()
          Gets the java BitSet reference.
static int getCount(java.util.BitSet marks)
          Gives the number of bits set in a given bitset.
 java.util.BitSet getGenericMarks()
          Accessor to the generic marks attached to this instance.
 int getGenericMarksNumber()
          Gets number of generic marks according to bitset type.
 int getMark(java.lang.String markName)
          Gets mark index corresponding to the specific given mark name.
 int getMark(java.lang.String markName, boolean add)
          Gets mark index corresponding to the specific given mark name.
 java.lang.String getMarkName(int markIndex)
          Get mark name corresponding to a given mark value.
 int getSize()
          Gets the marks size.
 java.lang.String[] getSpecificMarks()
          Accessor to the specific marks attached to this instance (presented as an array of strings).
 LyBitSet.Type getType()
          Gets the BitSet type.
static boolean match(java.util.BitSet marks, java.util.BitSet testedMarks, boolean matchAll)
          Checks if given marks are set in a bitset.
 boolean match(java.util.BitSet testedMarks, boolean matchAll)
          Checks if given marks are set in the current bitset.
 void set(int mark)
          Sets the bit at the specified index to true.
 java.util.BitSet setGenericMarks(java.util.BitSet marks)
          Sets the specific marks attached to this instance (presented as an array of strings).
 java.util.BitSet setSpecificMarks(java.util.BitSet marks)
          Sets the specific marks attached to this instance.
 java.util.BitSet setSpecificMarks(java.lang.String[] marks)
          Sets the specific marks attached to this instance (presented as an array of strings).
 java.lang.String toString()
          Returns a string representation of this bit set.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Constructor Detail

LyBitSet

public LyBitSet(LyBitSet.Type type,
                java.util.BitSet marks)
Constructor. Initialize _type and _marks with the given values.

Parameters:
type - the BitSet type
marks - the bit set

LyBitSet

public LyBitSet(LyBitSet.Type type,
                java.lang.String[] specificMarks)
Constructor. Initialize _type and _marks with the given values.

Parameters:
type - the BitSet type
marks - the bit set
Method Detail

match

public static boolean match(java.util.BitSet marks,
                            java.util.BitSet testedMarks,
                            boolean matchAll)
Checks if given marks are set in a bitset.

Parameters:
marks - The reference bitset.
testedMarks - A set of bits to check with the reference bitset.
matchAll - Indicates if all marks must match or not.
Returns:
true if matchAll is true and if tested marks matches all reference marks or if matchAll is false and is at least one mark of the tested marks matches one mark of the reference marks.
Throws:
java.lang.IllegalArgumentException - if the reference marks set is null or if the testedMarks set is null or empty.

getCount

public static int getCount(java.util.BitSet marks)
Gives the number of bits set in a given bitset.

Parameters:
marks - the bitset.
Returns:
number of bits set in the bitset.

getType

public LyBitSet.Type getType()
Gets the BitSet type. Type possible values are:

Returns:
The type of the BitSet.

getBitSet

public java.util.BitSet getBitSet()
Gets the java BitSet reference.

Returns:
The reference to the java BitSet.

getSize

public int getSize()
Gets the marks size.

Returns:
Size of the marks.

get

public boolean get(int mark)
Gets the value of the bit with the specified index.

Parameters:
mark - the bit index
Returns:
the true if the bit with the specified index is set, false if it is not or if the current BitSet is null

set

public void set(int mark)
Sets the bit at the specified index to true.

Parameters:
mark - the index of the bit to set

match

public boolean match(java.util.BitSet testedMarks,
                     boolean matchAll)
Checks if given marks are set in the current bitset.

Parameters:
testedMarks - the set of bits to check.
matchAll - Indicates if all marks must match or not.
Returns:
true if matchAll is true and if all marks match or if matchAll is false and that at least one mark match, false otherwise.

clone

public java.lang.Object clone()
Creates a new object of the same class as this object.

Overrides:
clone in class java.lang.Object
Returns:
The new created object.
Throws:
java.lang.InternalError - if the super.clone() method throws a CloneNotSupportedException.

toString

public java.lang.String toString()
Returns a string representation of this bit set. For every index for which this BitSet contains a bit in the set state, the decimal representation of that index is included in the result.
Example:
           BitSet drPepper = new BitSet();
 

Now drPepper.toString() returns "{}".

           drPepper.set(2);
 

Now drPepper.toString() returns "{2}".

           drPepper.set(4);
           drPepper.set(10);
 

Now drPepper.toString() returns "{2, 4, 10}".

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this bit set.

equals

public boolean equals(java.lang.Object object)
Compares the current BitSet and the given BitSet values.

Overrides:
equals in class java.lang.Object
Parameters:
object - object to compare to
Returns:
true if the two BitSets have exactly the same bits sets to true, false otherwise.

getMark

public int getMark(java.lang.String markName,
                   boolean add)
Gets mark index corresponding to the specific given mark name. Marks are represented as bits in a bitset. Each mark has a bit position assigned to it. This mark allows to retrieve this bit value by the name of the mark.

Parameters:
markName - Name of the mark.
add - indicates if the.mark must be added if it doesn't exit
Returns:
Returns mark value (bit position in a bits set)
See Also:
LyFieldInfo.getMarkName(int)

getMark

public int getMark(java.lang.String markName)
Gets mark index corresponding to the specific given mark name. Marks are represented as bits in a bitset. Each mark has a bit position assigned to it. This mark allows to retrieve this bit value by the name of the mark.

Parameters:
markName - Name of the mark.
Returns:
Returns mark value (bit position in a bits set)
See Also:
LyFieldInfo.getMarkName(int)

getMarkName

public java.lang.String getMarkName(int markIndex)
Get mark name corresponding to a given mark value.

Parameters:
markIndex - Mark value (index of a bit in a bits set).
Returns:
Corresponding mark name.

getGenericMarks

public java.util.BitSet getGenericMarks()
Accessor to the generic marks attached to this instance.


setGenericMarks

public java.util.BitSet setGenericMarks(java.util.BitSet marks)
Sets the specific marks attached to this instance (presented as an array of strings).


getSpecificMarks

public java.lang.String[] getSpecificMarks()
Accessor to the specific marks attached to this instance (presented as an array of strings).


setSpecificMarks

public java.util.BitSet setSpecificMarks(java.lang.String[] marks)
Sets the specific marks attached to this instance (presented as an array of strings).


setSpecificMarks

public java.util.BitSet setSpecificMarks(java.util.BitSet marks)
Sets the specific marks attached to this instance.


getGenericMarksNumber

public int getGenericMarksNumber()
Gets number of generic marks according to bitset type.

Returns:
Number of generic marks.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com