Package org.javarosa.core.model
Class QuestionDef
java.lang.Object
org.javarosa.core.model.QuestionDef
- All Implemented Interfaces:
IFormElement,Localizable,Externalizable
- Direct Known Subclasses:
RangeQuestion
public class QuestionDef extends Object implements IFormElement, Localizable
The definition of a Question to be presented to users when
filling out a form.
QuestionDef requires that any IDataReferences that are used
are contained in the FormDefRMS's PrototypeFactoryDeprecated in order
to be properly deserialized. If they aren't, an exception
will be thrown at the time of deserialization.
- Author:
- Daniel Kayiwa/Drew Roos
-
Constructor Summary
Constructors Constructor Description QuestionDef()QuestionDef(int id, int controlType) -
Method Summary
Modifier and Type Method Description voidaddChild(IFormElement fe)voidaddSelectChoice(SelectChoice choice)voidalertStateObservers(int changeFlags)ActionControllergetActionController()StringgetAdditionalAttribute(String namespace, String name)Retrieve the value of an additional attribute on a Question or GroupList<TreeElement>getAdditionalAttributes()Retrieve all additional attributes on a Question or GroupStringgetAppearanceAttr()IDataReferencegetBind()IFormElementgetChild(int i)List<IFormElement>getChildren()SelectChoicegetChoice(int i)SelectChoicegetChoiceForValue(String value)List<SelectChoice>getChoices()intgetControlType()intgetDeepChildCount()ItemsetBindinggetDynamicChoices()StringgetHelpInnerText()StringgetHelpText()Only if there is no localizable version of the <hint> available should this method be usedStringgetHelpTextID()intgetID()StringgetLabelInnerText()This method returns the regular innertext betweem label tags (if present) (<label>innertext</label>).intgetNumChoices()List<OSMTag>getOsmTags()StringgetTextID()get the TextID for this element used for localization purposesbooleanisComplex()true if the answer to this question yields xml tree data, not a simple string valuevoidlocaleChanged(String locale, Localizer localizer)Updates the current object with the locate given.voidreadExternal(DataInputStream dis, PrototypeFactory pf)voidregisterStateObserver(FormElementStateListener qsl)Registers a state observer for this element.voidremoveSelectChoice(SelectChoice choice)voidsetAdditionalAttribute(String namespace, String name, String value)Capture additional attributes on a Question or GroupvoidsetAppearanceAttr(String appearanceAttr)voidsetBind(IDataReference binding)voidsetChildren(List<IFormElement> v)voidsetControlType(int controlType)voidsetDynamicChoices(ItemsetBinding ib)voidsetHelpInnerText(String helpInnerText)voidsetHelpText(String helpText)Only if there is no localizable version of the <hint>available should this method be usedvoidsetHelpTextID(String textID)voidsetID(int id)voidsetLabelInnerText(String labelInnerText)voidsetOsmTags(List<OSMTag> tags)voidsetTextID(String textID)Set the textID for this element for use with localization.voidunregisterAll()voidunregisterStateObserver(FormElementStateListener qsl)Unregisters a state observer for this element.voidwriteExternal(DataOutputStream dos)
-
Constructor Details
-
QuestionDef
public QuestionDef() -
QuestionDef
public QuestionDef(int id, int controlType)
-
-
Method Details
-
getID
public int getID()- Specified by:
getIDin interfaceIFormElement- Returns:
- The unique ID of this element
-
setID
public void setID(int id)- Specified by:
setIDin interfaceIFormElement- Parameters:
id- The new unique ID of this element
-
getBind
- Specified by:
getBindin interfaceIFormElement- Returns:
- The data reference for this element
-
setBind
-
getControlType
public int getControlType() -
setControlType
public void setControlType(int controlType) -
setOsmTags
-
getOsmTags
-
getAppearanceAttr
- Specified by:
getAppearanceAttrin interfaceIFormElement- Returns:
-
setAppearanceAttr
- Specified by:
setAppearanceAttrin interfaceIFormElement
-
getHelpText
Only if there is no localizable version of the <hint> available should this method be used -
setHelpText
Only if there is no localizable version of the <hint>available should this method be used -
setAdditionalAttribute
Description copied from interface:IFormElementCapture additional attributes on a Question or Group- Specified by:
setAdditionalAttributein interfaceIFormElement
-
getAdditionalAttribute
Description copied from interface:IFormElementRetrieve the value of an additional attribute on a Question or Group- Specified by:
getAdditionalAttributein interfaceIFormElement- Returns:
-
getAdditionalAttributes
Description copied from interface:IFormElementRetrieve all additional attributes on a Question or Group- Specified by:
getAdditionalAttributesin interfaceIFormElement- Returns:
-
getActionController
- Specified by:
getActionControllerin interfaceIFormElement
-
getHelpTextID
-
setHelpTextID
-
addSelectChoice
-
removeSelectChoice
-
getChoices
-
getChoice
-
getNumChoices
public int getNumChoices() -
getChoiceForValue
-
getDynamicChoices
-
setDynamicChoices
-
isComplex
public boolean isComplex()true if the answer to this question yields xml tree data, not a simple string value -
localeChanged
Description copied from interface:LocalizableUpdates the current object with the locate given.- Specified by:
localeChangedin interfaceLocalizable
-
getChildren
- Specified by:
getChildrenin interfaceIFormElement- Returns:
- A List containing any children that this element might have. Null if the element is not able to have child elements.
-
setChildren
- Specified by:
setChildrenin interfaceIFormElement- Parameters:
v- the children of this element, if it is capable of having child elements.
-
addChild
- Specified by:
addChildin interfaceIFormElement- Parameters:
fe- The child element to be added
-
getChild
- Specified by:
getChildin interfaceIFormElement
-
readExternal
public void readExternal(DataInputStream dis, PrototypeFactory pf) throws IOException, DeserializationException- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionDeserializationException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
registerStateObserver
Description copied from interface:IFormElementRegisters a state observer for this element.- Specified by:
registerStateObserverin interfaceIFormElement
-
unregisterStateObserver
Description copied from interface:IFormElementUnregisters a state observer for this element.- Specified by:
unregisterStateObserverin interfaceIFormElement
-
unregisterAll
public void unregisterAll() -
alertStateObservers
public void alertStateObservers(int changeFlags) -
getDeepChildCount
public int getDeepChildCount()- Specified by:
getDeepChildCountin interfaceIFormElement- Returns:
- A recursive count of how many elements are ancestors of this element.
-
setLabelInnerText
-
getLabelInnerText
Description copied from interface:IFormElementThis method returns the regular innertext betweem label tags (if present) (<label>innertext</label>).- Specified by:
getLabelInnerTextin interfaceIFormElement- Returns:
- <label> innertext or null (if innertext is not present).
-
setHelpInnerText
-
getHelpInnerText
-
getTextID
Description copied from interface:IFormElementget the TextID for this element used for localization purposes- Specified by:
getTextIDin interfaceIFormElement- Returns:
- the TextID (bare, no ;form appended to it!!)
-
setTextID
Description copied from interface:IFormElementSet the textID for this element for use with localization.- Specified by:
setTextIDin interfaceIFormElement- Parameters:
textID- the plain TextID WITHOUT any form specification (e.g. ;long)
-