Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derbyTesting.unitTests.util
Class BitUtil  view BitUtil download BitUtil.java

java.lang.Object
  extended byorg.apache.derbyTesting.unitTests.util.BitUtil

public class BitUtil
extends java.lang.Object

This class provides utility methods for converting byte arrays to hexidecimal Strings and manipulating BIT/BIT VARYING values as a packed vector of booleans.

The BIT/BIT VARYING methods are 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:


Field Summary
private static char[] hex_table
           
 
Constructor Summary
BitUtil()
           
 
Method Summary
static byte[] clear(byte[] bytes, int position)
          Clear the bit at the specified position
static boolean get(byte[] bytes, int position)
          Check to see if the specified bit is set
static java.lang.String hexDump(byte[] data)
          Convert a byte array to a human-readable String for debugging purposes.
static byte[] set(byte[] bytes, int position)
          Set the bit at the specified position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hex_table

private static char[] hex_table
Constructor Detail

BitUtil

public BitUtil()
Method Detail

set

public static byte[] set(byte[] bytes,
                         int position)
Set the bit at the specified position


clear

public static byte[] clear(byte[] bytes,
                           int position)
Clear the bit at the specified position


get

public static boolean get(byte[] bytes,
                          int position)
Check to see if the specified bit is set


hexDump

public static java.lang.String hexDump(byte[] data)
Convert a byte array to a human-readable String for debugging purposes.