parent
10a881d860
commit
d3d57da89f
|
@ -37,7 +37,6 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
@ -243,45 +242,6 @@ public class Strings {
|
||||||
return hasText((CharSequence) str);
|
return hasText((CharSequence) str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether the given CharSequence contains any whitespace characters.
|
|
||||||
*
|
|
||||||
* @param str the CharSequence to check (may be <code>null</code>)
|
|
||||||
* @return <code>true</code> if the CharSequence is not empty and
|
|
||||||
* contains at least 1 whitespace character
|
|
||||||
* @see java.lang.Character#isWhitespace
|
|
||||||
*/
|
|
||||||
public static boolean containsWhitespace(CharSequence str) {
|
|
||||||
if (!hasLength(str)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int strLen = str.length();
|
|
||||||
for (int i = 0; i < strLen; i++) {
|
|
||||||
if (Character.isWhitespace(str.charAt(i))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trim leading whitespace from the given String.
|
|
||||||
*
|
|
||||||
* @param str the String to check
|
|
||||||
* @return the trimmed String
|
|
||||||
* @see java.lang.Character#isWhitespace
|
|
||||||
*/
|
|
||||||
public static String trimLeadingWhitespace(String str) {
|
|
||||||
if (!hasLength(str)) {
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder(str);
|
|
||||||
while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {
|
|
||||||
sb.deleteCharAt(0);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trim all occurrences of the supplied leading character from the given String.
|
* Trim all occurrences of the supplied leading character from the given String.
|
||||||
*
|
*
|
||||||
|
@ -416,17 +376,6 @@ public class Strings {
|
||||||
return (str != null ? "'" + str + "'" : null);
|
return (str != null ? "'" + str + "'" : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unqualify a string qualified by a separator character. For example,
|
|
||||||
* "this:name:is:qualified" returns "qualified" if using a ':' separator.
|
|
||||||
*
|
|
||||||
* @param qualifiedName the qualified name
|
|
||||||
* @param separator the separator
|
|
||||||
*/
|
|
||||||
public static String unqualify(String qualifiedName, char separator) {
|
|
||||||
return qualifiedName.substring(qualifiedName.lastIndexOf(separator) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Capitalize a <code>String</code>, changing the first letter to
|
* Capitalize a <code>String</code>, changing the first letter to
|
||||||
* upper case as per {@link Character#toUpperCase(char)}.
|
* upper case as per {@link Character#toUpperCase(char)}.
|
||||||
|
@ -611,41 +560,6 @@ public class Strings {
|
||||||
return new String[]{beforeDelimiter, afterDelimiter};
|
return new String[]{beforeDelimiter, afterDelimiter};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Take an array Strings and split each element based on the given delimiter.
|
|
||||||
* A <code>Properties</code> instance is then generated, with the left of the
|
|
||||||
* delimiter providing the key, and the right of the delimiter providing the value.
|
|
||||||
* <p>Will trim both the key and value before adding them to the
|
|
||||||
* <code>Properties</code> instance.
|
|
||||||
*
|
|
||||||
* @param array the array to process
|
|
||||||
* @param delimiter to split each element using (typically the equals symbol)
|
|
||||||
* @param charsToDelete one or more characters to remove from each element
|
|
||||||
* prior to attempting the split operation (typically the quotation mark
|
|
||||||
* symbol), or <code>null</code> if no removal should occur
|
|
||||||
* @return a <code>Properties</code> instance representing the array contents,
|
|
||||||
* or <code>null</code> if the array to process was <code>null</code> or empty
|
|
||||||
*/
|
|
||||||
public static Properties splitArrayElementsIntoProperties(
|
|
||||||
String[] array, String delimiter, String charsToDelete) {
|
|
||||||
|
|
||||||
if (isEmpty(array)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Properties result = new Properties();
|
|
||||||
for (String element : array) {
|
|
||||||
if (charsToDelete != null) {
|
|
||||||
element = deleteAny(element, charsToDelete);
|
|
||||||
}
|
|
||||||
String[] splittedElement = split(element, delimiter);
|
|
||||||
if (splittedElement == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
result.setProperty(splittedElement[0].trim(), splittedElement[1].trim());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tokenize the given String into a String array via a StringTokenizer.
|
* Tokenize the given String into a String array via a StringTokenizer.
|
||||||
* Trims tokens and omits empty tokens.
|
* Trims tokens and omits empty tokens.
|
||||||
|
|
Loading…
Reference in New Issue