public class FormDef extends Object implements IFormElement, Localizable, Persistable, IMetaData, ActionController.ActionResultProcessor
| Modifier and Type | Field and Description |
|---|---|
static String |
STORAGE_KEY |
static int |
TEMPLATING_RECURSION_LIMIT |
| Constructor and Description |
|---|
FormDef() |
FormDef(EventNotifier eventNotifier) |
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(IFormElement fe) |
void |
addNonMainInstance(DataInstance instance)
Getters and setters for the lists
|
void |
addParseError(String error) |
void |
addParseWarning(String warning) |
void |
addSubmissionProfile(String submissionId,
SubmissionProfile profile) |
Triggerable |
addTriggerable(Triggerable t)
Adds a Condition to the form's Collection.
|
void |
attachControlsToInstanceData()
Links a deserialized instance back up with its parent FormDef.
|
FormIndex |
buildIndex(List<Integer> indexes,
List<Integer> multiplicities,
List<IFormElement> elements) |
boolean |
canCreateRepeat(TreeReference repeatRef,
FormIndex repeatIndex) |
void |
collapseIndex(FormIndex index,
List<Integer> indexes,
List<Integer> multiplicities,
List<IFormElement> elements) |
void |
copyItemsetAnswer(QuestionDef q,
TreeElement targetNode,
IAnswerData data) |
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) |
boolean |
evaluateConstraint(TreeReference ref,
IAnswerData data) |
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)
|
String |
fillTemplateString(String template,
TreeReference contextRef) |
String |
fillTemplateString(String template,
TreeReference contextRef,
HashMap<String,?> variables) |
void |
finalizeTriggerables()
Finalizes the DAG associated with the form's triggered conditions.
|
static QuestionDef |
findQuestionByRef(TreeReference ref,
IFormElement fe)
Traverses recursively the given
IFormElement node tree and returns
the first QuestionDef that matches the binding defined in the
given TreeReference. |
void |
fireEvent() |
static IDataReference |
getAbsRef(IDataReference ref,
TreeReference parentRef)
Takes a (possibly relative) reference, and makes it absolute based on its parent.
|
ActionController |
getActionController() |
String |
getAdditionalAttribute(String namespace,
String name)
Retrieve the value of an additional attribute on a Question or Group
|
List<TreeElement> |
getAdditionalAttributes()
Retrieve all additional attributes on a Question or Group
|
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)
Finds the instance node a reference refers to (factoring in multiplicities)
|
TreeReference |
getChildInstanceRef(List<IFormElement> elements,
List<Integer> multiplicities) |
List<IFormElement> |
getChildren() |
int |
getDeepChildCount() |
EvaluationContext |
getEvaluationContext() |
EventNotifier |
getEventNotifier() |
<X extends XFormExtension> |
getExtension(Class<X> extension) |
HashMap<String,DataInstance> |
getFormInstances() |
int |
getID() |
FormInstance |
getInstance() |
String |
getLabelInnerText()
Not applicable here.
|
Localizer |
getLocalizer() |
FormInstance |
getMainInstance() |
HashMap<String,Object> |
getMetaData() |
String |
getMetaData(String fieldName) |
String[] |
getMetaDataFields() |
String |
getName() |
DataInstance |
getNonMainInstance(String name)
Get an instance based on a name
|
Enumeration<DataInstance> |
getNonMainInstances() |
int |
getNumRepetitions(FormIndex index) |
List<IConditionExpr> |
getOutputFragments() |
List<String> |
getParseErrors() |
List<String> |
getParseWarnings() |
QuestionPreloader |
getPreloader() |
SubmissionProfile |
getSubmissionProfile() |
String |
getTextID()
Not applicable
|
String |
getTitle() |
boolean |
hasAction(String name)
Returns true if this form definition includes one or more action of the given name.
|
void |
initialize(boolean newInstance,
InstanceInitializationFactory factory)
meant to be called after deserialization and initialization of handlers
|
boolean |
isRepeatRelevant(TreeReference repeatRef) |
void |
localeChanged(String locale,
Localizer localizer)
Updates the current object with the locate given.
|
static boolean |
objectEquals(Object object1,
Object object2)
Copied from commons-lang 2.6: For reviewing purposes only.
|
boolean |
postProcessInstance() |
void |
preloadInstance(TreeElement node)
Preloads the Data Model with the preload values that are enumerated in the
data bindings.
|
void |
processResultOfAction(TreeReference refSetByAction,
String event) |
void |
readExternal(DataInputStream dis,
PrototypeFactory pf)
Reads the form definition object from the supplied stream.
|
void |
registerAction(String actionName)
Records that the form definition includes an action of the given name.
|
void |
registerElementWithActionTriggeredByToplevelEvent(IFormElement element)
Records that this question or group has a nested action triggered by a top-level event so that the action can be
triggered without having to traverse all elements.
|
void |
registerStateObserver(FormElementStateListener qsl)
Registers a state observer for this element.
|
void |
reportDependencyCycles()
Reports any dependency cycles based upon the triggerIndex array.
|
void |
seal()
Frees all of the components of this form which are no longer needed once
it is completed.
|
void |
setAdditionalAttribute(String namespace,
String name,
String value)
Capture additional attributes on a Question or Group
|
void |
setAnswer(IAnswerData data,
TreeElement node) |
void |
setAnswer(IAnswerData data,
TreeReference ref) |
void |
setAppearanceAttr(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(List<IFormElement> children) |
void |
setDefaultSubmission(SubmissionProfile profile) |
void |
setEventNotifier(EventNotifier eventNotifier) |
void |
setFormXmlPath(String formXmlPath) |
void |
setID(int id) |
void |
setInstance(FormInstance fi) |
void |
setLocalizer(Localizer l) |
void |
setName(String name) |
void |
setOutputFragments(List<IConditionExpr> outputFragments) |
void |
setPreloader(QuestionPreloader preloads) |
void |
setTextID(String textID)
Not applicable
|
void |
setTitle(String title) |
void |
setValue(IAnswerData data,
TreeReference ref,
boolean midSurvey) |
void |
setValue(IAnswerData data,
TreeReference ref,
TreeElement node,
boolean midSurvey) |
String |
toString() |
Collection<QuickTriggerable> |
triggerTriggerables(TreeReference ref)
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.
|
static void |
updateItemsetReferences(List<IFormElement> children)
Recursively traverses the main instance and initializes any questions with
dynamic ItemsetBindings.
|
ValidateOutcome |
validate(boolean markCompleted) |
void |
writeExternal(DataOutputStream dos)
Writes the form definition object to the supplied stream.
|
public static final String STORAGE_KEY
public static final int TEMPLATING_RECURSION_LIMIT
public FormDef()
public FormDef(EventNotifier eventNotifier)
public static IDataReference getAbsRef(IDataReference ref, TreeReference parentRef)
public EventNotifier getEventNotifier()
public void setEventNotifier(EventNotifier eventNotifier)
public void addNonMainInstance(DataInstance instance)
public void setFormXmlPath(String formXmlPath)
public DataInstance getNonMainInstance(String name)
name - string namepublic Enumeration<DataInstance> getNonMainInstances()
public void setInstance(FormInstance fi)
public FormInstance getMainInstance()
public FormInstance getInstance()
public void fireEvent()
public void addChild(IFormElement fe)
addChild in interface IFormElementfe - The child element to be addedpublic IFormElement getChild(int i)
getChild in interface IFormElementpublic IFormElement getChild(FormIndex index)
public List<IFormElement> explodeIndex(FormIndex index)
index - public TreeReference getChildInstanceRef(FormIndex index)
public TreeReference getChildInstanceRef(List<IFormElement> elements, List<Integer> multiplicities)
public void setLocalizer(Localizer l)
public IDataReference getBind()
getBind in interface IFormElementpublic void setValue(IAnswerData data, TreeReference ref, boolean midSurvey)
public void setValue(IAnswerData data, TreeReference ref, TreeElement node, boolean midSurvey)
public static boolean objectEquals(Object object1, 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 nullobject2 - the second object, may be nulltrue 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
InvalidReferenceExceptionpublic void processResultOfAction(TreeReference refSetByAction, String event)
processResultOfAction in interface ActionController.ActionResultProcessorrefSetByAction - - the ref that this action targetedevent - - the event that triggered this actionpublic boolean isRepeatRelevant(TreeReference repeatRef)
public boolean canCreateRepeat(TreeReference repeatRef, FormIndex repeatIndex)
public void copyItemsetAnswer(QuestionDef q, TreeElement targetNode, IAnswerData data) throws InvalidReferenceException
InvalidReferenceExceptionpublic Triggerable addTriggerable(Triggerable t)
t - the condition to be setpublic void reportDependencyCycles()
public void finalizeTriggerables()
throws IllegalStateException
IllegalStateException - - If the trigger ordering contains an illegal cycle and the
triggers can't be laid out appropriatelypublic Collection<QuickTriggerable> triggerTriggerables(TreeReference ref)
ref - The full contextualized unambiguous reference of the value that
was changed.public ValidateOutcome validate(boolean markCompleted)
public boolean evaluateConstraint(TreeReference ref, IAnswerData data)
public EvaluationContext getEvaluationContext()
public String fillTemplateString(String template, TreeReference contextRef)
public String fillTemplateString(String template, TreeReference contextRef, HashMap<String,?> variables)
public QuestionPreloader getPreloader()
public void setPreloader(QuestionPreloader preloads)
public void localeChanged(String locale, Localizer localizer)
LocalizablelocaleChanged in interface Localizablepublic void preloadInstance(TreeElement node)
public boolean postProcessInstance()
public void readExternal(DataInputStream dis, PrototypeFactory pf) throws IOException, DeserializationException
readExternal in interface Externalizabledis - - the stream to read fromIOExceptionInstantiationExceptionIllegalAccessExceptionDeserializationExceptionpublic 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(DataOutputStream dos) throws IOException
writeExternal in interface Externalizabledos - - the stream to write toIOExceptionpublic void collapseIndex(FormIndex index, List<Integer> indexes, List<Integer> multiplicities, List<IFormElement> elements)
public FormIndex buildIndex(List<Integer> indexes, List<Integer> multiplicities, List<IFormElement> elements)
public int getNumRepetitions(FormIndex index)
public int getDeepChildCount()
getDeepChildCount in interface IFormElementpublic void registerStateObserver(FormElementStateListener qsl)
IFormElementregisterStateObserver in interface IFormElementpublic void unregisterStateObserver(FormElementStateListener qsl)
IFormElementunregisterStateObserver in interface IFormElementpublic List<IFormElement> getChildren()
getChildren in interface IFormElementpublic void setChildren(List<IFormElement> children)
setChildren in interface IFormElementchildren - the children of this element, if it is capable of having
child elements.public String getTitle()
public void setTitle(String title)
public int getID()
getID in interface IFormElementgetID in interface Persistablepublic void setID(int id)
setID in interface IFormElementsetID in interface Persistableid - The new unique ID of this elementpublic String getName()
public void setName(String name)
public Localizer getLocalizer()
public List<IConditionExpr> getOutputFragments()
public void setOutputFragments(List<IConditionExpr> outputFragments)
public HashMap<String,Object> getMetaData()
getMetaData in interface IMetaDatapublic String getMetaData(String fieldName)
getMetaData in interface IMetaDatapublic String[] getMetaDataFields()
getMetaDataFields in interface IMetaDatapublic static void updateItemsetReferences(List<IFormElement> children)
public void attachControlsToInstanceData()
public static QuestionDef findQuestionByRef(TreeReference ref, IFormElement fe)
IFormElement node tree and returns
the first QuestionDef that matches the binding defined in the
given TreeReference.ref - reference to a form bindingfe - the recursive IFormElement. The starting call would
typically receive a FormDefnull if no QuestionDef
matches the given bindingpublic String getAppearanceAttr()
getAppearanceAttr in interface IFormElementpublic ActionController getActionController()
getActionController in interface IFormElementpublic void setAppearanceAttr(String appearanceAttr)
setAppearanceAttr in interface IFormElementpublic String getLabelInnerText()
getLabelInnerText in interface IFormElementpublic String getTextID()
getTextID in interface IFormElementpublic void setTextID(String textID)
setTextID in interface IFormElementtextID - the plain TextID WITHOUT any form specification (e.g. ;long)public void setDefaultSubmission(SubmissionProfile profile)
public void addSubmissionProfile(String submissionId, SubmissionProfile profile)
public SubmissionProfile getSubmissionProfile()
public void setAdditionalAttribute(String namespace, String name, String value)
IFormElementsetAdditionalAttribute in interface IFormElementpublic String getAdditionalAttribute(String namespace, String name)
IFormElementgetAdditionalAttribute in interface IFormElementpublic List<TreeElement> getAdditionalAttributes()
IFormElementgetAdditionalAttributes in interface IFormElementpublic <X extends XFormExtension> X getExtension(Class<X> extension)
public void seal()
public void registerAction(String actionName)
public boolean hasAction(String name)
public void registerElementWithActionTriggeredByToplevelEvent(IFormElement element)
public void addParseWarning(String warning)
public void addParseError(String error)
public HashMap<String,DataInstance> getFormInstances()
Copyright © 2021. All rights reserved.