mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-24 04:53:50 +08:00
refactor
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
package me.chanjar.weixin.common.util;
|
||||
|
||||
/**
|
||||
* copy from apache-commons-lang3
|
||||
*/
|
||||
public class StringUtils {
|
||||
|
||||
/**
|
||||
* <p>Checks if a CharSequence is whitespace, empty ("") or null.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.isBlank(null) = true
|
||||
* StringUtils.isBlank("") = true
|
||||
* StringUtils.isBlank(" ") = true
|
||||
* StringUtils.isBlank("bob") = false
|
||||
* StringUtils.isBlank(" bob ") = false
|
||||
* </pre>
|
||||
*
|
||||
* @param cs the CharSequence to check, may be null
|
||||
* @return {@code true} if the CharSequence is null, empty or whitespace
|
||||
* @since 2.0
|
||||
* @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
|
||||
*/
|
||||
public static boolean isBlank(CharSequence cs) {
|
||||
int strLen;
|
||||
if (cs == null || (strLen = cs.length()) == 0) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < strLen; i++) {
|
||||
if (Character.isWhitespace(cs.charAt(i)) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Checks if a CharSequence is not empty (""), not null and not whitespace only.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.isNotBlank(null) = false
|
||||
* StringUtils.isNotBlank("") = false
|
||||
* StringUtils.isNotBlank(" ") = false
|
||||
* StringUtils.isNotBlank("bob") = true
|
||||
* StringUtils.isNotBlank(" bob ") = true
|
||||
* </pre>
|
||||
*
|
||||
* @param cs the CharSequence to check, may be null
|
||||
* @return {@code true} if the CharSequence is
|
||||
* not empty and not null and not whitespace
|
||||
* @since 2.0
|
||||
* @since 3.0 Changed signature from isNotBlank(String) to isNotBlank(CharSequence)
|
||||
*/
|
||||
public static boolean isNotBlank(CharSequence cs) {
|
||||
return !StringUtils.isBlank(cs);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Checks if a CharSequence is empty ("") or null.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.isEmpty(null) = true
|
||||
* StringUtils.isEmpty("") = true
|
||||
* StringUtils.isEmpty(" ") = false
|
||||
* StringUtils.isEmpty("bob") = false
|
||||
* StringUtils.isEmpty(" bob ") = false
|
||||
* </pre>
|
||||
*
|
||||
* <p>NOTE: This method changed in Lang version 2.0.
|
||||
* It no longer trims the CharSequence.
|
||||
* That functionality is available in isBlank().</p>
|
||||
*
|
||||
* @param cs the CharSequence to check, may be null
|
||||
* @return {@code true} if the CharSequence is empty or null
|
||||
* @since 3.0 Changed signature from isEmpty(String) to isEmpty(CharSequence)
|
||||
*/
|
||||
public static boolean isEmpty(CharSequence cs) {
|
||||
return cs == null || cs.length() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Checks if a CharSequence is not empty ("") and not null.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.isNotEmpty(null) = false
|
||||
* StringUtils.isNotEmpty("") = false
|
||||
* StringUtils.isNotEmpty(" ") = true
|
||||
* StringUtils.isNotEmpty("bob") = true
|
||||
* StringUtils.isNotEmpty(" bob ") = true
|
||||
* </pre>
|
||||
*
|
||||
* @param cs the CharSequence to check, may be null
|
||||
* @return {@code true} if the CharSequence is not empty and not null
|
||||
* @since 3.0 Changed signature from isNotEmpty(String) to isNotEmpty(CharSequence)
|
||||
*/
|
||||
public static boolean isNotEmpty(CharSequence cs) {
|
||||
return !StringUtils.isEmpty(cs);
|
||||
}
|
||||
|
||||
}
|
@@ -1,12 +1,9 @@
|
||||
package me.chanjar.weixin.common.util.http;
|
||||
|
||||
import me.chanjar.weixin.common.bean.result.WxError;
|
||||
import me.chanjar.weixin.common.util.fs.FileUtils;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.InputStreamResponseHandler;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.Utf8ResponseHandler;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import me.chanjar.weixin.common.util.StringUtils;
|
||||
import me.chanjar.weixin.common.util.fs.FileUtils;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
|
Reference in New Issue
Block a user