public void setAnswer(String variable, List<? extends CharSequence> values) {
        if (!isSubmitType()) {
            throw new IllegalStateException("Cannot set an answer if the form is not of type " +
            "\"submit\"");
        }
        FormField field = getField(variable);
        if (field != null) {
            // Check that the field can accept a collection of values
            switch (field.getType()) {
            case jid_multi:
            case list_multi:
            case list_single:
            case text_multi:
            case hidden:
                break;
            default:
                throw new IllegalArgumentException("This field only accept list of values.");
            }
            // Clear the old values
            field.resetValues();
            // Set the new values. The string representation of each value will be actually used.
            field.addValues(values);
        }
        else {
            throw new IllegalArgumentException("Couldn't find a field for the specified variable.");
        }
    }
public void setAnswer ( String variable , List < ? extends CharSequence > values ) { if ( ! isSubmitType ( ) ) { throw new IllegalStateException ( "Cannot set an answer if the form is not of type " + "\"submit\"" ) ; } FormField field = getField ( variable ) ; if ( field != null ) { switch ( field . getType ( ) ) { case jid_multi : case list_multi : case list_single : case text_multi : case hidden : break ; default : throw new IllegalArgumentException ( "This field only accept list of values." ) ; } field . resetValues ( ) ; field . addValues ( values ) ; } else { throw new IllegalArgumentException ( "Couldn't find a field for the specified variable." ) ; } }
Sets a new values to a given form's field. The field whose variable matches the requested
variable will be completed with the specified values. If no field could be found for
the specified variable then an exception will be raised.<p>

The Objects contained in the List could be of any type. The String representation of them
(i.e. #toString) will be actually used when sending the answer to the server.

@param variable the variable that was completed.
@param values the values that were answered.
@throws IllegalStateException if the form is not of type "submit".
@throws IllegalArgumentException if the form does not include the specified variable.