Lvg Java
2006p Version

gov.nih.nlm.nls.lvg.Lib
Class BitMaskBase

java.lang.Object
  extended by gov.nih.nlm.nls.lvg.Lib.BitMaskBase
Direct Known Subclasses:
Category, Flow, Gender, Inflection, Tag

public class BitMaskBase
extends java.lang.Object

This class is the base class for Bit Mask operation. It's child class which inherits (extends) from this class need to:

  1. declare bitStr_
  2. define the correspond BIT

History:

Version:
V-2006p
Author:
NLM NLS Development Team
See Also:
Design document

Field Summary
static long[] mask_
           
protected static int MAX_BIT
          the maximum number of bits used.
 
Constructor Summary
  BitMaskBase()
          Create a new BitMaskBase object
  BitMaskBase(long value)
          Create a new BitMaskBase object, using a long integer value
protected BitMaskBase(long value, long allBitValue, java.util.Vector[] bitStr)
           
protected BitMaskBase(long allBitValue, java.util.Vector[] bitStr)
           
 
Method Summary
 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.Vector[] 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.Vector[] 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.Vector[] bitStr)
          Get the combined bit string (abbreviation) of a specified value.
protected static long ToValue(java.lang.String valueStr, java.util.Vector[] bitStr)
          Convert a combined value string to a long value.
protected static java.util.Vector ToValues(long value, int maxBitUsed)
          Get a Vector include all values from the combined value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BIT

protected static final int MAX_BIT
the maximum number of bits used. It is used in it's child classes

See Also:
Constant Field Values

mask_

public static long[] mask_
Constructor Detail

BitMaskBase

public BitMaskBase()
Create a new BitMaskBase object


BitMaskBase

public BitMaskBase(long value)
Create a new BitMaskBase object, using a long integer value


BitMaskBase

protected BitMaskBase(long allBitValue,
                      java.util.Vector[] bitStr)

BitMaskBase

protected BitMaskBase(long value,
                      long allBitValue,
                      java.util.Vector[] bitStr)
Method Detail

GetBitValue

public static long GetBitValue(int bitNum)
Get the long value of mask at a specified bit

Parameters:
bitNum - the bit number that is interested
Returns:
a long value of the mask at bit number

GetBitIndex

public static int GetBitIndex(long value)
Convert from a long value to a bit index

Parameters:
value - long value to find for bit index
Returns:
the bit index of value, or -1 if no match

Contains

public static boolean Contains(long container,
                               long value)
Check if a given container object contains a object with a given value. Contain means all bits are true in the tested object are also true in the container object

Parameters:
container - a long value of the conatiner
value - a long value of the testing object
Returns:
true or false if this object contains or does not contain the object with the given value

ToValues

protected static java.util.Vector ToValues(long value,
                                           int maxBitUsed)
Get a Vector include all values from the combined value. For example, a value of 129 will return a vector contains two elements (Long) with value of 1 and 128.

Parameters:
value - combined value
Returns:
a Vector include all values from the combined value

SetValue

public void SetValue(long value)
Set the long value of htis object

Parameters:
value - long value to be assigned

GetBitFlag

public boolean GetBitFlag(int maskIndex)
Get the bit value (true or false) at the specified index of this object

Parameters:
maskIndex - index of the bit to find it's value
Returns:
value (true or false) of the specified bit

SetBitFlag

public void SetBitFlag(int maskIndex,
                       boolean flag)
Set the bit value of the specified bit for this object

Parameters:
maskIndex - index of the bit to be set
flag - value of the bit to be set (true or false).

GetValue

public long GetValue()
Get the long value of this object

Returns:
long value of this object

GetName

public java.lang.String GetName()
Get the String value of this object

Returns:
string value of this object

Contains

public boolean Contains(long value)
Check if current object contains a object with a given value. Contain means all bits are true in the tested object are also true in the container (this) object

Parameters:
value - a long value of the testing object
Returns:
true or false if this object contains or does not contain the object with the given value

ToValue

protected static long ToValue(java.lang.String valueStr,
                              java.util.Vector[] bitStr)
Convert a combined value string to a long value.

Parameters:
valueStr - names of bits for finding it's long value
Returns:
a long value of the specified name

ToName

protected static java.lang.String ToName(long value,
                                         long allBitValue,
                                         java.util.Vector[] bitStr)
Get the combined bit string (abbreviation) of a specified value.

Parameters:
value - nubmer for finding it's combined name
Returns:
name in a String format of an bitMask object

Enumerate

protected static long Enumerate(java.lang.String valueStr,
                                java.util.Vector[] bitStr)
Get the long value for one single name (no combine names of bits).

Parameters:
valueStr - name of a bit for finding it's long value
Returns:
a long value of the specified name

GetBitName

protected static java.lang.String GetBitName(int bitValue,
                                             int index,
                                             java.util.Vector[] bitStr)
Get the name at index order of a specified bit (single).

Parameters:
bitValue - bit nubmer for finding it's name
index - the order index of the name in bitStr_[]
Returns:
name at index order of the bit specified

main

public static void main(java.lang.String[] args)
Test driver for this class


Lvg Java
2006p Version

Submit a bug or feature

Copyright © 2006p National Library of Medicine