public class BitMaskBase
extends java.lang.Object
History:
Modifier and Type | Field and Description |
---|---|
static long[] |
MASK |
protected static int |
MAX_BIT
the maximum number of bits used.
|
Modifier | Constructor and Description |
---|---|
|
BitMaskBase()
Create a new BitMaskBase object
|
|
BitMaskBase(long value)
Create a new BitMaskBase object, using a long integer value
|
protected |
BitMaskBase(long allBitValue,
java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr) |
protected |
BitMaskBase(long value,
long allBitValue,
java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr) |
Modifier and Type | Method and Description |
---|---|
boolean |
Contains(long value)
Check if current object contains a object with a given value.
|
static boolean |
Contains(long container,
long value)
Check if a given container object contains a object with a given value.
|
protected static long |
Enumerate(java.lang.String valueStr,
java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
Get the long value for one single name (no combine names of bits).
|
boolean |
GetBitFlag(int maskIndex)
Get the bit value (true or false) at the specified index of this object
|
static int |
GetBitIndex(long value)
Convert from a long value to a bit index
|
protected static java.lang.String |
GetBitName(int bitValue,
int index,
java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
Get the name at index order of a specified bit (single).
|
static long |
GetBitValue(int bitNum)
Get the long value of mask at a specified bit
|
java.lang.String |
GetName()
Get the String value of this object
|
long |
GetValue()
Get the long value of this object
|
static void |
main(java.lang.String[] args)
Test driver for this class
|
void |
SetBitFlag(int maskIndex,
boolean flag)
Set the bit value of the specified bit for this object
|
void |
SetValue(long value)
Set the long value of htis object
|
protected static java.lang.String |
ToName(long value,
long allBitValue,
java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
Get the combined bit string (abbreviation) of a specified value.
|
protected static long |
ToValue(java.lang.String valueStr,
java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
Convert a combined value string to a long value.
|
protected static java.util.Vector<java.lang.Long> |
ToValues(long value,
int maxBitUsed)
Get a Vector of Long - includes all values from the combined value.
|
protected static final int MAX_BIT
public static final long[] MASK
public BitMaskBase()
public BitMaskBase(long value)
value
- long value to find for bit indexprotected BitMaskBase(long allBitValue, java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
protected BitMaskBase(long value, long allBitValue, java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
public static long GetBitValue(int bitNum)
bitNum
- the bit number that is interestedpublic static int GetBitIndex(long value)
value
- long value to find for bit indexpublic static boolean Contains(long container, long value)
container
- a long value of the conatinervalue
- a long value of the testing objectprotected static java.util.Vector<java.lang.Long> ToValues(long value, int maxBitUsed)
value
- combined valuemaxBitUsed
- the max bitpublic void SetValue(long value)
value
- long value to be assignedpublic boolean GetBitFlag(int maskIndex)
maskIndex
- index of the bit to find it's valuepublic void SetBitFlag(int maskIndex, boolean flag)
maskIndex
- index of the bit to be setflag
- value of the bit to be set (true or false).public long GetValue()
public java.lang.String GetName()
public boolean Contains(long value)
value
- a long value of the testing objectprotected static long ToValue(java.lang.String valueStr, java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
valueStr
- names of bits for finding it's long valuebitStr
- a Vector of String - bitStrprotected static java.lang.String ToName(long value, long allBitValue, java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
value
- nubmer for finding it's combined nameallBitValue
- the value of all bit are usedbitStr
- a Vector of String - bitStrprotected static long Enumerate(java.lang.String valueStr, java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
valueStr
- name of a bit for finding it's long valuebitStr
- a Vector of String - bitStrprotected static java.lang.String GetBitName(int bitValue, int index, java.util.ArrayList<java.util.Vector<java.lang.String>> bitStr)
bitValue
- bit nubmer for finding it's nameindex
- the order index of the name in bitStr_[]bitStr
- a Vector of String - bitStrpublic static void main(java.lang.String[] args)
args
- arguments