|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.drizzle.jdbc.internal.common.Utils
public class Utils
User: marcuse Date: Feb 19, 2009 Time: 8:40:51 PM
| Constructor Summary | |
|---|---|
Utils()
|
|
| Method Summary | |
|---|---|
static byte |
byteArrayToByte(byte[] b)
|
static int |
byteArrayToInt(byte[] b)
convert a byte array to an int sums negative numbers since Integer.MIN_VALUE < -Integer.MAX_VALUE |
static long |
byteArrayToLong(byte[] b)
|
static short |
byteArrayToShort(byte[] b)
|
static byte[] |
copyRange(byte[] orig,
int from,
int to)
Copies from original byte array to a new byte array. |
static byte[] |
copyWithLength(byte[] orig,
int length)
Copies the original byte array content to a new byte array. |
static int |
countChars(java.lang.String str,
char chr)
Counts the number of occurrences of a character in a string. |
static java.util.List<java.lang.String> |
createQueryParts(java.lang.String query)
|
static byte[] |
encryptPassword(java.lang.String password,
byte[] seed)
encrypts a password protocol for authentication is like this: 1. |
static boolean |
isJava5()
Returns if it is a Java version up to Java 5. |
static boolean |
needsEscaping(byte b)
returns true if the byte b needs to be escaped |
static int |
packTime(long milliseconds)
packs the time portion of a millisecond time stamp into an int format: |
static java.lang.String |
sqlEscapeString(java.lang.String str)
escapes the given string, new string length is at most twice the length of str |
static java.lang.String |
stripQuery(java.lang.String query)
|
static long |
unpackTime(int packedTime)
unpacks an integer packed by packTime |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Utils()
| Method Detail |
|---|
public static boolean needsEscaping(byte b)
b - the byte to check
public static java.lang.String sqlEscapeString(java.lang.String str)
str - the string to escape
public static int countChars(java.lang.String str,
char chr)
str - the string to checkchr - the character to count
public static java.util.List<java.lang.String> createQueryParts(java.lang.String query)
public static java.lang.String stripQuery(java.lang.String query)
public static byte[] encryptPassword(java.lang.String password,
byte[] seed)
throws java.security.NoSuchAlgorithmException
password - the password to encryptseed - the seed to use
java.security.NoSuchAlgorithmException - if SHA1 is not available on the platform we are usingpublic static int packTime(long milliseconds)
The part of the day, stored in a 4 byte integer as follows: | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | | mS | mS | mS | mS | mS | mS | mS | mS | | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | | mS | mS | mS | mS | mS | mS | mS | SS | | 15 | 14 | 13 | 12 | 11 | 10 | 09 | 08 | | SS | SS | SS | SS | SS | MM | MM | MM | | 07 | 06 | 05 | 04 | 03 | 02 | 01 | 00 | | MM | MM | MM | HH | HH | HH | HH | HH |
milliseconds - the milliseconds to pack
public static long unpackTime(int packedTime)
packedTime - the packed time
packTime(long)
public static byte[] copyWithLength(byte[] orig,
int length)
orig - the original byte arraylength - how big the resulting byte array will be
public static byte[] copyRange(byte[] orig,
int from,
int to)
orig - the original byte arrayfrom - index of first byte in original byte array which will be copiedto - index of last byte in original byte array which will be copied. This can be
outside of the original byte array
public static boolean isJava5()
public static short byteArrayToShort(byte[] b)
public static byte byteArrayToByte(byte[] b)
public static int byteArrayToInt(byte[] b)
b -
public static long byteArrayToLong(byte[] b)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||