CheckUtil类 判断工具类 本次开发中总结的工具类

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;
    }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值