• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FormDef类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.javarosa.core.model.FormDef的典型用法代码示例。如果您正苦于以下问题:Java FormDef类的具体用法?Java FormDef怎么用?Java FormDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FormDef类属于org.javarosa.core.model包,在下文中一共展示了FormDef类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: summarize

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
private void summarize() {
	addToTextArea("\n\n==================================\nForm Summary\n==================================\n");
	updateStatus("Creating Summary");
	
	FileInputStream in;
	try {
		in = new FileInputStream(newForm);
		FormDef f = XFormUtils.getFormFromInputStream(in);
		addToTextArea(FormOverview.overview(f, this.languages.getSelectedItem()));
		addToTextArea("\n\n==================================\nForm Summary Complete\n==================================\n");
		updateStatus("Summary Completed");
	} catch (FileNotFoundException e) {
		addToTextArea("ERROR! File Not Found Exception when attempting to load form " + newForm);
		e.printStackTrace();
		updateStatus("Error while loading form");
	}
	 
	
}
 
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:XFormValidatorGUI.java


示例2: updateLang

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
private void updateLang() {
	try {
		languages.removeAll();
		FileInputStream in = new FileInputStream(newForm);
		FormDef f = XFormUtils.getFormFromInputStream(in);
		if (f.getLocalizer() != null) {
			String[] locales = f.getLocalizer().getAvailableLocales();
			for (int i = 0; i < locales.length; ++i) {
				languages.add(locales[i]);
			}
			languages.select(f.getLocalizer().getDefaultLocale());
			languages.setVisible(true);
		} else {
			languages.setVisible(false);
		}
	} catch (Exception e) {
		//All failures here should just get swallowed, this is tertiary functionality
		e.printStackTrace();
		languages.setVisible(false);
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:22,代码来源:XFormValidatorGUI.java


示例3: FormEntryModel

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Creates a new entry model for the form with the appropriate
 * repeat structure
 *
 * @param form
 * @param repeatStructure The structure of repeats (the repeat signals which should
 * be sent during form entry)
 * @throws IllegalArgumentException If repeatStructure is not valid
 */
public FormEntryModel(FormDef form, int repeatStructure) {
    this.form = form;
    if(repeatStructure != REPEAT_STRUCTURE_LINEAR && repeatStructure != REPEAT_STRUCTURE_NON_LINEAR) {
    	throw new IllegalArgumentException(repeatStructure +": does not correspond to a valid repeat structure");
    }
    //We need to see if there are any guessed repeat counts in the form, which prevents
    //us from being able to use the new repeat style
    //Unfortunately this is probably (A) slow and (B) might overflow the stack. It's not the only
    //recursive walk of the form, though, so (B) isn't really relevant
    if(repeatStructure == REPEAT_STRUCTURE_NON_LINEAR && containsRepeatGuesses(form)) {
    	repeatStructure = REPEAT_STRUCTURE_LINEAR;
    }
    this.repeatStructure = repeatStructure;
    this.currentFormIndex = FormIndex.createBeginningOfFormIndex();
}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:FormEntryModel.java


示例4: parse

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
public FormDef parse() throws IOException {
	if (_f == null) {
		System.out.println("Parsing form...");

		if (_xmldoc == null) {
			_xmldoc = getXMLDocument(_reader, stringCache);
		}

		parseDoc();

		//load in a custom xml instance, if applicable
		if (_instReader != null) {
			loadXmlInstance(_f, _instReader);
		} else if (_instDoc != null) {
			loadXmlInstance(_f, _instDoc);
		}
	}
	return _f;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:XFormParser.java


示例5: loadXmlInstance

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Load a compatible xml instance into FormDef f
 *
 * call before f.initialize()!
 */
public static void loadXmlInstance(FormDef f, Document xmlInst) {
       TreeElement savedRoot = XFormParser.restoreDataModel(xmlInst, null).getRoot();
       TreeElement templateRoot = f.getMainInstance().getRoot().deepCopy(true);

       // weak check for matching forms
       // TODO: should check that namespaces match?
    if (!savedRoot.getName().equals(templateRoot.getName()) || savedRoot.getMult() != 0) {
    	throw new RuntimeException("Saved form instance does not match template form definition");
    }

    // populate the data model
    TreeReference tr = TreeReference.rootRef();
    tr.add(templateRoot.getName(), TreeReference.INDEX_UNBOUND);
    templateRoot.populate(savedRoot, f);

    // populated model to current form
    f.getMainInstance().setRoot(templateRoot);

    // if the new instance is inserted into the formdef before f.initialize() is called, this
    // locale refresh is unnecessary
    //   Localizer loc = f.getLocalizer();
    //   if (loc != null) {
    //       f.localeChanged(loc.getLocale(), loc);
    //	 }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:31,代码来源:XFormParser.java


示例6: createSimpleGroupReference

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
public static FormDef createSimpleGroupReference() {
	FormDef theform = new FormDef();
	
	QuestionDef question1 = new QuestionDef();
	GroupDef group1 = new GroupDef();
	QuestionDef question11 = new QuestionDef();
	QuestionDef question12 = new QuestionDef();
	group1.addChild(question11);
	group1.addChild(question12);
	QuestionDef question2 = new QuestionDef();
	theform.addChild(question1);
	theform.addChild(group1);
	theform.addChild(question2);
	
	return theform;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:FormDefConstructionUtils.java


示例7: testGeoShapeSupportForEnclosedArea

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
public void testGeoShapeSupportForEnclosedArea() throws Exception {
   // Read the form definition
String FORM_NAME = (new File(PathConst.getTestResourcePath(), "area.xml")).getAbsolutePath();
InputStream is = null;
FormDef formDef = null;
is = new FileInputStream(new File(FORM_NAME));
   formDef = XFormUtils.getFormFromInputStream(is);

   // trigger all calculations
   formDef.initialize(true, new InstanceInitializationFactory());

   // get the calculated area
   IAnswerData areaResult = formDef.getMainInstance().getRoot().getChildAt(1).getValue();

   assertTrue((int) Math.rint((Double) areaResult.getValue()) == 151452);
 }
 
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:GeoShapeAreaTest.java


示例8: testQuestionLevelActionsAndSerialization

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Tests:
 * -Adding a timestamp attribute to a node in the model when the corresponding question's
 * value is changed
 * -Setting a default value for one question based on the answer to another
 * -Deserialization of a FormDef
 */
@Test
public void testQuestionLevelActionsAndSerialization() throws Exception {
    // Generate a normal version of the fpi
    FormParseInit fpi =
            new FormParseInit("/xform_tests/test_question_level_actions.xml");

    // Then generate one from a deserialized version of the initial form def
    FormDef fd = fpi.getFormDef();
    PersistableSandbox sandbox = new PersistableSandbox();
    byte[] serialized = sandbox.serialize(fd);
    FormDef deserializedFormDef = sandbox.deserialize(serialized, FormDef.class);
    FormParseInit fpiFromDeserialization = new FormParseInit(deserializedFormDef);

    // First test normally
    testQuestionLevelActions(fpi);

    // Then test with the deserialized version (to test that FormDef serialization is working properly)
    testQuestionLevelActions(fpiFromDeserialization);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:27,代码来源:FormDefTest.java


示例9: getSubmissionMetadata

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Get the OpenRosa required metadata of the portion of the form beng submitted
 */
public InstanceMetadata getSubmissionMetadata() {
    FormDef formDef = mFormEntryController.getModel().getForm();
    TreeElement rootElement = formDef.getInstance().getRoot();

    TreeElement trueSubmissionElement = rootElement;

    // and find the depth-first meta block in this...
    TreeElement e = findDepthFirst(trueSubmissionElement, "meta");

    String instanceId = null;

    if (e != null) {
        Vector<TreeElement> v;

        // instance id...
        v = e.getChildrenWithName(INSTANCE_ID);
        if (v.size() == 1) {
            instanceId = v.get(0).getValue().uncast().toString();
        }
    }

    return new InstanceMetadata(instanceId);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:27,代码来源:FormController.java


示例10: FormEntryModel

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Creates a new entry model for the form with the appropriate
 * repeat structure
 *
 * @param repeatStructure The structure of repeats (the repeat signals which should
 *                        be sent during form entry)
 * @throws IllegalArgumentException If repeatStructure is not valid
 */
public FormEntryModel(FormDef form, int repeatStructure) {
    this.form = form;
    if (repeatStructure != REPEAT_STRUCTURE_LINEAR && repeatStructure != REPEAT_STRUCTURE_NON_LINEAR) {
        throw new IllegalArgumentException(repeatStructure + ": does not correspond to a valid repeat structure");
    }
    //We need to see if there are any guessed repeat counts in the form, which prevents
    //us from being able to use the new repeat style
    //Unfortunately this is probably (A) slow and (B) might overflow the stack. It's not the only
    //recursive walk of the form, though, so (B) isn't really relevant
    if (repeatStructure == REPEAT_STRUCTURE_NON_LINEAR && containsRepeatGuesses(form)) {
        repeatStructure = REPEAT_STRUCTURE_LINEAR;
    }
    this.repeatStructure = repeatStructure;
    this.currentFormIndex = FormIndex.createBeginningOfFormIndex();
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:24,代码来源:FormEntryModel.java


示例11: testNestedMultiplicities

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Some simple xpath expressions with multiple predicates that operate over
 * nodesets.
 */
@Test
public void testNestedMultiplicities() {
    FormParseInit fpi = new FormParseInit("/test_nested_multiplicities.xml");
    FormDef fd = fpi.getFormDef();

    ExprEvalUtils.testEval("/data/bikes/manufacturer/model[@id='pista']/@color",
            fd.getInstance(), null, "seafoam");
    ExprEvalUtils.testEval("join(' ', /data/bikes/manufacturer[@american='yes']/model[.=1]/@id)",
            fd.getInstance(), null, "karate-monkey vamoots");
    ExprEvalUtils.testEval("count(/data/bikes/manufacturer[@american='yes'][count(model[.=1]) > 0]/model/@id)",
            fd.getInstance(), null, 4.0);
    ExprEvalUtils.testEval("join(' ', /data/bikes/manufacturer[@american='yes'][count(model[.=1]) > 0]/model/@id)",
            fd.getInstance(), null, "karate-monkey long-haul cross-check vamoots");
    ExprEvalUtils.testEval("join(' ', /data/bikes/manufacturer[@american='yes'][count(model=1) > 0]/model/@id)",
            fd.getInstance(), null, new XPathTypeMismatchException());
    ExprEvalUtils.testEval("join(' ', /data/bikes/manufacturer[@american='no'][model=1]/model/@id)",
            fd.getInstance(), null, new XPathTypeMismatchException());
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:23,代码来源:XPathPathExprTest.java


示例12: loadXmlInstance

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Load a compatible xml instance into FormDef f
 *
 * call before f.initialize()!
 */
public static void loadXmlInstance(FormDef f, Document xmlInst) {
    TreeElement savedRoot = XFormParser.restoreDataModel(xmlInst, null).getRoot();
    TreeElement templateRoot = f.getMainInstance().getRoot().deepCopy(true);

    // weak check for matching forms
    // TODO: should check that namespaces match?
    if (!savedRoot.getName().equals(templateRoot.getName()) || savedRoot.getMult() != 0) {
        throw new RuntimeException("Saved form instance does not match template form definition");
    }

    // populate the data model
    TreeReference tr = TreeReference.rootRef();
    tr.add(templateRoot.getName(), TreeReference.INDEX_UNBOUND);
    templateRoot.populate(savedRoot);

    // populated model to current form
    f.getMainInstance().setRoot(templateRoot);

    // if the new instance is inserted into the formdef before f.initialize() is called, this
    // locale refresh is unnecessary
    //   Localizer loc = f.getLocalizer();
    //   if (loc != null) {
    //       f.localeChanged(loc.getLocale(), loc);
    //     }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:31,代码来源:XFormParser.java


示例13: revert

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
public boolean revert(Resource r, ResourceTable table) {
    //Basically some content as upgrade. Merge;
    FormDef form = storage().read(cacheLocation);
    String tempString = form.getInstance().schema;

    //TODO: Aggressively wipe out anything which might conflict with the uniqueness
    //of the new schema

    for (String ext : exts) {
        //Removing any staging/upgrade placeholders.
        if (tempString.indexOf(ext) != -1) {
            form.getInstance().schema = tempString.substring(0, tempString.indexOf(ext));
            storage().write(form);
        }
    }
    return true;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:18,代码来源:XFormInstaller.java


示例14: loadFormFromFile

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
private FormDef loadFormFromFile(File formXmlFile) {
    FileInputStream fis;
    // no binary, read from xml
    Log.i(TAG, "Attempting to load from: " + formXmlFile.getAbsolutePath());
    try {
        fis = new FileInputStream(formXmlFile);
    } catch (FileNotFoundException e) {
        throw new RuntimeException("Error reading XForm file", e);
    }
    XFormAndroidInstaller.registerAndroidLevelFormParsers();
    FormDef fd = XFormExtensionUtils.getFormFromInputStream(fis);
    if (fd == null) {
        throw new RuntimeException("Error reading XForm file: FormDef is null");
    }
    return fd;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:17,代码来源:FormLoaderTask.java


示例15: processAction

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
@Override
public TreeReference processAction(FormDef model, TreeReference contextRef) {
    SubmissionProfile profile = model.getSubmissionProfile(this.submissionId);
    String url = profile.getResource();

    TreeReference ref = profile.getRef();
    Map<String, String> map = null;
    if(ref != null) {
        map = getKeyValueMapping(model, ref);
    }

    String result = null;
    try {
        result = model.dispatchSendCallout(url, map);
    } catch (Exception e ) {
        Logger.exception("send-action", e);
    }
    if(result == null) {
        return null;
    } else {
        TreeReference target = profile.getTargetRef();
        model.setValue(new UncastData(result), target);
        return target;
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:26,代码来源:SendAction.java


示例16: IntentWidget

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
protected IntentWidget(Context context, FormEntryPrompt prompt, Intent in, IntentCallout ic,
                       PendingCalloutInterface pendingCalloutInterface,
                       String getButtonLocalizationKey, String updateButtonLocalizationKey,
                       String missingCalloutKey, boolean isEditable, String appearance,
                       FormDef formDef) {
    super(context, prompt);

    this.missingCalloutKey = missingCalloutKey;
    this.intent = in;
    this.ic = ic;
    this.appearance = appearance;
    this.pendingCalloutInterface = pendingCalloutInterface;
    this.getButtonLocalizationKey = getButtonLocalizationKey;
    this.updateButtonLocalizationKey = updateButtonLocalizationKey;
    this.isEditable = isEditable;
    this.formDef = formDef;

    if (isEditable) {
        mStringAnswer = new EditText(getContext());
    } else {
        mStringAnswer = new TextView(getContext());
    }
    launchIntentButton = new Button(getContext());
    setupTextView();
    setupButton();
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:27,代码来源:IntentWidget.java


示例17: handle

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Handle pollsensor node, creating a new PollSensor action with the node that sensor data will be written to.
 *
 * @param e      pollsensor Element
 * @param parent FormDef for the form being parsed
 */
@Override
public void handle(XFormParser p, Element e, Object parent) {
    String event = e.getAttributeValue(null, "event");
    FormDef form = (FormDef)parent;
    PollSensorAction action;

    String ref = e.getAttributeValue(null, "ref");
    if (ref != null) {
        XPathReference dataRef = new XPathReference(ref);
        dataRef = XFormParser.getAbsRef(dataRef, TreeReference.rootRef());
        TreeReference treeRef = FormInstance.unpackReference(dataRef);
        p.registerActionTarget(treeRef);
        action = new PollSensorAction(treeRef);
    } else {
        action = new PollSensorAction();
    }

    form.getActionController().registerEventListener(event, action);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:26,代码来源:PollSensorExtensionParser.java


示例18: getSubmissionDataReference

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
/**
 * Find the portion of the form that is to be submitted
 *
 * @return
 */
private IDataReference getSubmissionDataReference() {
    FormDef formDef = mFormEntryController.getModel().getForm();
    // Determine the information about the submission...
    SubmissionProfile p = formDef.getSubmissionProfile();
    if (p == null || p.getRef() == null) {
        return new XPathReference("/");
    } else {
        return p.getRef();
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:16,代码来源:FormController.java


示例19: getVariableValue

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
public static IAnswerData getVariableValue(String variableName,
                                           FormDef formDef) {
    TreeElement element = findChildForName(formDef.getInstance().getRoot(), variableName);
    if (element != null) {
        return element.getValue();
    }
    return null;
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:9,代码来源:FormsUtils.java


示例20: getVariableValueAsString

import org.javarosa.core.model.FormDef; //导入依赖的package包/类
public static String getVariableValueAsString(String variableName,
                                              FormDef form) {
    IAnswerData data = getVariableValue(variableName, form);
    if (data != null) {
        return data.getValue().toString();
    }
    return null;
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:9,代码来源:FormsUtils.java



注:本文中的org.javarosa.core.model.FormDef类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OperatingSystem类代码示例发布时间:2022-05-22
下一篇:
Java Sector类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap