Methods Summary |
---|
public static java.lang.String | arrayToSeparatedList(java.util.List list, int beginIndex, int endIndex, java.lang.String separator)Convert an array of objects into a separated string. This method
assumes there is no instance of the separator in the strings of list.
StringBuffer result = new StringBuffer();
if (list != null)
{
int i, count = (endIndex + 1);
if ((count > beginIndex) && (list.size() >= count))
result.append(list.get(beginIndex));
for (i = beginIndex + 1; i < count; i++)
result.append(separator + list.get(i));
}
return result.toString();
|
public static java.lang.String | arrayToSeparatedList(java.util.List list, int beginIndex, int endIndex)Convert an array of objects into a separated string using the default
separator. This method assumes there is no instance of the separator
in the strings of list.
return arrayToSeparatedList(list, beginIndex, endIndex, ","); // NOI18N
|
public static java.lang.String | arrayToSeparatedList(java.util.List list, java.lang.String separator)Convert an array of objects into a separated string using the specified
separator and the entire array. This method assumes there is no
instance of the separator in the strings of list.
return arrayToSeparatedList(list, 0,
((list != null) ? (list.size() - 1) : 0), separator);
|
public static java.lang.String | arrayToSeparatedList(java.util.List list)Convert an array of objects into a separated string using the default
separator and the entire array. This method assumes there is no
instance of the separator in the strings of list.
return arrayToSeparatedList(list, 0,
((list != null) ? (list.size() - 1) : 0));
|
public static java.lang.String | escape(java.lang.String str)Escaping given string by " and \.
if (str == null)
{
return str;
}
else
{
int indS = str.indexOf(BACKSLASH);
int indQ = str.indexOf(QUOTE);
if (indS == -1 && indQ == -1)
{
return str;
}
else
{
StringBuffer buf = new StringBuffer();
char data[] = str.toCharArray();
for (int i = 0; i < data.length; i++)
{
if (BACKSLASH == data[i] || QUOTE == data[i])
{
buf.append(BACKSLASH);
}
buf.append(data[i]);
}
return buf.toString();
}
}
|
public static java.lang.String | getCapitalizedString(java.lang.String aString)Gets a version of the specified string with the first letter
capitalized. This can be used to convert a field name to get and set
method names.
if (isEmpty(aString))
return aString;
return Character.toUpperCase(aString.charAt(0)) + aString.substring(1);
|
public static java.lang.String | intArrayToSeparatedList(int[] intArray, java.lang.String separator)Convert an array of int values into a separated string.
return intArrayToSeparatedList(intArray, 0,
((intArray != null) ? (intArray.length - 1) : 0), separator);
|
public static java.lang.String | intArrayToSeparatedList(int[] intArray, int beginIndex, int endIndex, java.lang.String separator)Convert an array of int values into a separated string.
StringBuffer result = new StringBuffer();
if (intArray != null)
{
int count = (endIndex + 1);
if ((count > beginIndex) && (intArray.length >= count))
result.append(intArray[beginIndex]);
for (int i = beginIndex + 1; i < count; i++) {
result.append(separator);
result.append(intArray[i]);
}
}
return result.toString();
|
public static boolean | isEmpty(java.lang.String aString)Checks if a string is null or empty.
return ((aString == null) || (aString.trim().length() == 0));
|
public static java.lang.String | replace(java.lang.String string, java.lang.String oldString, java.lang.String newString)Replaces all occurences of oldString in string
with newString . The methods returns either a new string
instance (in the case oldString is included in the string)
or the origial string itself (in the case oldString is not
included).
StringBuffer sb = null;
final int l = oldString.length();
int beginIndex = 0;
int index;
while ((index = string.indexOf(oldString, beginIndex)) > -1)
{
// only create the StringBuffer if there's an occurence of oldString
if (sb == null)
{
sb = new StringBuffer(string.length());
}
sb.append(string.substring(beginIndex, index));
sb.append(newString);
beginIndex = index + l;
}
// append the rest if the old value was found at least once
if (sb != null)
{
sb.append(string.substring(beginIndex));
}
return (sb != null ? sb.toString() : string);
|
public static java.lang.String | replaceFirst(java.lang.String string, java.lang.String oldString, java.lang.String newString)Replaces the first occurence of oldString in string
with newString . The methods returns either a new string
instance (in the case oldString is included in the string)
or the origial string itself (in the case oldString is not
included).
int index = string.indexOf(oldString);
if (index != -1) {
StringBuffer sb = new StringBuffer(string.length());
sb.append(string.substring(0, index));
sb.append(newString);
sb.append(string.substring(index + oldString.length()));
return sb.toString();
}
return string;
|
public static java.lang.String | rtrim(java.lang.String input)Trims trailing spaces from input.
String retVal = input;
if (input != null)
{
int lastCharIndex = input.length() - 1;
int originalLastCharIndex = lastCharIndex;
while ((lastCharIndex >= 0) &&
Character.isSpaceChar(input.charAt(lastCharIndex)))
{
lastCharIndex--;
}
if (lastCharIndex != originalLastCharIndex)
{
//We have characters to trim.
retVal = input.substring(0,lastCharIndex + 1);
}
}
return retVal;
|
public static java.util.List | separatedListToArray(java.lang.String list, java.lang.String separator)Convert a separated string to an array of strings
ArrayList result = new ArrayList();
if (list != null)
{
StringTokenizer st = new StringTokenizer(list, separator);
int i, size = st.countTokens();
for (i = 0; i < size; i++)
result.add(st.nextToken());
}
return result;
|
public static java.util.List | separatedListToArray(java.lang.String list)Convert a separated string to an array of strings using the default
separator.
return separatedListToArray(list, ","); // NOI18N
|