📄 stringutils.java
字号:
package org.speedframework.util;
import java.io.Serializable;
import java.lang.reflect.Array;
/**
* 字符串工具类
*
* @author victorching
*
*/
public final class StringUtils {
/**
*
* @param id
* @return
*/
public static String[] getSerializableID(Serializable id) throws Exception {
return getkeyList(id);
}
/**
* 传入的对象序列转换成缓存队列的key值
*
* @param id
* @return
*/
public static String getCacheKey(Serializable id) throws Exception {
String key = "";
String[] param = getkeyList(id);
for (int i = 0; i < param.length; i++) {
if (i == (param.length - 1)) {
key += param[i];
} else {
key += param[i] + "_";
}
}
return key;
}
/**
* 对象队列名称
* @param clz
* @return
* @throws Exception
*/
public static String getObjectQueueReqion(Class clz)throws Exception{
return SQLHelper.getExcuteTableName(clz)+"_queue";
}
private static String[] getkeyList(Serializable id) throws Exception {
String[] param = null;
if (id == null) {
throw new Exception("the id of object is null");
}
if (id.getClass().isArray()) {
int length = Array.getLength(id);
param = new String[length];
for (int i = 0; i < length; i++) {
param[i] = (String) Array.get(id, i);
}
} else if (!id.getClass().isArray()) {
param = new String[] { id.toString() };
}
return param;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -