org.jsurveylib.model
Class Page

java.lang.Object
  extended by org.jsurveylib.model.Page
All Implemented Interfaces:
Visitable

public class Page
extends java.lang.Object
implements Visitable

FOR INTERNAL USE ONLY.

A page in the survey. It contains a set of questions


Constructor Summary
Page()
           
 
Method Summary
 void accept(Visitor visitor)
           
 void addLabel(Label label)
          Add a label to the page
 void addQuestion(Question question)
          Add a question to this page
 boolean areRequirementsMet()
          Checks if all required questions have been answered correctly.
 int countElements()
          Returns the number of elements on the page.
 java.lang.String getLabel()
           
 java.util.List<Question> getQuestions()
          Returns all Questions in an unmodifiable list.
 java.util.List<SurveyElement> getSurveyElements()
          Returns all SurveyElements (Label and Question objects) in an unmodifiable list.
 void insertQuestion(Question question, int row)
           
 boolean isSkipped()
           
 int rowOf(java.lang.String questionId)
          Returns the row of this questionId or a number less than 0 if a question with this id does not exist on this page
 void setLabel(java.lang.String label)
          Change the label of this Page
 void setSkipped(boolean skipped)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Page

public Page()
Method Detail

addQuestion

public void addQuestion(Question question)
Add a question to this page

Parameters:
question - Question to be added

addLabel

public void addLabel(Label label)
Add a label to the page

Parameters:
label - The Label to be added

countElements

public int countElements()
Returns the number of elements on the page. An element is a question or a label.

Returns:
The number of elements on the page.

getSurveyElements

public java.util.List<SurveyElement> getSurveyElements()
Returns all SurveyElements (Label and Question objects) in an unmodifiable list.

Returns:
an unmodifiable list of all SurveyElements on this page

getQuestions

public java.util.List<Question> getQuestions()
Returns all Questions in an unmodifiable list.

Returns:
an unmodifiable list of all Question objects on this page

areRequirementsMet

public boolean areRequirementsMet()
Checks if all required questions have been answered correctly. If one question is mandatory and unanswered, this will return false unless it is unanswerable (uneditable/invisible). If any question on this page is invalid and answerable, this returns false. If a page is skipped, this always returns true.

Returns:
true if the user can go to the next page, otherwise, false.

getLabel

public java.lang.String getLabel()
Returns:
the label of this page

setLabel

public void setLabel(java.lang.String label)
Change the label of this Page

Parameters:
label - The label of this page

insertQuestion

public void insertQuestion(Question question,
                           int row)

rowOf

public int rowOf(java.lang.String questionId)
Returns the row of this questionId or a number less than 0 if a question with this id does not exist on this page

Parameters:
questionId - The id of the question to search for
Returns:
The row number of the question with this question id or a number less than 0 if this question does not exist on this page

accept

public void accept(Visitor visitor)
Specified by:
accept in interface Visitable

isSkipped

public boolean isSkipped()

setSkipped

public void setSkipped(boolean skipped)