This package provides a means for creating a set of questions to be asked by a "wizard".

A wizard is a tool that asks the user a series of simple questions, in order to achieve a complex goal, such as installing, configuring or using a complex piece of software. Each question is represented by an object which defines the text of the question to be asked, and the type of the response that is expected. Each question also specifies the next question to be asked, which may depend on the answers to any of the questions that have already been asked. All questions belong to an "interview", and the complete set of questions for a wizard may be grouped into one or more different interviews.

By design, questions are simple to write and do not have any dependence on any GUI API: the presentation of the questions of a wizard is left to a separate utility: more than one may be available.

Guide to writing wizards

The questions for a wizard are most conveniently written as a series of anonymous inner classes. Each question extends the appropriate subtype of {@link com.sun.interview.Question Question}, depending on the appropriate type of response. Normally, the arguments to the supertype constructor are the interview which contains the question, and a short name to identify the question. Anonymous initializers are used to complete the setup of the question, and each question defines a {@link com.sun.interview.Question#getNext getNext} method to define its successor. This method will be called whenever the response to the question changes, and may return different values depending on the response to this question and any other questions that have already been asked. If the user has not yet answered a question, or has answered it inciorrectly, the getNext method may return null. This will prevent any tool processing the questions from moving beyond this question until a valid response has been given.
    Question name = new StringQuestion(interview, "name") {
	{
	    setText("what is your name?");
	}

	protected Question getNext() {
	    return age;
	}
    }

Questions can conveniently be created as fields within an implementation of {@link com.sun.interview.Interview Interview}.

    Interview personal = new Interview("personal") {
	{
	    setFirstQuestion(name);
	    setTitle("personal questions");
	}

	private Question name = new StringQuestion(this, "name") {
	    ...
	};

	private Question age = new IntQuestion(this, "int") {
	    ...
	};

	private Question sex = new ChoiceQuestion(this, "sex") {
	    ...
	};
    }
{@link com.sun.interview.FinalQuestion FinalQuestion} is a special type of question that is used to indicate the end of an interview, and does not provide any response. You may still choose to set some text to be presented to the user, to announce that they have reached the last question.
    Question end = new FinalQuestion(interview, "end") {
	setText("This completes the interview.");
    };
You can invoke one interview from another by using the {@link com.sun.interview.Interview#callInterview callInterview} method, to recursively invoke a sub-interview before continuing to process to the next question in the current interview. The sub-interview will begin at the first question in that interview, and will proceed until an instance of FinalQuestion is found, at which point control will revert to the successor question given to callInterview.
    Question a5 = new ...Question(....) {
	....

	protected Question getNext() {
	    callInterview(subInterview, a6);
	}
    };

    // this question will be asked after the subInterview has been completed
    Question a6 = new ....Question(...) {
	...
    };
@since 1.0