Utilities for strings.
* * * Copyright 2002 Sapient * @since carbon 1.0 * @author Greg Hinkle, May 2002 * @version $Revision: 1.5 $($Author: dvoet $ / $Date: 2003/05/05 21:21:24 $) */ public class StringUtil { /** * Converts a string to a Set. Breaks the string to characters and store
* each character in a Set.
*
* @param string the string to convert
* @return a Set
containing all characters in the text string parameter
*/
public static Set convertToSet(String string) {
// Result hashset
Set resultSet = new HashSet();
for (int i = 0; i < string.length(); i++) {
resultSet.add(new Character(string.charAt(i)));
}
// Return result
return resultSet;
}
/**
*
Converts a char array to a Set. Puts all characters in the array to a Set.
*
* @param charArray an array of char
s
* @return a set
containing all characters in the char array
*/
public static Set convertToSet(char[] charArray) {
// Result hashset
Set resultSet = new HashSet();
for (int i = 0; i < charArray.length; i++) {
resultSet.add(new Character(charArray[i]));
}
// Return result
return resultSet;
}
}