org.esa.beam.util
Class BitSetter

java.lang.Object
  extended by org.esa.beam.util.BitSetter

public class BitSetter
extends Object

Static function to manipulate bits inside an int or long.

Since:
4.1
Author:
marcoz

Constructor Summary
BitSetter()
           
 
Method Summary
static boolean isFlagSet(int flags, int bitIndex)
          Tests if a flag with the given index is set in a 32-bit collection of flags.
static boolean isFlagSet(long flags, int bitIndex)
          Tests if a flag with the given index is set in a 64-bit collection of flags.
static int setFlag(int flags, int bitIndex)
          Sets a flag with the given index in a 32-bit collection of flags.
static int setFlag(int flags, int bitIndex, boolean cond)
          Sets a flag with the given index in a 32-bit collection of flags if a given condition is true.
static long setFlag(long flags, int bitIndex)
          Sets a flag with the given index in a 64-bit collection of flags.
static long setFlag(long flags, int bitIndex, boolean cond)
          Sets a flag with the given index in a 64-bit collection of flags if a given condition is true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitSetter

public BitSetter()
Method Detail

isFlagSet

public static boolean isFlagSet(int flags,
                                int bitIndex)
Tests if a flag with the given index is set in a 32-bit collection of flags.

Parameters:
flags - a collection of a maximum of 32 flags
bitIndex - the zero-based index of the flag to be tested
Returns:
true if the flag is set

isFlagSet

public static boolean isFlagSet(long flags,
                                int bitIndex)
Tests if a flag with the given index is set in a 64-bit collection of flags.

Parameters:
flags - a collection of a maximum of 64 flags
bitIndex - the zero-based index of the flag to be tested
Returns:
true if the flag is set

setFlag

public static int setFlag(int flags,
                          int bitIndex)
Sets a flag with the given index in a 32-bit collection of flags.

Parameters:
flags - a collection of a maximum of 32 flags
bitIndex - the zero-based index of the flag to be set
Returns:
the collection of flags with the given flag set

setFlag

public static long setFlag(long flags,
                           int bitIndex)
Sets a flag with the given index in a 64-bit collection of flags.

Parameters:
flags - a collection of a maximum of 64 flags
bitIndex - the zero-based index of the flag to be set
Returns:
the collection of flags with the given flag set

setFlag

public static int setFlag(int flags,
                          int bitIndex,
                          boolean cond)
Sets a flag with the given index in a 32-bit collection of flags if a given condition is true.

Parameters:
flags - a collection of a maximum of 32 flags
bitIndex - the zero-based index of the flag to be set
cond - the condition
Returns:
the collection of flags with the given flag possibly set

setFlag

public static long setFlag(long flags,
                           int bitIndex,
                           boolean cond)
Sets a flag with the given index in a 64-bit collection of flags if a given condition is true.

Parameters:
flags - a collection of a maximum of 64 flags
bitIndex - the zero-based index of the flag to be set
cond - the condition
Returns:
the collection of flags with the given flag possibly set


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.