Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.questionnaire.bean
Class XInManyStringsQuestion  view XInManyStringsQuestion download XInManyStringsQuestion.java

java.lang.Object
  extended bycom.RuntimeCollective.questionnaire.bean.SimpleQuestion
      extended bycom.RuntimeCollective.questionnaire.bean.XInManyStringsQuestion
All Implemented Interfaces:
com.RuntimeCollective.webapps.bean.EntityBean, Question, java.io.Serializable
Direct Known Subclasses:
ManyInManyStringsQuestion, OneInManyStringsQuestion

public abstract class XInManyStringsQuestion
extends SimpleQuestion

Common superclass for OneInManyStringsQuestion and ManyInManyStringsQuestion - contains methods useful for both.

Version:
$Id: XInManyStringsQuestion.java,v 1.8 2003/09/30 15:12:53 joe Exp $

Field Summary
 java.lang.String CHOICES_TABLE
          Filled in by subclasses by the setDatabaseParticulars() method
 java.lang.String DATABASE_ID
          Filled in by subclasses by the setDatabaseParticulars() method
 java.lang.String DATABASE_KEY
          Filled in by subclasses by the setDatabaseParticulars() method
static java.lang.String DATABASE_TABLE
          The name of the database table for this bean type.
(package private)  java.util.Vector DisplayTexts
           
(package private)  java.util.Vector Keys
          The Keys and DisplayTexts
 java.lang.String REAL_DATABASE_TABLE
          Filled in by subclasses by the setDatabaseParticulars() method
 
Fields inherited from class com.RuntimeCollective.questionnaire.bean.SimpleQuestion
Description, id, Name, QuestionnaireId
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
INTERFACE_BEAN, NULL_ID
 
Constructor Summary
XInManyStringsQuestion()
          Construct a new blank XInManyStringsQuestion, giving it a new unique ID.
XInManyStringsQuestion(int id)
          Get a current XInManyStringsQuestion from the RuntimeDataSource, given an id.
 
Method Summary
 void addChoice(java.lang.String displayText)
          Add a Choice to this Question, generates a new key on the way
 void addChoice(java.lang.String key, java.lang.String displayText)
          Add a Choice to this Question
 void delete()
          Delete this bean from the database.
 java.lang.String getDisplayText(int position)
          Get a DisplayText from this Question
 java.util.Iterator getDisplayTexts()
          Get all DisplayTexts from this Question
 int getIndexOfKey(java.lang.String key)
          Get the (first) index of a Key in this Question
 java.lang.String getKey(int position)
          Get a Key from this Question
 java.util.Iterator getKeys()
          Get all Keys from this Question
abstract  boolean isAnswerValid(java.lang.Object answer)
          Check the validity of a raw Object answer for this Question.
 boolean isNewChoiceValid(java.lang.String choice)
          Check the validity of a new choice (as in, before actually adding it).
abstract  Answer makeNewAnswer(java.lang.Object answer)
          Make a new Answer to this Question, based on a row answer Object.
 void removeChoice(java.lang.String key)
          Remove a Choice from this Question
 boolean removeChoiceIfNoVotes(java.lang.String key)
          Remove a choice from this question only if no votes have been cast in the overall questionnaire
 void save()
          Save this bean to the database.
protected abstract  void setDatabaseParticulars()
          Subclasses must use this method to set the values of REAL_DATABASE_TABLE, CHOICES_TABLE, DATABASE_ID, and DATABASE_KEY, as used by the constructors and save/delete methods.
 void setDisplayText(int position, java.lang.String displayText)
          Set a DisplayText in this Question
 void setKey(int position, java.lang.String key)
          Set a Key in this Question
 
Methods inherited from class com.RuntimeCollective.questionnaire.bean.SimpleQuestion
getDescription, getId, getName, getQuestionnaire, setDescription, setId, setName, setQuestionnaire
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATABASE_TABLE

public static java.lang.String DATABASE_TABLE
The name of the database table for this bean type.


REAL_DATABASE_TABLE

public java.lang.String REAL_DATABASE_TABLE
Filled in by subclasses by the setDatabaseParticulars() method


CHOICES_TABLE

public java.lang.String CHOICES_TABLE
Filled in by subclasses by the setDatabaseParticulars() method


DATABASE_ID

public java.lang.String DATABASE_ID
Filled in by subclasses by the setDatabaseParticulars() method


DATABASE_KEY

public java.lang.String DATABASE_KEY
Filled in by subclasses by the setDatabaseParticulars() method


Keys

java.util.Vector Keys
The Keys and DisplayTexts


DisplayTexts

java.util.Vector DisplayTexts
Constructor Detail

XInManyStringsQuestion

public XInManyStringsQuestion()
Construct a new blank XInManyStringsQuestion, giving it a new unique ID.


XInManyStringsQuestion

public XInManyStringsQuestion(int id)
Get a current XInManyStringsQuestion from the RuntimeDataSource, given an id.

Method Detail

save

public void save()
Save this bean to the database.

Specified by:
save in interface Question
Overrides:
save in class SimpleQuestion

delete

public void delete()
Delete this bean from the database.

Specified by:
delete in interface Question
Overrides:
delete in class SimpleQuestion

makeNewAnswer

public abstract Answer makeNewAnswer(java.lang.Object answer)
                              throws com.RuntimeCollective.questionnaire.InvalidAnswerException
Make a new Answer to this Question, based on a row answer Object.
This checks the validity of the raw Object answer.

Specified by:
makeNewAnswer in interface Question
Specified by:
makeNewAnswer in class SimpleQuestion

isAnswerValid

public abstract boolean isAnswerValid(java.lang.Object answer)
Check the validity of a raw Object answer for this Question.

Specified by:
isAnswerValid in interface Question
Specified by:
isAnswerValid in class SimpleQuestion

addChoice

public void addChoice(java.lang.String key,
                      java.lang.String displayText)
Add a Choice to this Question


addChoice

public void addChoice(java.lang.String displayText)
Add a Choice to this Question, generates a new key on the way


removeChoice

public void removeChoice(java.lang.String key)
Remove a Choice from this Question


removeChoiceIfNoVotes

public boolean removeChoiceIfNoVotes(java.lang.String key)
Remove a choice from this question only if no votes have been cast in the overall questionnaire


isNewChoiceValid

public boolean isNewChoiceValid(java.lang.String choice)
Check the validity of a new choice (as in, before actually adding it). This checks that that choice text is not already used.


getKey

public java.lang.String getKey(int position)
Get a Key from this Question


setKey

public void setKey(int position,
                   java.lang.String key)
Set a Key in this Question


getDisplayText

public java.lang.String getDisplayText(int position)
Get a DisplayText from this Question


setDisplayText

public void setDisplayText(int position,
                           java.lang.String displayText)
Set a DisplayText in this Question


getIndexOfKey

public int getIndexOfKey(java.lang.String key)
Get the (first) index of a Key in this Question


getKeys

public java.util.Iterator getKeys()
Get all Keys from this Question


getDisplayTexts

public java.util.Iterator getDisplayTexts()
Get all DisplayTexts from this Question


setDatabaseParticulars

protected abstract void setDatabaseParticulars()
Subclasses must use this method to set the values of REAL_DATABASE_TABLE, CHOICES_TABLE, DATABASE_ID, and DATABASE_KEY, as used by the constructors and save/delete methods.