package com.stylefeng.guns.modular.system.util;
|
|
import java.util.List;
|
|
public class EmptyUtil {
|
/**
|
* 判断对象为空
|
*
|
* @param obj
|
* 对象名
|
* @return 是否为空
|
*/
|
@SuppressWarnings("rawtypes")
|
public static boolean isEmpty(Object obj)
|
{
|
if (obj == null)
|
{
|
return true;
|
}
|
if ((obj instanceof List))
|
{
|
return ((List) obj).size() == 0;
|
}
|
if ((obj instanceof String))
|
{
|
return ((String) obj).trim().equals("");
|
}
|
return false;
|
}
|
|
/**
|
* 判断对象不为空
|
*
|
* @param obj
|
* 对象名
|
* @return 是否不为空
|
*/
|
public static boolean isNotEmpty(Object obj)
|
{
|
return !isEmpty(obj);
|
}
|
|
|
/**
|
* 富文本格式转换
|
* @param value
|
* @return
|
*/
|
public static String cleanXSS(String value) {
|
//You'll need to remove the spaces from the html entities below
|
value = value.replaceAll("& lt;", "<").replaceAll("& gt;", ">");
|
value = value.replaceAll("\\(", "& #40;").replaceAll("\\)", "& #41;");
|
return value;
|
}
|
}
|