非空验证(源代码Java版)
import java.util.Map; /**
* 非空验证工具类
*/
public class UntilEmpty { /**
* @see: 验证string类型的是否为空
*/
public static boolean isNullorEmpty(String str) {
//为了执行忽略大小写的比较,可以调用equalsIgnoreCase( )方法。当比较两个字符串时,它会认为A-Z和a-z是一样的。
if ((str == null) || ("".equals(str)) || ("null".equalsIgnoreCase(str)) || ("undefined".equalsIgnoreCase(str))) {
return true;
}
return false;
} /**
* @see: 验证实体是否为空
*/
public static <T> boolean isNullorEmpty(T entity) {
if (entity == null) {
return true;
} else {
return false;
}
} /**
* @see: 验证StringBuffer类型的是否为空
*/
public static boolean isNullorEmpty(StringBuffer str) {
if (str == null ||"".equals(str.toString()) || str.length() == 0) {
return true;
} else {
return false;
}
} /**
* @see: 验证Map类型的是否为空
*/
public static boolean isNullorEmpty(Map map) {
if ((map == null) || (map.size() == 0)) {
return true;
}
return false;
} /**
* @see: 验证Object数组类型的是否为空
*/
public static boolean isNullorEmpty(Object[] obj) {
if ((obj == null) || (obj.length == 0)) {
return true;
}
return false;
} /**
* @see: 验证Long类型的是否为空
*/
public static boolean isNullorEmpty(Long longTime) {
if ((longTime == null) || (longTime.longValue() <= 0L)) {
return true;
}
return false;
} /**
* @see: 验证String数组类型的是否为空
*/
public static boolean isNullorEmpty(String[] str) {
if ((str == null) || (str.length == 0)) {
return true;
}
return false;
}
}
非空验证(源代码Java版)的更多相关文章
- select标签非空验证,第一个option value=""即可
select标签非空验证,第一个option value=""即可,否则不能验证
- JavaWeb 学习008-今日问题(非空验证尚未解决) 2016-12-2
1. 学生模块list页面 不能正常跳转 说是找不到stuid属性,但是我在entity里面和数据库建表的属性就是stuid:Grade模块代码一样,却可以正常运行 这是什么问题? <c:for ...
- JS非空验证及邮箱验证
非空验证 <body> <table> <tr> <td>姓名:</td> <td><input type="t ...
- Atitit 验证 数字验证 非空验证的最佳算法 h5
Atitit 验证 数字验证 非空验证的最佳算法 h5 <td><select class="searchBox-select" style=" ...
- php非空验证
我想说这种方法是不是很常用的非空验证,现在的普遍使用的是javascript来验证非空,但是作为学习php的一些知识点,还是可以看看的. 先来看看commit.php中的方法 <?php $db ...
- .NET开源工作流RoadFlow-Bug修改-1.8.2表单验证时ueditor编辑非空验证无效
RoadFlow生成的表单,Ueditor编辑器不能进行非空验证的BUG修改: 1.修改控制器:WorkFlowFormDesignerController红框处: 2.修改js文件:Scripts/ ...
- 单选按钮 设置required属性无法进行非空验证
先看代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- JS-表单非空验证
JavaScript 表单验证 JavaScript 可用来在数据被送往服务器前对 HTML 表单中的这些输入数据进行验证. 实例:1.用户名的非空验证代码如下: <head> <m ...
- 阿里云短信验证解决方案(java版)(redis存储)
最近搞了一个互联网项目的注册,需要写一个手机号验证(由于之前没有轮子,只能自己摸索了); 1:基本思路: 1>购买了阿里云短信服务->下载阿里云短信发送demo(java版); 2> ...
随机推荐
- C#,新建的系统服务项目有些机器不能运行
检查了一下,是权限的问题 右键ProjectInstaller.cs 在设计界面里找到serviceProcessInstaller1右键属性 找到Account属性改为:LocalSystem
- PHP 关于MongoDB的操作
<?php header("Content-type:text/html;charset=utf-8"); $m = new MongoClient(); // 连接 $db ...
- A Script Pro nginx URL重写规则无法播放MP4解决方法
I am using nginx and I have already add the line location /file/ { rewrite ^/-]+)/([-]+)/([^/]*)/([- ...
- 3.2. Grid Search: Searching for estimator parameters
3.2. Grid Search: Searching for estimator parameters Parameters that are not directly learnt within ...
- ios入门之c语言篇——基本函数——5——素数判断
参数返回值解析: 参数: m:int,需要判断的值: 返回值: 0:非素数 1:素数 函数解析: 注意:函数没有对输入进行判断,请自己屏蔽非法输入 int prime(int m) { int tem ...
- centos 6.5关闭NetworkManager
jrhmpt01:/root# rpm -qa | grep -i network NetworkManager-glib-0.8.1-99.el6.x86_64 system-config-netw ...
- 【转】EditText大小(长宽)的多种设置方式----不错
原文网址:http://orgcent.com/android-edittext-ems-layout-minwidth-maxheight/ EditText大小的设置有多种方式,要想对每种方式运用 ...
- (转载)PHP怎么获取MySQL执行sql语句的查询时间
(转载自CSDN) 方法一: //计时开始 runtime(); //执行查询 mysql_query($sql); //计时结束. echo runtime(1); //计时函数 function ...
- (转载)遍历memcache中已缓存的key
(转载)http://www.cnblogs.com/ainiaa/archive/2011/03/11/1981108.html 最近需要做一个缓存管理的功能.其中有一个需要模糊匹配memcache ...
- 生成树的计数(基尔霍夫矩阵):UVAoj 10766 Organising the Organisation SPOJ HIGH - Highways
HIGH - Highways In some countries building highways takes a lot of time... Maybe that's because th ...