|
|||||||||
| Home >> All >> org >> apache >> derbyTesting >> unitTests >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derbyTesting.unitTests.util
Class BitUtil

java.lang.Objectorg.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:
- void set(byte[] bytes, int position) to set a bit
- void clear(byte[] bytes, int position) to clear a bit
- boolean get(byte[] bytes, int position) to get the bit status
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:
- SELECT BitUtil::get(bitcol, 2) FROM mytab
- UPDATE mytab SET bitcol = BitUtil::set(bitcol, 2)
- UPDATE mytab SET bitcol = BitUtil::clear(bitcol, 2)
| 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.
|
|||||||||
| Home >> All >> org >> apache >> derbyTesting >> unitTests >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.derbyTesting.unitTests.util.BitUtil