Java Utililty Methods Comma Separated List

List of utility methods to do Comma Separated List

Description

The list of methods to do Comma Separated List are organized into topic(s).

Method

intextractCommaItems(List list, String tags)
extract Comma Items
int count, offset;
String tag;
count = 0;
while (!tags.isEmpty()) {
    offset = tags.indexOf(",");
    if (offset >= 0) {
        tag = tags.substring(0, offset).trim();
        tags = tags.substring(tag.length() + 1).trim();
...
voidextractCommandsFromLine(final String line, final String delimiter, final StringBuilder bufferedCommand, final List extractedCommands)
Extracts SQL commands from string.
final String[] lineParts = line.split(delimiter);
for (int i = 0; i < lineParts.length; i++) {
    if (i == 0) {
        extractedCommands.add(bufferedCommand.toString() + " " + lineParts[i]);
        bufferedCommand.setLength(0);
        bufferedCommand.trimToSize();
    } else {
        if (i == (lineParts.length - 1) && !line.endsWith(delimiter)) {
...
StringformatCommand(List arguments)
Formats arguments
StringBuilder builder = new StringBuilder();
boolean redact = false; 
for (String string : arguments) {
    final boolean quote = string.contains(" ");
    if (quote) {
        builder.append("\"");
    builder.append(redact ? "{redacted}" : string);
...
StringgetAsCommaDelimitedString(List coll)
get As Comma Delimited String
StringBuffer strBuffer = new StringBuffer();
for (Iterator<?> iter = coll.iterator(); iter.hasNext();) {
    Object obj = iter.next();
    if (obj != null) {
        strBuffer.append(obj.toString());
        strBuffer.append(",");
return strBuffer.toString();
StringgetCommaList(List V)
Gets comma-separated list from a Vector of Strings.
StringBuffer SB = new StringBuffer();
int size = V.size();
for (int i = 0; i < size; i++) {
    if (SB.length() > 0)
        SB.append(',');
    SB.append(V.get(i));
return SB.toString();
...
StringgetCommandLine(List command)
get Command Line
if (command == null || command.isEmpty()) {
    return "";
String result = (String) command.get(0);
for (int i = 1; i < command.size(); i++) {
    result += " " + command.get(i);
return result;
...
intgetCommandLineOptionInt(List args, String param, int defaultValue)
get Command Line Option Int
String s = getCommandLineOption(args, param, null);
if (s == null)
    return defaultValue;
return Integer.parseInt(s);
StringgetCommandStr(List commandList)
get Command Str
String s = "";
for (String _command : commandList) {
    s += _command + " ";
return s;
StringgetCommaSeparatedList(Collection stringValues)
Utility method for creating display values
StringBuilder values = new StringBuilder();
if (stringValues.size() == 0) {
    return values.toString();
Iterator<String> i = stringValues.iterator();
values.append((String) i.next());
while (i.hasNext()) {
    values.append(", ");
...
StringgetCommaSeparatedList(List list)
Returns a string containing every element of the given list, with each element separated by a comma.
StringBuilder buffer = new StringBuilder();
String separator = "";
for (Object e : list) {
    buffer.append(separator).append(e);
    separator = ",";
return buffer.toString();