Package org.javarosa.form.api
Class FormEntryModel
java.lang.Object
org.javarosa.form.api.FormEntryModel
public class FormEntryModel extends Object
The data model used during form entry. Represents the current state of the
form and provides access to the objects required by the view and the
controller.
-
Field Summary
Fields Modifier and Type Field Description static intREPEAT_STRUCTURE_LINEARRepeats should be a prompted linear set of questions, either with a fixed set of repetitions, or a prompt for creating a new one.static intREPEAT_STRUCTURE_NON_LINEARRepeats should be a custom juncture point with centralized "Create/Remove/Interact" hub. -
Constructor Summary
Constructors Constructor Description FormEntryModel(FormDef form)FormEntryModel(FormDef form, int repeatStructure)Creates a new entry model for the form with the appropriate repeat structure -
Method Summary
Modifier and Type Method Description FormIndexdecrementIndex(FormIndex index)FormEntryCaption[]getCaptionHierarchy()Returns a hierarchical list of FormEntryCaption objects for the current FormIndexFormEntryCaption[]getCaptionHierarchy(FormIndex index)Returns a hierarchical list of FormEntryCaption objects for the given FormIndexFormEntryCaptiongetCaptionPrompt()When you have a non-question event, a CaptionPrompt will have all the information needed to display to the user.FormEntryCaptiongetCaptionPrompt(FormIndex index)When you have a non-question event, a CaptionPrompt will have all the information needed to display to the user.intgetCompletedRelevantQuestionCount()Not yet implemented Should get the number of completed questions to this point.FormIndex[]getCompoundIndices()FormIndex[]getCompoundIndices(FormIndex container)intgetEvent()intgetEvent(FormIndex index)Given a FormIndex, returns the event this FormIndex represents.FormDefgetForm()FormIndexgetFormIndex()StringgetFormTitle()StringgetLanguage()String[]getLanguages()intgetNumQuestions()FormEntryPromptgetQuestionPrompt()FormEntryPromptgetQuestionPrompt(FormIndex index)intgetRepeatStructure()intgetTotalRelevantQuestionCount()Not yet implemented Should get the total possible questions given the current path through the form.protected TreeElementgetTreeElement(FormIndex index)FormIndexincrementIndex(FormIndex index)FormIndexincrementIndex(FormIndex index, boolean descend)booleanisIndexCompoundContainer()booleanisIndexCompoundContainer(FormIndex index)booleanisIndexCompoundElement()booleanisIndexCompoundElement(FormIndex index)booleanisIndexReadonly()booleanisIndexReadonly(FormIndex index)booleanisIndexRelevant()Determine if the current FormIndex is relevant.booleanisIndexRelevant(FormIndex index)Determine if the current FormIndex is relevant.protected voidsetLanguage(String language)voidsetQuestionIndex(FormIndex index)Set the FormIndex for the current question.
-
Field Details
-
REPEAT_STRUCTURE_LINEAR
public static final int REPEAT_STRUCTURE_LINEARRepeats should be a prompted linear set of questions, either with a fixed set of repetitions, or a prompt for creating a new one.- See Also:
- Constant Field Values
-
REPEAT_STRUCTURE_NON_LINEAR
public static final int REPEAT_STRUCTURE_NON_LINEARRepeats should be a custom juncture point with centralized "Create/Remove/Interact" hub.- See Also:
- Constant Field Values
-
-
Constructor Details
-
FormEntryModel
-
FormEntryModel
Creates a new entry model for the form with the appropriate repeat structure- Parameters:
form-repeatStructure- The structure of repeats (the repeat signals which should be sent during form entry)- Throws:
IllegalArgumentException- If repeatStructure is not valid
-
-
Method Details
-
getEvent
Given a FormIndex, returns the event this FormIndex represents.- See Also:
FormEntryController
-
getTreeElement
- Parameters:
index-- Returns:
-
getEvent
public int getEvent()- Returns:
- the event for the current FormIndex
- See Also:
FormEntryController
-
getFormTitle
- Returns:
- Form title
-
getQuestionPrompt
- Parameters:
index-- Returns:
- Returns the FormEntryPrompt for the specified FormIndex if the index represents a question.
-
getQuestionPrompt
- Returns:
- Returns the FormEntryPrompt for the current FormIndex if the index represents a question.
-
getCaptionPrompt
When you have a non-question event, a CaptionPrompt will have all the information needed to display to the user.- Parameters:
index-- Returns:
- Returns the FormEntryCaption for the given FormIndex if is not a question.
-
getCaptionPrompt
When you have a non-question event, a CaptionPrompt will have all the information needed to display to the user.- Returns:
- Returns the FormEntryCaption for the current FormIndex if is not a question.
-
getLanguages
- Returns:
- an array of Strings of the current langauges. Null if there are none.
-
getCompletedRelevantQuestionCount
public int getCompletedRelevantQuestionCount()Not yet implemented Should get the number of completed questions to this point. -
getTotalRelevantQuestionCount
public int getTotalRelevantQuestionCount()Not yet implemented Should get the total possible questions given the current path through the form. -
getNumQuestions
public int getNumQuestions()- Returns:
- total number of questions in the form, regardless of relevancy
-
getFormIndex
- Returns:
- Returns the current FormIndex referenced by the FormEntryModel.
-
setLanguage
-
getLanguage
- Returns:
- Returns the currently selected language.
-
setQuestionIndex
Set the FormIndex for the current question.- Parameters:
index-
-
getForm
- Returns:
-
getCaptionHierarchy
Returns a hierarchical list of FormEntryCaption objects for the given FormIndex- Parameters:
index-- Returns:
- list of FormEntryCaptions in hierarchical order
-
getCaptionHierarchy
Returns a hierarchical list of FormEntryCaption objects for the current FormIndex- Returns:
- list of FormEntryCaptions in hierarchical order
-
isIndexReadonly
- Parameters:
index-- Returns:
- true if the element at the specified index is read only
-
isIndexReadonly
public boolean isIndexReadonly()- Returns:
- true if the element at the current index is read only
-
isIndexRelevant
Determine if the current FormIndex is relevant. Only relevant indexes should be returned when filling out a form.- Parameters:
index-- Returns:
- true if current element at FormIndex is relevant
-
isIndexRelevant
public boolean isIndexRelevant()Determine if the current FormIndex is relevant. Only relevant indexes should be returned when filling out a form.- Returns:
- true if current element at FormIndex is relevant
-
isIndexCompoundContainer
public boolean isIndexCompoundContainer() -
isIndexCompoundContainer
-
isIndexCompoundElement
public boolean isIndexCompoundElement() -
isIndexCompoundElement
-
getCompoundIndices
-
getCompoundIndices
-
getRepeatStructure
public int getRepeatStructure()- Returns:
- The Current Repeat style which should be used.
-
incrementIndex
-
incrementIndex
-
decrementIndex
-