001: /*
002: * Project: AMODA - Abstract Modeled Application
003: * Class: de.gulden.framework.amoda.generic.interaction.GenericQuestion
004: * Version: snapshot-beautyj-1.1
005: *
006: * Date: 2004-09-29
007: *
008: * This is a snapshot version of the AMODA 0.2 development branch,
009: * it is not released as a seperate version.
010: * For AMODA, see http://amoda.berlios.de/.
011: *
012: * This is licensed under the GNU Lesser General Public License (LGPL)
013: * and comes with NO WARRANTY.
014: *
015: * Author: Jens Gulden
016: * Email: amoda@jensgulden.de
017: */
018:
019: package de.gulden.framework.amoda.generic.interaction;
020:
021: import de.gulden.framework.amoda.generic.option.*;
022: import de.gulden.framework.amoda.model.interaction.Question;
023: import de.gulden.framework.amoda.model.option.*;
024: import java.lang.*;
025: import java.util.*;
026:
027: /**
028: * Class GenericQuestion.
029: *
030: * @author Jens Gulden
031: * @version snapshot-beautyj-1.1
032: */
033: public class GenericQuestion extends GenericMessageAbstract implements
034: Question {
035:
036: // ------------------------------------------------------------------------
037: // --- fields ---
038: // ------------------------------------------------------------------------
039:
040: public String answers = "yes,no";
041:
042: public String defaultAnswer = "";
043:
044: protected volatile String answer;
045:
046: // ------------------------------------------------------------------------
047: // --- constructor ---
048: // ------------------------------------------------------------------------
049:
050: public GenericQuestion() {
051: setType(QUESTION_MESSAGE);
052: }
053:
054: // ------------------------------------------------------------------------
055: // --- methods ---
056: // ------------------------------------------------------------------------
057:
058: public void reset() {
059: setAnswer(null);
060: }
061:
062: public void perform() {
063: ((de.gulden.framework.amoda.generic.core.GenericApplicationEnvironment) getApplication()
064: .getEnvironment()).doQuestion(this );
065: }
066:
067: public Collection getAnswerOptions() {
068: Vector v = new Vector();
069: for (StringTokenizer st = new StringTokenizer(answers, ",",
070: false); st.hasMoreTokens();) {
071: String optionId = st.nextToken();
072: Option option = (Option) getApplication().getOptions().get(
073: optionId);
074: v.add(option);
075: }
076: return v;
077: }
078:
079: public String getAnswers() {
080: return answers;
081: }
082:
083: public void setAnswers(String _answers) {
084: answers = _answers;
085: }
086:
087: public String getDefaultAnswer() {
088: return defaultAnswer;
089: }
090:
091: public void setDefaultAnswer(String _defaultAnswer) {
092: defaultAnswer = _defaultAnswer;
093: }
094:
095: public Option getDefaultAnswerOption() {
096: return getApplication().getOptions().getOptionEntry(
097: getDefaultAnswer());
098: }
099:
100: public String getAnswer() {
101: return answer;
102: }
103:
104: public void setAnswer(String _answer) {
105: answer = _answer;
106: }
107:
108: } // end GenericQuestion
|