嘿伙计们,有人可以告诉我一种用逗号连接这些字符串的好方法
基本上我正在构建一个标题标准字符串,显示已选择哪些表单变量。我需要在值之间加上逗号并保持中断标签在适当的位置……有人能找到更好的方法吗?如果只是值,我不想要逗号
这是它目前的格式:
protected final String getCriteriaHeader(MetricFilterCriteriaForm form)
{
String filterCriteria = "<br/>";
}
if (form.isSacNone() || form.isSac1() || form.isSac2() || form.isSac3())
{
filterCriteria = filterCriteria + "SAC:";
}
if (form.isSacNone())
{
filterCriteria = filterCriteria + " NONE";
}
if (form.isSac1())
{
filterCriteria = filterCriteria + " 1";
}
if (form.isSac2())
{
filterCriteria = filterCriteria + " 2";
}
if (form.isSac3())
{
filterCriteria = filterCriteria + " 3";
}
if (form.isSac1() || form.isSac2() || form.isSac3())
{
filterCriteria = filterCriteria + "<br/>";
}
if (form.isRegularScheduleType() || form.isLotScheduleType() || form.isBatchScheduleType())
{
filterCriteria = filterCriteria + "Schedule Type:";
}
if (form.isRegularScheduleType())
{
filterCriteria = filterCriteria + " Regular";
}
if (form.isLotScheduleType())
{
filterCriteria = filterCriteria + " Lot";
}
if (form.isBatchScheduleType())
{
filterCriteria = filterCriteria + " Batch";
}
return filterCriteria;
}