|
JML | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jqql.Util
public class Util
Tools, convenient way to provide some, some are mainly for debugging purposes, some not 工具类,提供一些方便的方法,有些主要是用于调试用途,有些不是
Field Summary | |
---|---|
static int |
MASK_VALID
Valid character mask. |
Constructor Summary | |
---|---|
Util()
|
Method Summary | |
---|---|
static boolean |
checkFileMD5(RandomAccessFile file,
byte[] md5)
检查收到的文件MD5是否正确 |
static boolean |
checkFileMD5(String filename,
byte[] md5)
check the MD5 file which received whether is correct 检查收到的文件MD5是否正确 |
static boolean |
compareMD5(byte[] m1,
byte[] m2)
compare two MD5 whether is equal 比较两个MD5是否相等 |
static String |
convertByteToHexString(byte[] b)
a Hex string band into a byte array 把字节数组转换成16进制字符串 |
static String |
convertByteToHexString(byte[] b,
int offset,
int len)
a Hex string band into a byte array 把字节数组转换成16进制字符串 |
static String |
convertByteToHexStringWithoutSpace(byte[] b)
a Hex string band into a byte array 把字节数组转换成16进制字符串 |
static String |
convertByteToHexStringWithoutSpace(byte[] b,
int offset,
int len)
a Hex string band into a byte array 把字节数组转换成16进制字符串 |
static byte[] |
convertCharToBytes(char c)
a char change to byte-Array 把一个char转换成字节数组 |
static byte[] |
convertHexStringToByte(String s)
a Hex string band into a byte array 转换16进制字符串为字节数组 |
static byte[] |
convertHexStringToByteNoSpace(String s)
a Hex string band into a byte array, string no spaces,so every ocharacters is two-byte 把一个16进制字符串转换为字节数组,字符串没有空格,所以每两个字符 一个字节 |
static String |
convertIpToString(byte[] ip)
use the byte-array of ip conversion String from 把ip的字节数组形式转换成字符串形式 |
static String |
filterUnprintableCharacter(String s)
Filter in strings of characters can not print |
static int |
findByteOffset(byte[] ar,
byte b)
start from indicate location to search the location where a char appear 从头开始(包含指定位置)查找一个字节的出现位置 |
static int |
findByteOffset(byte[] ar,
byte b,
int from)
start from indicate location to search the location where a char appear 从指定位置开始(包含指定位置)查找一个字节的出现位置 |
static int |
findByteOffset(byte[] ar,
byte b,
int from,
int occurs)
start from indicate location to search the location where next char appear the N th times 从指定位置开始(包含指定位置)查找一个字节的第N次出现位置 |
static String |
get05CommandString(char command)
|
static String |
getAuthActionString(byte b)
get the String form of authenticate type 得到认证操作字符串形式 |
static String |
getAuthTypeString(byte b)
get the String form of authenticate type 得到认证类型字符串形式 |
static byte |
getByte(String s,
int faultValue)
String convert to byte 把字符串转换成byte |
static byte[] |
getBytes(String s)
according to the encoding form to get the byte array format of String 根据缺省编码得到字符串的字节数组形式 |
static byte[] |
getBytes(String s,
String encoding)
according to the encoding form to get the byte array format of String |
static char |
getChar(String s,
int faultValue)
convert String to unsigned number of char 把字符串转换成char类型的无符号数 |
static String |
getClusterCommandString(byte cmd)
get the String form of cluster operate,just for test 得到群操作的字符串形式,仅用于调试 |
static String |
getCommandString(char cmd)
|
static String |
getEncodingString(char encoding)
this is not for test ,we acture wanna invoke the method 这个不是用于调试的,真正要用的方法 |
static String |
getErrorString(int error)
get the type of error 得到错误类型 |
static String |
getFileCommandString(char command)
return String form of file command,just for test 返回文件命令的字符串形式,仅用作调试 |
static byte[] |
getFileMD5(RandomAccessFile file)
calculate the MD5 of file , just calculate in front of up to 10,002,432 bytes 计算文件的MD5,最多只计算前面10002432字节 |
static byte[] |
getFileMD5(String filename)
calculate the MD5 of file , just calculate in front of up to 10,002,432 bytes 计算文件的MD5,最多只计算前面10002432字节 |
static String |
getFileMD5String(String filename)
get the String form of MD5 file |
static String |
getFTPCommandString(char command)
|
static String |
getIMReplyType(byte type)
return response type of String form ,just for test 返回字符串形式的回复类型,仅用于调试 |
static int |
getInt(String s,
int faultValue)
convert the String to int 把字符串转换成int |
static int |
getInt(String s,
int radix,
int faultValue)
convert the String to int 把字符串转换成int |
static int |
getIntFromBytes(byte[] b,
int offset,
int len)
From the array of bytes from the designated location of the len bytes into int type (big-endian), if less than 4 bytes, that is high 0 从字节数组的指定位置起的len的字节转换成int型(big-endian),如果不足4字节,高位认为是0 |
static byte[] |
getIpByteArrayFromString(String ip)
get byte-array form form String of IP 从ip的字符串形式得到字节数组形式 |
static String |
getIpStringFromBytes(byte[] ip)
get String form form byte-array of IP |
static long |
getLong(String s,
int radix,
long faultValue)
convert String to long 把字符串转换成long |
static String |
getNormalIMTypeString(char type)
return general type in the message, just for test 返回普通消息中的类型,仅用作调试 |
static String |
getProtocolString(int p)
get the string of protocol,for debug 得到协议的字符串,for debug |
static String |
getSearchTypeString(byte b)
get the string of search type 得到搜索类型的字符串 |
static String |
getString(byte[] b)
According to default encoding convert byte-array to String 根据缺省编码将字节数组转换成字符串 |
static String |
getString(byte[] b,
int offset,
int len)
According default encoding convert byte-array to String 根据缺省编码方式将字节数组转换成字符串 |
static String |
getString(byte[] b,
int offset,
int len,
String encoding)
According to the encoding convert byte-array to String 根据某种编码方式将字节数组转换成字符串 |
static String |
getString(byte[] b,
String encoding)
According to the encoding convert byte-array to String 根据某种编码方式将字节数组转换成字符串 |
static String |
getString(ByteBuffer buf)
resolve a string from the current location of Buf,stop until a run separator, or reach the end of the buf 从buf的当前位置解析出一个字符串,直到碰到了buf的结尾 |
static String |
getString(ByteBuffer buf,
byte delimit)
resolve a string from the current location of Buf, stop until a run separator, or reach the end of the buf |
static String |
getString(ByteBuffer buf,
byte delimit,
int maxLen)
resolve a string from the current location of Buf,stop until reach delimit or have readed maxlen number of bytes or reach the end. |
static String |
getString(ByteBuffer buf,
int len)
resolve a string from the current location of Buf, stop until reach the end of the buf or read len number bytes 从buf的当前位置解析出一个字符串,直到碰到了buf的结尾或者读取了len个byte之后停止 |
static String |
getString(String s,
String srcEncoding,
String destEncoding)
encoding conversion the source String ,if fail ,return the String |
static byte[] |
getSubBytes(byte[] b,
int offset,
int len)
get the apart of byte array 得到一个字节数组的一部分 |
static long |
getUnsignedInt(byte[] in,
int offset,
int len)
The byte offset from the beginning of an array of len bytes into an unsigned int, there is no java as unsigned, so unsigned (Edited by notxx) changed the algorithm slightly better performance. |
static int |
indexOf(byte[] buf,
int begin,
byte b)
start begin positions where Buf byte in the array to find an byte-array in b as long as any of the emergence of the first location 在buf字节数组中的begin位置开始,查找字节b出现的第一个位置 |
static int |
indexOf(byte[] buf,
int begin,
byte[] b)
start begin positions where Buf byte in the array to find an byte-array in b as long as any of the emergence of the first location 在buf字节数组中的begin位置开始,查找字节数组b中只要任何一个出现的第一个位置 |
static boolean |
isByteArrayEqual(byte[] b1,
byte[] b2)
Comparison of the two-byte array of content is the same |
static boolean |
isInt(String s)
check String whether is int format 检查字符串是否是整数格式 |
static boolean |
isIpEquals(byte[] ip1,
byte[] ip2)
estimate the ip whether is equal another ip 判断IP是否相等 |
static boolean |
isIpZero(byte[] ip)
estimate the IP whether is full-0 |
static char |
parseChar(byte[] content,
int offset)
Content from the offset position from the 2-byte analysis into the char type 从content的offset位置起的2个字节解析成char类型 |
static int |
parseInt(byte[] content,
int offset)
Content from the offset position from the 4-byte analysis into the int type 从content的offset位置起的4个字节解析成int类型 |
static Random |
random()
return a random object |
static byte[] |
randomKey()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MASK_VALID
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static long getUnsignedInt(byte[] in, int offset, int len)
in
- 字节数组.offset
- 从哪里开始转换.len
- 转换长度, 如果len超过8则忽略后面的
public static String filterUnprintableCharacter(String s)
s
- 字符串
public static boolean isByteArrayEqual(byte[] b1, byte[] b2)
b1
- 字节数组1b2
- 字节数组2
public static boolean checkFileMD5(RandomAccessFile file, byte[] md5)
file
- 收到的存在本地的文件md5
- 正确的MD5
public static boolean isIpZero(byte[] ip)
ip
- ip
-
public static boolean checkFileMD5(String filename, byte[] md5)
filename
- md5
-
public static byte[] getFileMD5(String filename)
filename
-
public static byte[] getFileMD5(RandomAccessFile file)
file
- RandomAccessFile对象
public static String getFileMD5String(String filename)
filename
- filename
- 文件名
public static boolean compareMD5(byte[] m1, byte[] m2)
m1
- m2
-
public static byte[] getBytes(String s, String encoding)
s
- Stringencoding
- s
- 字符串encoding
- 编码方式
public static byte[] getBytes(String s)
s
-
public static String getString(String s, String srcEncoding, String destEncoding)
s
- source StringsrcEncoding
- source encodingdestEncoding
- dest encodings
- 原始字符串srcEncoding
- 源编码方式destEncoding
- 目标编码方式
public static String getString(ByteBuffer buf, byte delimit)
This method is not responsible for adjust position of buf , so be sure to call before buf current location at the beginning of a string. After read it complete ,the current position of buf will be located after the separator's P>
Return the string will use the default encoding of QQ, the general encoding is GBK P>
buf
- ByteBufferdelimit
- split char
public static String getString(ByteBuffer buf)
This method is not responsible for adjust the position of buf,so be sure that current location of buf is at the beginning of a string before invoke it. After read it complete ,the current position of buf will be located after the separator's 此方法不负责调整buf位置,调用之前务必使buf当前位置处于字符串开头。在读取完成 后,buf当前位置将位于buf最后之后
Return the string will use the default encoding of QQ, the general encoding is GBK
buf
- ByteBuffer
public static String getString(ByteBuffer buf, int len)
this method is not responsible for adjust the position of buf,so be sure that current location of buf is at the beginning of a string before invoke it. After read it complete ,current position of buf will be located after len byte or after the last byte 此方法不负责调整buf位置,调用之前务必使buf当前位置处于字符串开头。在读取完成 后,buf当前位置将位于len字节之后或者最后之后
Return the string will use the default encoding of QQ, the general encoding is GBK
buf
- ByteBuffer
public static String getString(ByteBuffer buf, byte delimit, int maxLen)
this method is not responsible for adjust the position of buf,so be sure that current location of buf is at the beginning of a string before invoke it. After read it complete ,current position of buf will be located after maxLen 此方法不负责调整buf位置,调用之前务必使buf当前位置处于字符串开头。在读取完成 后,buf当前位置将位于maxLen之后
Return the string will use the default encoding of QQ, the general encoding is GBK
buf
- ByteBufferdelimit
- delimitmaxLen
- max len to read
public static String getString(byte[] b, String encoding)
b
- byte-arrayencoding
-
public static String getString(byte[] b)
b
- byte-array
public static String getString(byte[] b, int offset, int len, String encoding)
b
- byte-arrayoffset
- the posite where start to convertlen
- the length which we wanna convertencoding
-
public static String getString(byte[] b, int offset, int len)
b
- byte-arrayoffset
- the posite where start to convertlen
- the length which we wanna convert
public static int getInt(String s, int faultValue)
s
- StringfaultValue
- if conversion is fail , return this value
public static long getLong(String s, int radix, long faultValue)
s
- StringfaultValue
- if conversion is fail , return this value
public static int getInt(String s, int radix, int faultValue)
s
- Stringradix
- the radix
基数faultValue
- if conversion is fail , return this value
public static boolean isInt(String s)
s
- String
public static char getChar(String s, int faultValue)
s
- StringfaultValue
- if conversion is fail , return this value
public static byte getByte(String s, int faultValue)
s
- 字符串faultValue
- if conversion is fail , return this value
public static String getIpStringFromBytes(byte[] ip)
ip
- byte-array of IP
public static byte[] getIpByteArrayFromString(String ip)
ip
- String form of IP
public static boolean isIpEquals(byte[] ip1, byte[] ip2)
ip1
- byte-array of ipip2
- byte-array of ip
public static String getCommandString(char cmd)
cmd
- command type
public static String getClusterCommandString(byte cmd)
cmd
-
public static String getFileCommandString(char command)
command
-
public static String getEncodingString(char encoding)
encoding
-
public static String getNormalIMTypeString(char type)
type
-
public static String getIMReplyType(byte type)
type
- response type
public static int indexOf(byte[] buf, int begin, byte b)
buf
- a byte-arraybegin
- start with a unknow indexb
- we wanna find the byte-array
public static int indexOf(byte[] buf, int begin, byte[] b)
buf
- a byte-arraybegin
- start with a unknow indexb
- we wanna find the byte-array
public static Random random()
public static byte[] randomKey()
public static final int parseInt(byte[] content, int offset)
content
- byte - arrayoffset
-
public static final char parseChar(byte[] content, int offset)
content
- is byte - arrayoffset
-
public static final String getAuthActionString(byte b)
b
- byte of authenticate operate
认证操作字节
public static final String getAuthTypeString(byte b)
b
- byte of authenticate type
认证类型字节
public static final String getSearchTypeString(byte b)
b
- byte of search type
搜索类型字节
public static String convertByteToHexString(byte[] b)
b
- byte-array
字节数组
public static String convertByteToHexString(byte[] b, int offset, int len)
b
- 字节数组offset
- where start to convert
从哪里开始转换len
- length of conversion
转换的长度
public static String convertByteToHexStringWithoutSpace(byte[] b)
b
- byte-array
字节数组
public static String convertByteToHexStringWithoutSpace(byte[] b, int offset, int len)
b
- byte-array
字节数组offset
- where start to conversion
从哪里开始转换len
- length of conversion
转换的长度
public static byte[] convertHexStringToByte(String s)
s
- Hex String, Bytes each separated by spaces
16进制字符串,每个字节由空格分隔
public static byte[] convertHexStringToByteNoSpace(String s)
s
-
public static String convertIpToString(byte[] ip)
ip
- IP address byte-array, big endian
ip地址字节数组,big-endian
public static int findByteOffset(byte[] ar, byte b)
ar
- byte-array
字节数组b
- the char which we wanna find
要查找的字节
public static int findByteOffset(byte[] ar, byte b, int from)
ar
- byte-array
字节数组b
- the byte we wanna find
要查找的字节from
- indicate location
指定位置
public static int findByteOffset(byte[] ar, byte b, int from, int occurs)
ar
- byte-array
字节数组b
- the byte we wanna find
要查找的字节from
- indicate the location
指定位置occurs
- how many times appeared
第几次出现
public static byte[] convertCharToBytes(char c)
c
- char
字符
public static int getIntFromBytes(byte[] b, int offset, int len)
b
- byte array
字节数组offset
- start location of conversion
转换起始位置len
- length of conversion
转换长度
public static byte[] getSubBytes(byte[] b, int offset, int len)
b
- source byte array
原始字节数组offset
- sub - array start move
子数组开始偏移len
- length of sub -Array
子数组长度
public static String get05CommandString(char command)
command
-
public static String getFTPCommandString(char command)
command
-
public static String getErrorString(int error)
error
-
public static String getProtocolString(int p)
p
-
|
JML | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |