Search in sources :

Example 31 with FormDef

use of org.javarosa.core.model.FormDef in project javarosa by opendatakit.

the class FormParseInit method printStuff.

/*
     * Makes an 'extremely basic' print out of the xform model.
     */
public String printStuff() {
    String stuff = "";
    // go to the beginning of the form
    fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
    do {
        FormEntryCaption fep = femodel.getCaptionPrompt();
        boolean choiceFlag = false;
        if (fep.getFormElement() instanceof QuestionDef) {
            stuff += "\t[Type:QuestionDef, ";
            List<SelectChoice> s = ((QuestionDef) fep.getFormElement()).getChoices();
            stuff += "ContainsChoices: " + ((s != null && s.size() > 0) ? "true " : "false") + ", ";
            if (s != null && s.size() > 0)
                choiceFlag = true;
        } else if (fep.getFormElement() instanceof FormDef) {
            stuff += "\t[Type:FormDef, ";
        } else if (fep.getFormElement() instanceof GroupDef) {
            stuff += "\t[Type:GroupDef, ";
        } else {
            stuff += "\t[Type:Unknown]\n";
            continue;
        }
        stuff += "ID:" + fep.getFormElement().getID() + ", TextID:" + fep.getFormElement().getTextID() + ",InnerText:" + fep.getFormElement().getLabelInnerText();
        if (choiceFlag) {
            stuff += "] \n\t\t---Choices:" + ((QuestionDef) fep.getFormElement()).getChoices().toString() + "\n";
        } else {
            stuff += "]\n";
        }
    } while (fec.stepToNextEvent() != fec.EVENT_END_OF_FORM);
    return stuff;
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) FormDef(org.javarosa.core.model.FormDef) FormEntryCaption(org.javarosa.form.api.FormEntryCaption) QuestionDef(org.javarosa.core.model.QuestionDef) GroupDef(org.javarosa.core.model.GroupDef)

Aggregations

FormDef (org.javarosa.core.model.FormDef)31 Test (org.junit.Test)10 IOException (java.io.IOException)9 TreeElement (org.javarosa.core.model.instance.TreeElement)7 FormInstance (org.javarosa.core.model.instance.FormInstance)5 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 EvaluationContext (org.javarosa.core.model.condition.EvaluationContext)4 AbstractTreeElement (org.javarosa.core.model.instance.AbstractTreeElement)4 DataInputStream (java.io.DataInputStream)3 SubmissionProfile (org.javarosa.core.model.SubmissionProfile)3 IAnswerData (org.javarosa.core.model.data.IAnswerData)3 TreeReference (org.javarosa.core.model.instance.TreeReference)3 FormEntryController (org.javarosa.form.api.FormEntryController)3 ParseResult (org.javarosa.xform.parse.FormParserHelper.ParseResult)3 XPathExpression (org.javarosa.xpath.expr.XPathExpression)3 InputStream (java.io.InputStream)2 GroupDef (org.javarosa.core.model.GroupDef)2 IDataReference (org.javarosa.core.model.IDataReference)2 QuestionDef (org.javarosa.core.model.QuestionDef)2