code: public void setAnswer(String variable, String value) {
          FormField field = getField(variable);
          if (field == null) {
              throw new IllegalArgumentException("Field not found for the specified variable name.");
          }
          switch (field.getType()) {
          case text_multi:
          case text_private:
          case text_single:
          case jid_single:
          case hidden:
              break;
          default:
              throw new IllegalArgumentException("This field is not of type String.");
          }
          setAnswer(field, value);
      }
docs: Sets a new String value to a given form's field. The field whose variable matches the
  requested variable will be completed with the specified value. If no field could be found
  for the specified variable then an exception will be raised.<p>
  
  If the value to set to the field is not a basic type (e.g. String, boolean, int, etc.) you
  can use this message where the String value is the String representation of the object.
  
  @param variable the variable name that was completed.
  @param value the String value that was answered.
  @throws IllegalStateException if the form is not of type "submit".
  @throws IllegalArgumentException if the form does not include the specified variable or
  if the answer type does not correspond with the field type..