mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
remove unused code
This commit is contained in:
@@ -79,22 +79,6 @@ public class StringUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param in
|
||||
* @return
|
||||
*/
|
||||
public static Long stringToLong(String in) {
|
||||
if (in == null) return null;
|
||||
in = in.trim();
|
||||
if (in.length() == 0) return null;
|
||||
try {
|
||||
return Long.parseLong(in);
|
||||
} catch (NumberFormatException e) {
|
||||
LOG.warn("stringToLong fail,string=" + in, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> getParameters(String url) {
|
||||
if (url == null || (url = url.trim()).length() == 0) return null;
|
||||
|
||||
@@ -115,97 +99,18 @@ public class StringUtils {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenize the given String into a String array via a StringTokenizer. Trims tokens and omits empty tokens.
|
||||
* <p>
|
||||
* The given delimiters string is supposed to consist of any number of delimiter characters. Each of those
|
||||
* characters can be used to separate tokens. A delimiter is always a single character; for multi-character
|
||||
* delimiters, consider using <code>delimitedListToStringArray</code>
|
||||
* <p/>
|
||||
* <p>
|
||||
* Copied from the Spring Framework while retaining all license, copyright and author information.
|
||||
*
|
||||
* @param str the String to tokenize
|
||||
* @param delimiters the delimiter characters, assembled as String (each of those characters is individually
|
||||
* considered as delimiter).
|
||||
* @return an array of the tokens
|
||||
* @see java.util.StringTokenizer
|
||||
* @see java.lang.String#trim()
|
||||
*/
|
||||
public static String[] tokenizeToStringArray(String str, String delimiters) {
|
||||
return tokenizeToStringArray(str, delimiters, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenize the given String into a String array via a StringTokenizer.
|
||||
* <p>
|
||||
* The given delimiters string is supposed to consist of any number of delimiter characters. Each of those
|
||||
* characters can be used to separate tokens. A delimiter is always a single character; for multi-character
|
||||
* delimiters, consider using <code>delimitedListToStringArray</code>
|
||||
* <p/>
|
||||
* <p>
|
||||
* Copied from the Spring Framework while retaining all license, copyright and author information.
|
||||
*
|
||||
* @param str the String to tokenize
|
||||
* @param delimiters the delimiter characters, assembled as String (each of those characters is individually
|
||||
* considered as delimiter)
|
||||
* @param trimTokens trim the tokens via String's <code>trim</code>
|
||||
* @param ignoreEmptyTokens omit empty tokens from the result array (only applies to tokens that are empty after
|
||||
* trimming; StringTokenizer will not consider subsequent delimiters as token in the first place).
|
||||
* @return an array of the tokens (<code>null</code> if the input String was <code>null</code>)
|
||||
* @see java.util.StringTokenizer
|
||||
* @see java.lang.String#trim()
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens,
|
||||
boolean ignoreEmptyTokens) {
|
||||
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(str, delimiters);
|
||||
List tokens = new ArrayList();
|
||||
while (st.hasMoreTokens()) {
|
||||
String token = st.nextToken();
|
||||
if (trimTokens) {
|
||||
token = token.trim();
|
||||
}
|
||||
if (!ignoreEmptyTokens || token.length() > 0) {
|
||||
tokens.add(token);
|
||||
}
|
||||
}
|
||||
return toStringArray(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the given Collection into a String array. The Collection must contain String elements only.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Copied from the Spring Framework while retaining all license, copyright and author information.
|
||||
*
|
||||
* @param collection the Collection to copy
|
||||
* @return the String array (<code>null</code> if the passed-in Collection was <code>null</code>)
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static String[] toStringArray(Collection collection) {
|
||||
if (collection == null) {
|
||||
return null;
|
||||
}
|
||||
return (String[]) collection.toArray(new String[collection.size()]);
|
||||
}
|
||||
|
||||
public static boolean equals(String a, String b) {
|
||||
if (a == null) {
|
||||
return b == null;
|
||||
}
|
||||
return a.equals(b);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isEmpty(String value) {
|
||||
if (value == null || value.length() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user