org.sourceforge.espro.model
Class Questionnaire

java.lang.Object
  extended by org.sourceforge.espro.model.AbstractModel
      extended by org.sourceforge.espro.model.Questionnaire
All Implemented Interfaces:
java.io.Serializable, ModelInterface

public class Questionnaire
extends AbstractModel

The questionnaire.

The questionnaire is a set of questions which are using the elicitation objects, that are used for one questionnaire. Here we will also store the results of the subjects.

Version:
1.1
Author:
Martin Kaffanke
See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList<Item> items
          A list of items in the questionnaire.
protected  Settings settings
          The settings.
 
Fields inherited from class org.sourceforge.espro.model.AbstractModel
pcs
 
Constructor Summary
Questionnaire()
          The constructor of the Questionnaire.
 
Method Summary
 void addItem(Item item)
          Adds an item to the questionnaire.
 void addItem(Item item, int index)
          Adds an item to the given position into the item list.
 void addItemListeners()
          This method has to be called whenever a questionnaire is created without the normal methods of the questionnaire.
 void cleanData()
          Removes all data from the questionnaire.
 void freeze()
           
 Item getCurrent()
          Returns the current item from the questionnaire.
 QData getData()
          Returns the questionnaire data
 java.io.File getFile()
          Returns the File object of the questionniare.
 Item getItem(java.lang.String id)
          Returns an item by a given id.
 java.util.ArrayList<Item> getItems()
          Returns the items.
 RunnableQuestionnaire getRunnable()
          Returns a runnable copy of the questionnaire.
 Settings getSettings()
          Returns the settings
 boolean isFrozen()
           
 int ItemCount()
          Returns the number of items the questionnaire currently has.
 Item newItem()
          Creates a new item to the questionnaire.
 void removeCurrentItem()
          Removes the current item from the Questionnaire.
 void setCurrent(Item currentItem)
          Sets the currentItem
 boolean setCurrentItem(java.lang.String id)
          Sets the current item from the given id (as string).
 void setData(QData data)
          Sets the questionnaire data.
 void setFile(java.io.File file)
          Sets the file where the questionnaire is stored.
 void setFrozen(boolean frozen)
           
 void setItemOrder(java.util.Vector itemVector)
          Sets the order of the items.
 void setItems(java.util.ArrayList<Item> items)
          Sets the Items of the questionnaire.
 void setSaved(boolean saved)
          We need to set all items to be saved if we save a questionnaire.
 void setSettings(Settings settings)
          Sets the settings.
 java.lang.String toString()
          Returns a String about an object.
 java.lang.String validate()
          Validates the questionnaire.
 
Methods inherited from class org.sourceforge.espro.model.AbstractModel
addPropertyChangeListener, addPropertyChangeListener, isSaved, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

settings

protected Settings settings
The settings.


items

protected java.util.ArrayList<Item> items
A list of items in the questionnaire.

Constructor Detail

Questionnaire

public Questionnaire()
The constructor of the Questionnaire.

Method Detail

addItem

public void addItem(Item item)
Adds an item to the questionnaire. This will be appended at the end of the list.

Parameters:
item - The item to add.

addItem

public void addItem(Item item,
                    int index)
Adds an item to the given position into the item list.

Parameters:
item - The item to add.
index - The position to insert the item.

removeCurrentItem

public void removeCurrentItem()
Removes the current item from the Questionnaire.


getFile

public java.io.File getFile()
Returns the File object of the questionniare. This can be null, if there is none set.

Returns:
The File object.

getItems

public java.util.ArrayList<Item> getItems()
Returns the items.

Returns:
The Items

getSettings

public Settings getSettings()
Returns the settings

Returns:
The settings

newItem

public Item newItem()
Creates a new item to the questionnaire.

Returns:
The new item.

setFile

public void setFile(java.io.File file)
Sets the file where the questionnaire is stored. This will normally be done by the QuestionnaireManager, there should be no use for the users.

Parameters:
file - the file to set

setItems

public void setItems(java.util.ArrayList<Item> items)
Sets the Items of the questionnaire. You should use this only once, if you load a new questionnaire from a file or something, because the GUI does not handle this.

Parameters:
items - the items to set

toString

public java.lang.String toString()
Returns a String about an object.

Overrides:
toString in class java.lang.Object
Returns:
The String.
See Also:
Object.toString()

getCurrent

public Item getCurrent()
Returns the current item from the questionnaire. The current item is normally the currently shown item.

Returns:
The current item.

setCurrent

public void setCurrent(Item currentItem)
Sets the currentItem

Parameters:
currentItem - The currentItem to set.

setCurrentItem

public boolean setCurrentItem(java.lang.String id)
Sets the current item from the given id (as string).

Parameters:
id - The id of the new current item.
Returns:
true if the item was found, false otherwise

setSaved

public void setSaved(boolean saved)
We need to set all items to be saved if we save a questionnaire.

Overrides:
setSaved in class AbstractModel
Parameters:
saved - true if it is saved.
See Also:
AbstractModel.setSaved(boolean)

addItemListeners

public void addItemListeners()
This method has to be called whenever a questionnaire is created without the normal methods of the questionnaire. At the moment this is used by the openQuestionnaire method of the QuestionnaireManager, because there the items list will be created without setting the correct listeners. Here we set all the listeners.


ItemCount

public int ItemCount()
Returns the number of items the questionnaire currently has.

Returns:
The number of items.

getItem

public Item getItem(java.lang.String id)
Returns an item by a given id.

Parameters:
id - The item id.
Returns:
The item.

getRunnable

public RunnableQuestionnaire getRunnable()
Returns a runnable copy of the questionnaire.

Returns:
The runnable copy.

setSettings

public void setSettings(Settings settings)
Sets the settings.

Parameters:
settings - The settings.

getData

public QData getData()
Returns the questionnaire data

Returns:
The Data

setData

public void setData(QData data)
Sets the questionnaire data.

Parameters:
data - The data.

cleanData

public void cleanData()
Removes all data from the questionnaire.


setItemOrder

public void setItemOrder(java.util.Vector itemVector)
Sets the order of the items. The Vector is a vector of readable strings, which is read out by the items Item.readableString() method.

Parameters:
itemVector - The vector of strings.

validate

public java.lang.String validate()
Validates the questionnaire. This tests if the items have all their own id.

Returns:
null if there is no error found, otherwise the error message.

freeze

public void freeze()

isFrozen

public boolean isFrozen()

setFrozen

public void setFrozen(boolean frozen)