public class HexToBinaryConverter
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
HexToBinaryConverter.Gbfhd_tuple
For return results from getBytesFromHexDigits()
|
Modifier and Type | Field and Description |
---|---|
static int |
BYTE_MASK |
static char |
HIGH_BYTE_MASK |
static char |
LOW_BYTE_MASK |
static int |
LOWER_A |
static int |
LOWER_BYTE_MASK |
static int |
LOWER_F |
static byte |
LOWER_X |
static int |
NIBBLE_MASK |
static int |
NINE |
static byte |
SINGLE_QUOTE |
static int |
SQL_LITERAL_OVERHEAD |
static int |
UPPER_A |
static int |
UPPER_F |
static byte |
UPPER_X |
static int |
ZERO |
Constructor and Description |
---|
HexToBinaryConverter() |
Modifier and Type | Method and Description |
---|---|
static void |
byte_to_hexits(byte theByte,
java.nio.CharBuffer charBuffer)
Convert a byte into two hex digits
|
static void |
char_to_hexits(char theChar,
java.nio.CharBuffer charBuffer)
Convert a character into four hex digits
|
static void |
encodeHexits(byte[] sourceBytes,
byte[] targetBytes,
int sourceOffset,
int sourceLength,
int targetOffset)
Convert a byte array to hex digits.
|
int |
getBytesFromHexDigits(byte[] targetBytes)
Read the sequence of 1-byte hex chars which are inside this converter.
|
HexToBinaryConverter.Gbfhd_tuple |
getBytesFromHexDigits(byte[] targetBytes,
HexToBinaryConverter.Gbfhd_tuple retval)
Read the sequence of 1-byte hex chars which are inside this converter.
|
void |
setBytes(byte[] bytes,
int startOffset,
int length)
Initialize with an array of source digits which are bytes.
|
void |
setChars(char[] chars,
int startOffset,
int length)
Initialize with an array of source digits which are chars.
|
void |
setString(java.lang.String string,
int startOffset,
int length)
Initialize with a string of source digits.
|
static java.lang.String |
varbinary_to_string(byte[] sourceBytes,
java.lang.String charsetName)
System function varbinary_to_string() to convert a varbinary value into a
varchar using the indicated character encoding.
|
static java.lang.String |
varbinary_to_varchar(byte[] sourceBytes)
System function varbinary_to_varchar() to convert a varbinary value into a
varchar.
|
static byte[] |
varchar_to_varbinary(java.lang.String sourceString)
System function varchar_to_varbinary() to convert a char/varchar value into a
varbinary, two hex digits per byte.
|
public static final int ZERO
public static final int NINE
public static final int LOWER_A
public static final int LOWER_F
public static final int UPPER_A
public static final int UPPER_F
public static final int BYTE_MASK
public static final char HIGH_BYTE_MASK
public static final char LOW_BYTE_MASK
public static final int LOWER_BYTE_MASK
public static final int NIBBLE_MASK
public static final byte SINGLE_QUOTE
public static final byte LOWER_X
public static final byte UPPER_X
public static final int SQL_LITERAL_OVERHEAD
public static byte[] varchar_to_varbinary(java.lang.String sourceString) throws java.sql.SQLException
sourceString
- The string to be converted.java.sql.SQLException
- if the sourceString isn't a valid hex string or SQL BINARY literal.public static java.lang.String varbinary_to_varchar(byte[] sourceBytes)
sourceBytes
- The bytes to convert into a hex stringjava.sql.SQLException
- on errorpublic static java.lang.String varbinary_to_string(byte[] sourceBytes, java.lang.String charsetName) throws java.sql.SQLException
sourceBytes
- The bytes to convert into a hex stringcharsetName
- Name of a java.nio.charset.Charset. Identifies the character encoding used to convert the bytes into characters.java.sql.SQLException
- on errorpublic static void char_to_hexits(char theChar, java.nio.CharBuffer charBuffer)
theChar
- The character to convertcharBuffer
- An evolving CharBuffer into which to write the results.public static void byte_to_hexits(byte theByte, java.nio.CharBuffer charBuffer)
theByte
- The byte to convertcharBuffer
- An evolving CharBuffer into which to write the results.public static void encodeHexits(byte[] sourceBytes, byte[] targetBytes, int sourceOffset, int sourceLength, int targetOffset)
sourceBytes
- The byte array to be converted.targetBytes
- Where to write the converted digits.sourceOffset
- The offset of the first relevant byte in the source array.sourceLength
- The number of source bytes to convert.targetOffset
- The first byte of the target array to fill with converted digits.java.lang.IllegalArgumentException
- if the target array won't accomodate the result.public void setBytes(byte[] bytes, int startOffset, int length)
bytes
- The source digits.startOffset
- Offset of the first digitlength
- Length of the digit stringpublic void setChars(char[] chars, int startOffset, int length)
chars
- The source digits.startOffset
- Offset of the first digitlength
- Length of the digit stringpublic void setString(java.lang.String string, int startOffset, int length)
string
- The source digits.startOffset
- Offset of the first digitlength
- Length of the digit stringpublic int getBytesFromHexDigits(byte[] targetBytes) throws java.sql.SQLException
targetBytes
- The result array to merge intojava.sql.SQLException
- If the source is not an even number of hex digits.public HexToBinaryConverter.Gbfhd_tuple getBytesFromHexDigits(byte[] targetBytes, HexToBinaryConverter.Gbfhd_tuple retval) throws java.sql.SQLException
targetBytes
- The result array to merge intojava.sql.SQLException
- If the source is not an even number of hex digits.Copyright (C) 2003-2021 SQLstream, Inc.