public class BitUtil
extends java.lang.Object
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:
Modifier and Type | Field and Description |
---|---|
private static char[] |
hex_table |
Constructor and Description |
---|
BitUtil() |
Modifier and Type | Method and Description |
---|---|
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
|
public static byte[] set(byte[] bytes, int position)
bytes
- the byte arrayposition
- the bit to set, starting from zerojava.lang.IndexOutOfBoundsException
- on bad positionpublic static byte[] clear(byte[] bytes, int position)
bytes
- the byte arrayposition
- the bit to clear, starting from zerojava.lang.IndexOutOfBoundsException
- on bad positionpublic static boolean get(byte[] bytes, int position)
bytes
- the byte arrayposition
- the bit to check, starting from zerojava.lang.IndexOutOfBoundsException
- on bad positionpublic static java.lang.String hexDump(byte[] data)
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.