Constructs user prompt from a request.
This implementation adds (choice1,choice2,choice3,...) to the
prompt for MultipleChoiceInputRequest
s.
String prompt = request.getPrompt();
String def = request.getDefaultValue();
if (request instanceof MultipleChoiceInputRequest) {
StringBuffer sb = new StringBuffer(prompt);
sb.append(" (");
Enumeration e =
((MultipleChoiceInputRequest) request).getChoices().elements();
boolean first = true;
while (e.hasMoreElements()) {
if (!first) {
sb.append(", ");
}
String next = (String) e.nextElement();
if (next.equals(def)) {
sb.append('[");
}
sb.append(next);
if (next.equals(def)) {
sb.append(']");
}
first = false;
}
sb.append(")");
return sb.toString();
} else if (def != null) {
return prompt + " [" + def + "]";
} else {
return prompt;
}