Package org.javarosa.form.api
Class FormEntryCaption
java.lang.Object
org.javarosa.form.api.FormEntryCaption
- All Implemented Interfaces:
FormElementStateListener
- Direct Known Subclasses:
FormEntryPrompt
public class FormEntryCaption extends Object implements FormElementStateListener
This class gives you all the information you need to display a caption when
your current FormIndex references a GroupEvent, RepeatPromptEvent, or
RepeatEvent.
- Author:
- Simon Kelly
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classFormEntryCaption.RepeatOptions -
Field Summary
Fields Modifier and Type Field Description protected IFormElementelementstatic StringTEXT_FORM_AUDIOstatic StringTEXT_FORM_IMAGEstatic StringTEXT_FORM_LONGstatic StringTEXT_FORM_SHORTstatic StringTEXT_FORM_VIDEOprotected IQuestionWidgetviewWidgetFields inherited from interface org.javarosa.core.model.FormElementStateListener
CHANGE_DATA, CHANGE_ENABLED, CHANGE_INIT, CHANGE_LOCALE, CHANGE_OTHER, CHANGE_RELEVANT, CHANGE_REQUIRED -
Constructor Summary
Constructors Constructor Description FormEntryCaption()This empty constructor exists for convenience of any supertypes of this promptFormEntryCaption(FormDef form, FormIndex index)Creates a FormEntryCaption for the element at the given index in the form. -
Method Summary
Modifier and Type Method Description voidformElementStateChanged(IFormElement element, int changeFlags)voidformElementStateChanged(TreeElement instanceNode, int changeFlags)StringgetAppearanceHint()StringgetAudioText()Convenience method Get audio URI from Text form for THIS element (if available)IFormElementgetFormElement()StringgetImageText()Convenience method Get image URI form of text for THIS element (if available)FormIndexgetIndex()protected StringgetIText(String textID, String form)StringgetLongText()Convenience method Get longText form of text for THIS element (if available) !!Falls back to default form if 'long' form does not exist.!! Use getSpecialFormQuestionText() if you want short form only.intgetMultiplicity()intgetNumRepetitions()StringgetQuestionText()Same as getQuestionText(String textID), but for the current element textID;StringgetQuestionText(String textID)Attempts to return question text for this element.FormEntryCaption.RepeatOptionsgetRepeatOptions()StringgetRepeatText(String typeKey)List<String>getRepetitionsText()StringgetRepetitionText(boolean newrep)StringgetShortText()Convenience method Get shortText form of text for THIS element (if available) !!Falls back to default form if 'short' form does not exist.!! Use getSpecialFormQuestionText() if you want short form only.StringgetSpecialFormQuestionText(String form)Same as getSpecialFormQuestionText(String textID,String form) except that the textID defaults to the textID of the current element.StringgetSpecialFormQuestionText(String textID, String form)This method is generally used to retrieve special forms of a textID, e.g.protected StringgetTextID()protected Localizerlocalizer()voidregister(IQuestionWidget viewWidget)booleanrepeats()protected StringsubstituteStringArgs(String templateStr)voidunregister()
-
Field Details
-
element
-
TEXT_FORM_LONG
- See Also:
- Constant Field Values
-
TEXT_FORM_SHORT
- See Also:
- Constant Field Values
-
TEXT_FORM_AUDIO
- See Also:
- Constant Field Values
-
TEXT_FORM_IMAGE
- See Also:
- Constant Field Values
-
TEXT_FORM_VIDEO
- See Also:
- Constant Field Values
-
viewWidget
-
-
Constructor Details
-
FormEntryCaption
public FormEntryCaption()This empty constructor exists for convenience of any supertypes of this prompt -
FormEntryCaption
Creates a FormEntryCaption for the element at the given index in the form.- Parameters:
form-index-
-
-
Method Details
-
getLongText
Convenience method Get longText form of text for THIS element (if available) !!Falls back to default form if 'long' form does not exist.!! Use getSpecialFormQuestionText() if you want short form only.- Returns:
- longText form
-
getShortText
Convenience method Get shortText form of text for THIS element (if available) !!Falls back to default form if 'short' form does not exist.!! Use getSpecialFormQuestionText() if you want short form only.- Returns:
- shortText form
-
getAudioText
Convenience method Get audio URI from Text form for THIS element (if available)- Returns:
- audio URI form stored in current locale of Text, returns null if not available
-
getImageText
Convenience method Get image URI form of text for THIS element (if available)- Returns:
- URI of image form stored in current locale of Text, returns null if not available
-
getQuestionText
Attempts to return question text for this element. Will check for text in the following order:
Localized Text (long form) -> Localized Text (no special form)
If no textID is specified, method will return THIS element's labelInnerText.- Parameters:
textID- - The textID of the text you're trying to retrieve. iftextID == nullwill get LabelInnerText for current element- Returns:
- Question Text.
nullif no text for this element exists (after all fallbacks). - Throws:
RunTimeException- if this method is called on an element that is NOT a QuestionDef
-
getQuestionText
Same as getQuestionText(String textID), but for the current element textID;- Returns:
- Question Text
- See Also:
getQuestionText(java.lang.String)
-
getSpecialFormQuestionText
This method is generally used to retrieve special forms of a textID, e.g. "audio", "video", etc.- Parameters:
textID- - The textID of the text you're trying to retrieve.form- - special text form of textID you're trying to retrieve.- Returns:
- Special Form Question Text.
nullif no text for this element exists (with the specified special form). - Throws:
RunTimeException- if this method is called on an element that is NOT a QuestionDef
-
getSpecialFormQuestionText
Same as getSpecialFormQuestionText(String textID,String form) except that the textID defaults to the textID of the current element.- Parameters:
form- - special text form of textID you're trying to retrieve.- Returns:
- Special Form Question Text.
nullif no text for this element exists (with the specified special form). - Throws:
RunTimeException- if this method is called on an element that is NOT a QuestionDef
-
getIText
- Parameters:
textID- - the textID of the text you'd like to retrieveform- - the special form (e.g. "audio","long", etc) of the text- Returns:
- the IText for the parameters specified.
-
getRepeatText
-
getNumRepetitions
public int getNumRepetitions() -
getRepetitionText
-
getRepetitionsText
-
getRepeatOptions
-
getAppearanceHint
-
substituteStringArgs
-
getMultiplicity
public int getMultiplicity() -
getFormElement
-
repeats
public boolean repeats()- Returns:
- true if this represents a
element
-
getIndex
-
localizer
-
register
-
unregister
public void unregister() -
formElementStateChanged
- Specified by:
formElementStateChangedin interfaceFormElementStateListener
-
formElementStateChanged
- Specified by:
formElementStateChangedin interfaceFormElementStateListener
-
getTextID
-