CheckUtil类 判断工具类 本次开发中总结的工具类
2014-02-08 15:27
232 查看
public class CheckUtil
{
/**
* 判断字符串为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(String str)
{
return null == str || str.trim().length()==0?true:false;
}
/**
* 判断对象为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(Object obj)
{
return null == obj ? true : false;
}
/**
* 判断集合类为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(Collection c)
{
return CollectionUtils.isEmpty(c);
}
/**
* 判断Map为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(Map map)
{
return MapUtils.isEmpty(map);
}
/**
* 判断数组为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(Object[] arr)
{
return ArrayUtils.isEmpty(arr);
}
/**
* 判断集合不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(Collection c)
{
return !isEmpty(c);
}
/**
* 判断对象不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(Object c)
{
return !isEmpty(c);
}
/**
* 判断数组不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(Object[] c)
{
return !isEmpty(c);
}
/**
* 判断Map不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(Map c)
{
return !isEmpty(c);
}
/**
* 判断字符串不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(String c)
{
return !isEmpty(c);
}
public static boolean isMobile(String str)
{
Pattern p = Pattern.compile("^1[3|4|5|8][0-9]\\d{8}$");
Matcher m = p.matcher(str);
return m.matches();
}
public static boolean notMobile(String str)
{
return !isMobile(str);
}
public static boolean isEmail(String email)
{
if (StringUtils.isBlank(email))
return false;
email = email.toLowerCase();
if(!isLimitEmail(email))
return false;
Pattern emailer = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
return emailer.matcher(email).matches();
}
private static boolean isLimitEmail(String email)
{
String[] emails = {"@163.com","@126.com","@sohu.com","@yeah.net","@gmail.com","@yahoo.cn","@qq.com","@sina.com.cn","@hotmail.com","@tom.cn","@live.cn"};
for(String e : emails)
{
if(email.endsWith(e))
{
return true;
}
}
return false;
}
public static int getLength(String s)
{
s = s.replaceAll("[^\\x00-\\xff]", "**");
int length = s.length();
return length;
}
}
{
/**
* 判断字符串为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(String str)
{
return null == str || str.trim().length()==0?true:false;
}
/**
* 判断对象为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(Object obj)
{
return null == obj ? true : false;
}
/**
* 判断集合类为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(Collection c)
{
return CollectionUtils.isEmpty(c);
}
/**
* 判断Map为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(Map map)
{
return MapUtils.isEmpty(map);
}
/**
* 判断数组为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean isEmpty(Object[] arr)
{
return ArrayUtils.isEmpty(arr);
}
/**
* 判断集合不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(Collection c)
{
return !isEmpty(c);
}
/**
* 判断对象不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(Object c)
{
return !isEmpty(c);
}
/**
* 判断数组不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(Object[] c)
{
return !isEmpty(c);
}
/**
* 判断Map不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(Map c)
{
return !isEmpty(c);
}
/**
* 判断字符串不为空
* <一句话功能简述>
* <功能详细描述>
* @author tangzhang
* @date 2013-11-9 下午3:58:10
* @param str
* @return
* @see [类、类#方法、类#成员]
*/
public static boolean notEmpty(String c)
{
return !isEmpty(c);
}
public static boolean isMobile(String str)
{
Pattern p = Pattern.compile("^1[3|4|5|8][0-9]\\d{8}$");
Matcher m = p.matcher(str);
return m.matches();
}
public static boolean notMobile(String str)
{
return !isMobile(str);
}
public static boolean isEmail(String email)
{
if (StringUtils.isBlank(email))
return false;
email = email.toLowerCase();
if(!isLimitEmail(email))
return false;
Pattern emailer = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
return emailer.matcher(email).matches();
}
private static boolean isLimitEmail(String email)
{
String[] emails = {"@163.com","@126.com","@sohu.com","@yeah.net","@gmail.com","@yahoo.cn","@qq.com","@sina.com.cn","@hotmail.com","@tom.cn","@live.cn"};
for(String e : emails)
{
if(email.endsWith(e))
{
return true;
}
}
return false;
}
public static int getLength(String s)
{
s = s.replaceAll("[^\\x00-\\xff]", "**");
int length = s.length();
return length;
}
}
相关文章推荐
- 快速开发之网络判断工具类
- android开发工具类总结(一)
- javascript开发经验总结【一】:多重条件判断
- android开发常用工具类 文件读写 手机号格式校验 有无网络判断
- java开发常用工具类集合总结
- Android开发中总结的Adapter工具类【附完整源码下载】
- ios开发之小总结「类与对象的判断方法和遍历字典的方法」
- Android开发总结笔记 绘图工具类 3-6
- 百度地图开发总结----3.判断一个点是否在一片区域内
- 百度地图开发总结----3.判断一个点是否在一片区域内
- 实例详解Android快速开发工具类总结
- android开发之网络判断的工具类
- 近期的安卓学习开发SOS APP的一些总结文档 (拨打电话 加载首页图片的异步代码 判断是否有网络代码)
- 开发经验总结(打造更优秀的日志输出工具类)
- javascript开发经验总结【一】:多重条件判断
- ios开发总结:Utils常用方法等收集,添加扩展类,工具类方法,拥有很多方便快捷功能(不断更新中。。。)
- Android开发之java代码工具类。判断当前网络是否连接并请求下载图片
- 近期的安卓学习开发SOS APP的一些总结文档 (拨打电话 加载首页图片的异步代码 判断是否有网络代码)
- Android开发之SDCardUtils工具类。java工具详细代码,附源代码。判断SD卡是否挂载等功能
- android开发工具类总结(一)