Class Hierarchy        Index

Class COM.cloudscape.util.BitUtil

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

public class BitUtil
extends Object
Copyright © 1998-1999, Cloudscape, 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

Constructors

 o BitUtil
 public BitUtil()

Methods

 o set
 public static byte[] set(byte bytes[],
                          int position) throws Exception
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: Exception
on bad position
 o clear
 public static byte[] clear(byte bytes[],
                            int position) throws Exception
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: Exception
on bad position
 o get
 public static boolean get(byte bytes[],
                           int position) throws Exception
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: Exception
on bad position

  Class Hierarchy        Index