public class FormDef extends java.lang.Object implements IFormElement, Localizable, Persistable, IMetaData
Modifier and Type | Class and Description |
---|---|
static class |
FormDef.EvalBehavior |
Modifier and Type | Field and Description |
---|---|
private java.util.List<IFormElement> |
children |
private IDag |
dagImpl |
private static java.lang.String |
DEFAULT_SUBMISSION_PROFILE |
private static EventNotifier |
defaultEventNotifier |
private static FormDef.EvalBehavior |
defaultMode |
private java.util.HashMap<java.lang.String,java.util.List<Action>> |
eventListeners |
private EventNotifier |
eventNotifier |
private EvaluationContext |
exprEvalContext |
private java.util.List<XFormExtension> |
extensions |
private java.util.HashMap<java.lang.String,FormInstance> |
formInstances |
private int |
id
A collection of group definitions.
|
private Localizer |
localizer
A unique external name that is used to identify the form between machines
|
private FormInstance |
mainInstance |
private java.lang.String |
name
The display title of the form.
|
private java.util.List<IConditionExpr> |
outputFragments |
private QuestionPreloader |
preloader |
static FormDef.EvalBehavior |
recommendedMode |
static java.lang.String |
STORAGE_KEY |
private java.util.HashMap<java.lang.String,SubmissionProfile> |
submissionProfiles |
static int |
TEMPLATING_RECURSION_LIMIT |
private java.lang.String |
title
The numeric unique identifier of the form definition on the local device
|
Constructor and Description |
---|
FormDef() |
FormDef(FormDef.EvalBehavior mode,
EventNotifier eventNotifier) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(IFormElement fe) |
void |
addNonMainInstance(FormInstance instance)
Getters and setters for the lists
|
void |
addSubmissionProfile(java.lang.String submissionId,
SubmissionProfile profile) |
Triggerable |
addTriggerable(Triggerable t)
Add a Condition to the form's Collection.
|
void |
attachControlsToInstanceData()
Link a deserialized instance back up with its parent FormDef.
|
private void |
attachControlsToInstanceData(TreeElement node) |
FormIndex |
buildIndex(java.util.List<java.lang.Integer> indexes,
java.util.List<java.lang.Integer> multiplicities,
java.util.List<IFormElement> elements) |
boolean |
canCreateRepeat(TreeReference repeatRef,
FormIndex repeatIndex) |
void |
collapseIndex(FormIndex index,
java.util.List<java.lang.Integer> indexes,
java.util.List<java.lang.Integer> multiplicities,
java.util.List<IFormElement> elements) |
void |
copyItemsetAnswer(QuestionDef q,
TreeElement targetNode,
IAnswerData data,
boolean midSurvey) |
void |
createNewRepeat(FormIndex index) |
FormIndex |
deleteRepeat(FormIndex index)
Deletes the inner-most repeat that this node belongs to and returns the
corresponding FormIndex.
|
FormIndex |
descendIntoRepeat(FormIndex index,
int repIndex) |
void |
dispatchFormEvent(java.lang.String event) |
boolean |
evaluateConstraint(TreeReference ref,
IAnswerData data) |
java.util.List<IFormElement> |
explodeIndex(FormIndex index)
Dereference the form index and return a List of all interstitial nodes
(top-level parent first; index target last)
Ignore 'new-repeat' node for now; just return/stop at ref to
yet-to-be-created repeat node (similar to repeats that already exist)
|
java.lang.String |
fillTemplateString(java.lang.String template,
TreeReference contextRef) |
java.lang.String |
fillTemplateString(java.lang.String template,
TreeReference contextRef,
java.util.HashMap<java.lang.String,?> variables) |
void |
finalizeTriggerables()
Finalize the DAG associated with the form's triggered conditions.
|
static QuestionDef |
findQuestionByRef(TreeReference ref,
IFormElement fe) |
void |
fireEvent() |
java.lang.String |
getAdditionalAttribute(java.lang.String namespace,
java.lang.String name)
Retrieve the value of an additional attribute on a Question or Group
|
java.util.List<TreeElement> |
getAdditionalAttributes()
Retrieve all additional attributes on a Question or Group
|
java.lang.String |
getAppearanceAttr()
Appearance isn't a valid attribute for form, but this method must be
included as a result of conforming to the IFormElement interface.
|
IDataReference |
getBind() |
IFormElement |
getChild(FormIndex index) |
IFormElement |
getChild(int i) |
TreeReference |
getChildInstanceRef(FormIndex index) |
TreeReference |
getChildInstanceRef(java.util.List<IFormElement> elements,
java.util.List<java.lang.Integer> multiplicities) |
java.util.List<IFormElement> |
getChildren() |
IConditionExpr |
getConditionExpressionForTrueAction(TreeElement instanceNode,
int action)
Pull this in from FormOverview so that we can make fields private.
|
int |
getDeepChildCount() |
EvaluationContext |
getEvaluationContext() |
java.util.List<Action> |
getEventListeners(java.lang.String event) |
EventNotifier |
getEventNotifier() |
<X extends XFormExtension> |
getExtension(java.lang.Class<X> extension) |
int |
getID() |
FormInstance |
getInstance() |
java.lang.String |
getLabelInnerText()
Not applicable here.
|
Localizer |
getLocalizer() |
FormInstance |
getMainInstance()
Get the main instance
|
java.util.HashMap<java.lang.String,java.lang.Object> |
getMetaData() |
java.lang.String |
getMetaData(java.lang.String fieldName) |
java.lang.String[] |
getMetaDataFields() |
java.lang.String |
getName() |
FormInstance |
getNonMainInstance(java.lang.String name)
Get an instance based on a name
|
java.util.Enumeration<FormInstance> |
getNonMainInstances()
Get the non main instances
|
int |
getNumRepetitions(FormIndex index) |
java.util.List<IConditionExpr> |
getOutputFragments() |
QuestionPreloader |
getPreloader() |
SubmissionProfile |
getSubmissionProfile() |
java.lang.String |
getTextID()
Not applicable
|
java.lang.String |
getTitle() |
private void |
initEvalContext(EvaluationContext ec) |
void |
initialize(boolean newInstance,
InstanceInitializationFactory factory)
meant to be called after deserialization and initialization of handlers
|
private java.util.Collection<QuickTriggerable> |
initializeTriggerables(TreeReference rootRef,
boolean midSurvey)
Walks the current set of conditions, and evaluates each of them with the
current context.
|
boolean |
isRepeatRelevant(TreeReference repeatRef) |
void |
localeChanged(java.lang.String locale,
Localizer localizer)
Updates the current object with the locate given.
|
static boolean |
objectEquals(java.lang.Object object1,
java.lang.Object object2)
Copied from commons-lang 2.6: For reviewing purposes only.
|
void |
populateDynamicChoices(ItemsetBinding itemset,
TreeReference curQRef)
Identify the itemset in the backend model, and create a set of
SelectChoice objects at the current question reference based on the data
in the model.
|
boolean |
postProcessInstance() |
private boolean |
postProcessInstance(TreeElement node)
Iterate over the form's data bindings, and evaluate all post procesing
calls.
|
void |
preloadInstance(TreeElement node)
Preload the Data Model with the preload values that are enumerated in the
data bindings.
|
void |
printTriggerables(java.lang.String path)
For debugging
|
void |
readExternal(java.io.DataInputStream dis,
PrototypeFactory pf)
Reads the form definition object from the supplied stream.
|
void |
registerEventListener(java.lang.String event,
Action action) |
void |
registerStateObserver(FormElementStateListener qsl)
Registers a state observer for this element.
|
void |
reportDependencyCycles(XFormParserReporter reporter)
Report any dependency cycles based upon the triggerIndex array.
|
private void |
resetEvaluationContext() |
void |
seal()
Frees all of the components of this form which are no longer needed once
it is completed.
|
void |
setAdditionalAttribute(java.lang.String namespace,
java.lang.String name,
java.lang.String value)
Capture additional attributes on a Question or Group
|
void |
setAnswer(IAnswerData data,
TreeElement node) |
void |
setAnswer(IAnswerData data,
TreeReference ref) |
void |
setAppearanceAttr(java.lang.String appearanceAttr)
Appearance isn't a valid attribute for form, but this method must be
included as a result of conforming to the IFormElement interface.
|
void |
setChildren(java.util.List<IFormElement> children) |
static void |
setDefaultEventNotifier(EventNotifier eventNotifier) |
void |
setDefaultSubmission(SubmissionProfile profile) |
static void |
setEvalBehavior(FormDef.EvalBehavior mode) |
void |
setEventNotifier(EventNotifier eventNotifier) |
void |
setID(int id) |
void |
setInstance(FormInstance fi)
Set the main instance
|
void |
setLocalizer(Localizer l) |
void |
setName(java.lang.String name) |
void |
setOutputFragments(java.util.List<IConditionExpr> outputFragments) |
void |
setPreloader(QuestionPreloader preloads) |
void |
setTextID(java.lang.String textID)
Not applicable
|
void |
setTitle(java.lang.String title) |
void |
setValue(IAnswerData data,
TreeReference ref,
boolean midSurvey) |
void |
setValue(IAnswerData data,
TreeReference ref,
TreeElement node,
boolean midSurvey) |
java.lang.String |
toString() |
java.util.Collection<QuickTriggerable> |
triggerTriggerables(TreeReference ref,
boolean midSurvey)
The entry point for the DAG cascade after a value is changed in the model.
|
void |
unregisterStateObserver(FormElementStateListener qsl)
Unregisters a state observer for this element.
|
ValidateOutcome |
validate(boolean markCompleted) |
void |
writeExternal(java.io.DataOutputStream dos)
Writes the form definition object to the supplied stream.
|
public static final java.lang.String STORAGE_KEY
public static final int TEMPLATING_RECURSION_LIMIT
public static final FormDef.EvalBehavior recommendedMode
private static FormDef.EvalBehavior defaultMode
private static EventNotifier defaultEventNotifier
private java.util.List<IFormElement> children
private int id
private java.lang.String title
private java.lang.String name
private java.util.List<XFormExtension> extensions
private Localizer localizer
private java.util.List<IConditionExpr> outputFragments
private IDag dagImpl
private EvaluationContext exprEvalContext
private QuestionPreloader preloader
private static java.lang.String DEFAULT_SUBMISSION_PROFILE
private java.util.HashMap<java.lang.String,SubmissionProfile> submissionProfiles
private java.util.HashMap<java.lang.String,FormInstance> formInstances
private FormInstance mainInstance
private java.util.HashMap<java.lang.String,java.util.List<Action>> eventListeners
private EventNotifier eventNotifier
public FormDef()
public FormDef(FormDef.EvalBehavior mode, EventNotifier eventNotifier)
public static final void setEvalBehavior(FormDef.EvalBehavior mode)
public static void setDefaultEventNotifier(EventNotifier eventNotifier)
public EventNotifier getEventNotifier()
public void setEventNotifier(EventNotifier eventNotifier)
public void addNonMainInstance(FormInstance instance)
public FormInstance getNonMainInstance(java.lang.String name)
name
- string namepublic java.util.Enumeration<FormInstance> getNonMainInstances()
public void setInstance(FormInstance fi)
fi
- public FormInstance getMainInstance()
public FormInstance getInstance()
public void fireEvent()
public void addChild(IFormElement fe)
addChild
in interface IFormElement
fe
- The child element to be addedpublic IFormElement getChild(int i)
getChild
in interface IFormElement
public IFormElement getChild(FormIndex index)
public java.util.List<IFormElement> explodeIndex(FormIndex index)
index
- public TreeReference getChildInstanceRef(FormIndex index)
index
- public TreeReference getChildInstanceRef(java.util.List<IFormElement> elements, java.util.List<java.lang.Integer> multiplicities)
elements
- multiplicities
- public void setLocalizer(Localizer l)
public IDataReference getBind()
getBind
in interface IFormElement
public void setValue(IAnswerData data, TreeReference ref, boolean midSurvey)
public void setValue(IAnswerData data, TreeReference ref, TreeElement node, boolean midSurvey)
public static boolean objectEquals(java.lang.Object object1, java.lang.Object object2)
Compares two objects for equality, where either one or both objects may be
null
.
ObjectUtils.equals(null, null) = true ObjectUtils.equals(null, "") = false ObjectUtils.equals("", null) = false ObjectUtils.equals("", "") = true ObjectUtils.equals(Boolean.TRUE, null) = false ObjectUtils.equals(Boolean.TRUE, "true") = false ObjectUtils.equals(Boolean.TRUE, Boolean.TRUE) = true ObjectUtils.equals(Boolean.TRUE, Boolean.FALSE) = false
object1
- the first object, may be null
object2
- the second object, may be null
true
if the values of both objects are the samepublic void setAnswer(IAnswerData data, TreeReference ref)
public void setAnswer(IAnswerData data, TreeElement node)
public FormIndex deleteRepeat(FormIndex index)
index
- public void createNewRepeat(FormIndex index) throws InvalidReferenceException
InvalidReferenceException
public boolean isRepeatRelevant(TreeReference repeatRef)
public boolean canCreateRepeat(TreeReference repeatRef, FormIndex repeatIndex)
public void copyItemsetAnswer(QuestionDef q, TreeElement targetNode, IAnswerData data, boolean midSurvey) throws InvalidReferenceException
InvalidReferenceException
public Triggerable addTriggerable(Triggerable t)
t
- the condition to be setpublic void reportDependencyCycles(XFormParserReporter reporter)
reporter
- public void finalizeTriggerables() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- - If the trigger ordering contains an illegal cycle and the
triggers can't be laid out appropriatelyprivate java.util.Collection<QuickTriggerable> initializeTriggerables(TreeReference rootRef, boolean midSurvey)
public java.util.Collection<QuickTriggerable> triggerTriggerables(TreeReference ref, boolean midSurvey)
ref
- The full contextualized unambiguous reference of the value that
was changed.public ValidateOutcome validate(boolean markCompleted)
public boolean evaluateConstraint(TreeReference ref, IAnswerData data)
private void resetEvaluationContext()
public EvaluationContext getEvaluationContext()
private void initEvalContext(EvaluationContext ec)
ec
- The new Evaluation Contextpublic java.lang.String fillTemplateString(java.lang.String template, TreeReference contextRef)
public java.lang.String fillTemplateString(java.lang.String template, TreeReference contextRef, java.util.HashMap<java.lang.String,?> variables)
public void populateDynamicChoices(ItemsetBinding itemset, TreeReference curQRef)
itemset
- The binding for an itemset, where the choices will be populatedcurQRef
- A reference to the current question's element, which will be
used to determine the values to be chosen from.public QuestionPreloader getPreloader()
public void setPreloader(QuestionPreloader preloads)
preloads
- the preloads to setpublic void localeChanged(java.lang.String locale, Localizer localizer)
Localizable
localeChanged
in interface Localizable
public java.lang.String toString()
toString
in class java.lang.Object
public void preloadInstance(TreeElement node)
public boolean postProcessInstance()
private boolean postProcessInstance(TreeElement node)
public void readExternal(java.io.DataInputStream dis, PrototypeFactory pf) throws java.io.IOException, DeserializationException
readExternal
in interface Externalizable
dis
- - the stream to read from.java.io.IOException
java.lang.InstantiationException
java.lang.IllegalAccessException
DeserializationException
public void initialize(boolean newInstance, InstanceInitializationFactory factory)
newInstance
- true if the form is to be used for a new entry interaction,
false if it is using an existing IDataModelpublic void writeExternal(java.io.DataOutputStream dos) throws java.io.IOException
writeExternal
in interface Externalizable
dos
- - the stream to write to.java.io.IOException
public void collapseIndex(FormIndex index, java.util.List<java.lang.Integer> indexes, java.util.List<java.lang.Integer> multiplicities, java.util.List<IFormElement> elements)
public FormIndex buildIndex(java.util.List<java.lang.Integer> indexes, java.util.List<java.lang.Integer> multiplicities, java.util.List<IFormElement> elements)
public int getNumRepetitions(FormIndex index)
public int getDeepChildCount()
getDeepChildCount
in interface IFormElement
public void registerStateObserver(FormElementStateListener qsl)
IFormElement
registerStateObserver
in interface IFormElement
public void unregisterStateObserver(FormElementStateListener qsl)
IFormElement
unregisterStateObserver
in interface IFormElement
public java.util.List<IFormElement> getChildren()
getChildren
in interface IFormElement
public void setChildren(java.util.List<IFormElement> children)
setChildren
in interface IFormElement
children
- the children of this element, if it is capable of having
child elements.public java.lang.String getTitle()
public void setTitle(java.lang.String title)
public int getID()
getID
in interface IFormElement
getID
in interface Persistable
public void setID(int id)
setID
in interface IFormElement
setID
in interface Persistable
id
- The new unique ID of this elementpublic java.lang.String getName()
public void setName(java.lang.String name)
public Localizer getLocalizer()
public java.util.List<IConditionExpr> getOutputFragments()
public void setOutputFragments(java.util.List<IConditionExpr> outputFragments)
public java.util.HashMap<java.lang.String,java.lang.Object> getMetaData()
getMetaData
in interface IMetaData
public java.lang.String getMetaData(java.lang.String fieldName)
getMetaData
in interface IMetaData
public java.lang.String[] getMetaDataFields()
getMetaDataFields
in interface IMetaData
public void attachControlsToInstanceData()
private void attachControlsToInstanceData(TreeElement node)
public static QuestionDef findQuestionByRef(TreeReference ref, IFormElement fe)
public java.lang.String getAppearanceAttr()
getAppearanceAttr
in interface IFormElement
public void setAppearanceAttr(java.lang.String appearanceAttr)
setAppearanceAttr
in interface IFormElement
public java.lang.String getLabelInnerText()
getLabelInnerText
in interface IFormElement
public java.lang.String getTextID()
getTextID
in interface IFormElement
public void setTextID(java.lang.String textID)
setTextID
in interface IFormElement
textID
- the plain TextID WITHOUT any form specification (e.g. ;long)public void setDefaultSubmission(SubmissionProfile profile)
public void addSubmissionProfile(java.lang.String submissionId, SubmissionProfile profile)
public SubmissionProfile getSubmissionProfile()
public void setAdditionalAttribute(java.lang.String namespace, java.lang.String name, java.lang.String value)
IFormElement
setAdditionalAttribute
in interface IFormElement
public java.lang.String getAdditionalAttribute(java.lang.String namespace, java.lang.String name)
IFormElement
getAdditionalAttribute
in interface IFormElement
public java.util.List<TreeElement> getAdditionalAttributes()
IFormElement
getAdditionalAttributes
in interface IFormElement
public java.util.List<Action> getEventListeners(java.lang.String event)
public void registerEventListener(java.lang.String event, Action action)
public void dispatchFormEvent(java.lang.String event)
public <X extends XFormExtension> X getExtension(java.lang.Class<X> extension)
public void seal()
public IConditionExpr getConditionExpressionForTrueAction(TreeElement instanceNode, int action)
instanceNode
- action
- public final void printTriggerables(java.lang.String path)