Class Hierarchy    Previous  Next  Index

Class COM.cloudscape.util.BitUtil

java.lang.Object
    |
    +----COM.cloudscape.util.BitUtil

public class BitUtil
extends java.lang.Object
Copyright © 1998-2000, Informix Software, Inc. All rights reserved.

This class provides some basic static methods for manipulating a Cloudscape BIT or BIT VARYING field as a packed vector of booleans. It is modeled after some methods in the java.util.BitSet class. An alternative to using a SQL BIT (VARYING) column in conjunction with the methods provided herein to provide bit manipulation would be to use a serialized java.util.BitSet column instead.

This class contains the following static methods:

Since these methods effectively allow a SQL BIT to be considered as an array of booleans, all offsets (position parameters) are zero based. So if you want to set the first bit of a BIT type, you would use set(MyBitColumn, 0) .

Examples:


Constructor Index

 o BitUtil()
 

Method Index

 o clear(byte[], int)
Clear the bit at the specified position
 o get(byte[], int)
Check to see if the specified bit is set
 o set(byte[], int)
Set the bit at the specified position

Constructor Detail

 o BitUtil
public BitUtil()

Method Detail

 o set
public static byte[] set(byte bytes[],
                         int position)
          Set the bit at the specified position
Parameters:
bytes - the byte array
position - the bit to set, starting from zero
Returns:
the byte array with the set bit
Throws:
java.lang.IndexOutOfBoundsException - on bad position
 o clear
public static byte[] clear(byte bytes[],
                           int position)
          Clear the bit at the specified position
Parameters:
bytes - the byte array
position - the bit to clear, starting from zero
Returns:
the byte array with the cleared bit
Throws:
java.lang.IndexOutOfBoundsException - on bad position
 o get
public static boolean get(byte bytes[],
                          int position)
          Check to see if the specified bit is set
Parameters:
bytes - the byte array
position - the bit to check, starting from zero
Returns:
true/false
Throws:
java.lang.IndexOutOfBoundsException - on bad position

  Class Hierarchy    Previous  Next  Index