StringUtils增加splitComma、joinComma
This commit is contained in:
@@ -29,7 +29,7 @@ public class DesUtils {
|
||||
if ("Base64".equalsIgnoreCase(secretKey)) {
|
||||
return EncodeUtils.encodeBase64(data);
|
||||
}
|
||||
String[] ks = StringUtils.split(secretKey, StringUtils.COMMA);
|
||||
String[] ks = StringUtils.splitComma(secretKey);
|
||||
if (ks.length >= 3){
|
||||
return desCore.strEnc(data, ks[0], ks[1], ks[2]);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class DesUtils {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
}
|
||||
String[] ks = StringUtils.split(secretKey, StringUtils.COMMA);
|
||||
String[] ks = StringUtils.splitComma(secretKey);
|
||||
if (ks.length >= 3){
|
||||
return desCore.strDec(data, ks[0], ks[1], ks[2]);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PropertiesUtils {
|
||||
// 获取 spring.config.location 外部自定义的配置文件
|
||||
String customConfigs = System.getProperty("spring.config.location");
|
||||
if (StringUtils.isNotBlank(customConfigs)){
|
||||
for (String customConfig : StringUtils.split(customConfigs, ",")){
|
||||
for (String customConfig : StringUtils.splitComma(customConfigs)){
|
||||
if (!customConfig.contains("$")){
|
||||
customConfig = org.springframework.util.StringUtils.cleanPath(customConfig);
|
||||
if (!ResourceUtils.isUrl(customConfig)){
|
||||
@@ -89,7 +89,7 @@ public class PropertiesUtils {
|
||||
for (String location : configFiles){
|
||||
configSet.add(location);
|
||||
if (StringUtils.isNotBlank(profiles)){
|
||||
for (String pf : StringUtils.split(profiles, ",")) {
|
||||
for (String pf : StringUtils.splitComma(profiles)) {
|
||||
if (location.endsWith(".properties")){
|
||||
configSet.add(StringUtils.substringBeforeLast(location, ".properties")
|
||||
+ "-" + pf + ".properties");
|
||||
@@ -214,7 +214,7 @@ public class PropertiesUtils {
|
||||
* @return 获取不到,返回空defValue默认值
|
||||
*/
|
||||
public String[] getPropertyToArray(String key, String defValue) {
|
||||
return StringUtils.split(getProperty(key, defValue), ",");
|
||||
return StringUtils.splitComma(getProperty(key, defValue));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,20 +4,19 @@
|
||||
*/
|
||||
package com.jeesite.common.lang;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nustaq.serialization.FSTConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* 对象操作工具类,继承 org.apache.commons.lang3.ObjectUtils 类
|
||||
* @author ThinkGem
|
||||
@@ -29,7 +28,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
private static final boolean isJavaSerialize;
|
||||
|
||||
static {
|
||||
String[] ver = StringUtils.split(System.getProperty("java.version"), '.');
|
||||
String[] ver = StringUtils.split(System.getProperty("java.version"), StringUtils.DOT);
|
||||
isJavaSerialize = ver.length > 0 && Integer.parseInt(ver[0]) > 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
|
||||
public static final String DOT = ".";
|
||||
public static final String COMMA = ",";
|
||||
public static final String COLON = ":";
|
||||
public static final String TILDE = "~";
|
||||
@@ -31,10 +32,19 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String[] split(final String str) {
|
||||
public static String[] splitComma(final String str) {
|
||||
return split(str, COMMA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接字符串(默认逗号分隔)
|
||||
* @param iterable
|
||||
* @return
|
||||
*/
|
||||
public static String joinComma(final Iterable<?> iterable) {
|
||||
return join(iterable, COMMA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字节数组
|
||||
* @param str
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.jeesite.common.network;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.io.PropertiesUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class IpUtils {
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ public class IpUtils {
|
||||
}
|
||||
if (StringUtils.isNotBlank(ip)){
|
||||
ip = EncodeUtils.xssFilter(ip, request);
|
||||
ip = StringUtils.split(ip, ",")[0];
|
||||
ip = StringUtils.splitComma(ip)[0];
|
||||
}
|
||||
if (StringUtils.isBlank(ip)){
|
||||
ip = "unknown";
|
||||
|
||||
@@ -7,8 +7,8 @@ package com.jeesite.common.reflect;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.reflect.asm.MethodAccess;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.slf4j.Logger;
|
||||
@@ -26,11 +26,11 @@ import java.util.Map;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class ReflectUtils {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
||||
private static final String SETTER_PREFIX = "set";
|
||||
private static final String GETTER_PREFIX = "get";
|
||||
private static final String CGLIB_CLASS_SEPARATOR = "$$";
|
||||
private static Map<String, Map<String, Method>> methodClassCache = MapUtils.newHashMap();
|
||||
private static final Map<String, Map<String, Method>> methodClassCache = MapUtils.newHashMap();
|
||||
|
||||
/**
|
||||
* 调用Getter方法,v5.3.0+ 变更为ASM方式,不支持私有方法调用,高性能,
|
||||
@@ -41,7 +41,7 @@ public class ReflectUtils {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E invokeGetter(Object obj, String propertyName) {
|
||||
Object object = obj;
|
||||
for (String name : StringUtils.split(propertyName, ".")){
|
||||
for (String name : StringUtils.split(propertyName, StringUtils.DOT)){
|
||||
if (obj instanceof Map){
|
||||
object = ((Map)obj).get(name);
|
||||
}else{
|
||||
@@ -62,7 +62,7 @@ public class ReflectUtils {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> void invokeSetter(Object obj, String propertyName, Object... args) {
|
||||
Object object = obj;
|
||||
String[] names = StringUtils.split(propertyName, ".");
|
||||
String[] names = StringUtils.split(propertyName, StringUtils.DOT);
|
||||
for (int i=0; i<names.length; i++){
|
||||
if(i<names.length-1){
|
||||
if (obj instanceof Map){
|
||||
|
||||
@@ -35,8 +35,8 @@ public class ServletUtils {
|
||||
|
||||
// 定义静态文件后缀;静态文件排除URI地址
|
||||
private static final PropertiesUtils PROPS = PropertiesUtils.getInstance();
|
||||
private static final String[] STATIC_FILE = StringUtils.split(PROPS.getProperty("web.staticFile"), ",");
|
||||
private static final String[] STATIC_FILE_EXCLUDE_URI = StringUtils.split(PROPS.getProperty("web.staticFileExcludeUri"), ",");
|
||||
private static final String[] STATIC_FILE = StringUtils.splitComma(PROPS.getProperty("web.staticFile"));
|
||||
private static final String[] STATIC_FILE_EXCLUDE_URI = StringUtils.splitComma(PROPS.getProperty("web.staticFileExcludeUri"));
|
||||
|
||||
// AJAX 请求参数和请求头名
|
||||
public static final String AJAX_PARAM_NAME = PROPS.getProperty("web.ajaxParamName", "__ajax");
|
||||
|
||||
Reference in New Issue
Block a user