import java.util.Collection;
import java.util.Map;
import java.util.UUID; public class StringHelper { public static final String EMPTY=""; public StringHelper(){} /**
* 判断字符串是否为NULL或空值
* @param str
* @return
*/
@SuppressWarnings("rawtypes")
public static Boolean IsEmptyOrNull(Object obj)
{
if (obj == null)
return true;
if ("".equals(obj))
return true;
if (obj instanceof String) {
if (((String) obj).length() == 0) {
return true;
}
} else if (obj instanceof Collection) {
if (((Collection) obj).size() == 0) {
return true;
}
} else if (obj instanceof Map) {
if (((Map) obj).size() == 0) {
return true;
}
}
return false;
} /**
* NULL转String
* @param obj
* @return
*/
public static String TranString(Object obj)
{
if (obj == null)
return ""; return obj.toString();
} /**
* NULL转String
* @param obj
* @param defaultval 默认值
* @return
*/
public static String TranString(Object obj, String defaultval)
{
if (obj == null)
return defaultval; return obj.toString();
} /**
* 模糊查询%_通配符转换
* @param str
* @return
*/
public static String TranSeachString(Object obj)
{
if (obj == null)
return "";
String result = obj.toString(); return result.replace("\\", "\\\\").replace("_", "\\_").replace("%", "\\%"); /*if (result.startsWith("%") || result.startsWith("_")) {
result = "\\" + result;
} if (!"\\%".equals(result) && !"\\_".equals(result) && result.length() >= 2 && (result.endsWith("%") || result.endsWith("_"))) {
String tmp1 = result.substring(result.length() - 1, result.length());
String tmp2 = result.substring(0, result.length() - 1);
result = tmp2 + "\\" + tmp1;
}
return result;*/
} /**
* 获取GUID
* @return
*/
public static String GetGUID()
{
return UUID.randomUUID().toString().replace("-", "");
} }

最新文章

  1. couchDB视图
  2. [deviceone开发]-do_SegmentView和do_SlideView联动的示例
  3. 再次完善了 WASPCN for Matlab
  4. ubuntu git 使用
  5. Xamarin.Android 反复报 Please Download android_m2repository_rxx.zip 的解决办法
  6. UIScrollView,contentOffset,contentInsert的各自特点和区别?
  7. 大数加法之C语言函数法(只有正数版)
  8. 将Session放入Redis
  9. 编码注释coding: utf-8
  10. 图文浅析APK程序运行的过程
  11. ionic2自定义radio样式
  12. 把mysql脚本或其他数据库脚本导入Powerdesigner
  13. (4)java数据结构--集合类及其数据结构归纳-有大图
  14. jquery计算时间差(天、时、分、秒)并使用定时器实时获取
  15. eclipse打jar包解决第三方依赖包
  16. Qt 反射
  17. Hadoop2的Yarn和MapReduce2相关
  18. JS几个常用的工具函数
  19. oracle系统包——dbms_random用法
  20. [Go语言]从Docker源码学习Go——function和method

热门文章

  1. linux Apache 日志配置
  2. Jmeter--函数助手之随机函数_Random(随机函数)
  3. 010-流程控制 while 与 until 语句
  4. KeSetEvent
  5. Django【第8篇】:Django之查询知识点总结
  6. 【BZOJ3601】一个人的数论
  7. elementui多个文件上传问题
  8. 交互输入与for语句
  9. Java——package与import
  10. sh_03_注释