|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.common.mysql.Utils
public class Utils
Utility class.
| Constructor Summary | |
|---|---|
Utils()
|
|
| Method Summary | |
|---|---|
static java.net.InetAddress |
applyMask(java.lang.String ip,
java.lang.String mask)
Applies the given mask to the given IP |
static java.util.ArrayList<java.lang.Byte> |
byteArrayToArrayList(byte[] byteArray)
Converts the given array of bytes into a Java ArrayList |
static java.util.ArrayList<java.lang.Byte> |
byteArrayToArrayList(byte[] byteArray,
int offset)
Converts the given array of bytes into a Java ArrayList starting from the given offset |
static java.lang.String |
byteArrayToHexString(byte[] in)
Converts the given byte array into a readable hexa-decimal formatted string |
static java.lang.String |
byteArrayToHexString(byte[] in,
int offset)
Converts the given byte array into a readable hexa-decimal formatted string, starting from given offset This code was originally taken from Jeff Boyle's article on devX.com |
static void |
bytesToHex(byte[] bytes,
byte[] hex,
int offset)
Turns 16-byte stream into a human-readable 32-byte hex string This code was copied from the PostgreSQL JDBC driver code (MD5Digest.java) |
static java.lang.String |
byteToHexString(byte in)
Converts a byte to readable hexadecimal format in a string This code was originally taken from Jeff Boyle's article on devX.com |
static java.lang.String |
cidrMaskToNetMask(java.lang.String cidrMask)
Transforms a CIDR formatted mask into a regular network mask |
static java.lang.String |
generateRandomString(int count)
Generate a random string. |
static boolean |
isAuthorizedIP(java.lang.String ip,
java.util.List<java.lang.String> authorizedIPs)
Tells whether the given IP belongs to the given list of CIDR addresses. |
static boolean |
isInRange(java.lang.String ip,
java.lang.String ipRange)
Tells whether the given IPV4 address is in the given CIDR ip range |
static java.lang.String |
removeComments(java.lang.String sqlStatement)
Removes comments (between slash-star and star-slash plus lines beginning with double slash) comments from a sql statement and returns the resulting statement. |
static java.lang.String |
removeQuotes(java.lang.String s)
Trims white spaces and remove quotes from the string. |
static java.lang.String |
replaceParametersWithQuestionMarks(java.lang.String statement)
Replace parameters $1, $2, ... |
| 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 java.lang.String generateRandomString(int count)
public static java.lang.String removeQuotes(java.lang.String s)
s - the string
public static java.lang.String replaceParametersWithQuestionMarks(java.lang.String statement)
statement - the statement
public static void bytesToHex(byte[] bytes,
byte[] hex,
int offset)
bytes - bytes to converthex - the converted hex bytesoffset - from where to start the conversionpublic static java.lang.String byteToHexString(byte in)
in - byte[] buffer to convert to string format
public static java.lang.String byteArrayToHexString(byte[] in,
int offset)
in - byte[] buffer to convert to string formatoffset - where to start the conversion from
public static java.lang.String byteArrayToHexString(byte[] in)
in - byte[] buffer to convert to string format
public static java.util.ArrayList<java.lang.Byte> byteArrayToArrayList(byte[] byteArray)
byteArray - array of bytes to convert
public static java.util.ArrayList<java.lang.Byte> byteArrayToArrayList(byte[] byteArray,
int offset)
byteArray - array of bytes to convertoffset - where to start conversion from
public static java.lang.String removeComments(java.lang.String sqlStatement)
sqlStatement - a sql statement in which we want to remove comments
public static java.net.InetAddress applyMask(java.lang.String ip,
java.lang.String mask)
ip - the IPV4 address to apply mask tomask - the IPV4 mask to apply to the given IP
public static java.lang.String cidrMaskToNetMask(java.lang.String cidrMask)
cidrMask - mask in CIDR format (24, 32, etc.)
public static boolean isInRange(java.lang.String ip,
java.lang.String ipRange)
ip - the IP address to compare, in ipv4 formatipRange - the network+mask to test, in CIDR format
public static boolean isAuthorizedIP(java.lang.String ip,
java.util.List<java.lang.String> authorizedIPs)
ip - the IP address to testauthorizedIPs - a list of CIDR formatted network/mask. Null for
authorizing any host
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||