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

Java XFormParseException类代码示例

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

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



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

示例1: testCyclicReferenceWithGroup

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
/**
 * Test that XPath cyclic reference that references parent throws usable error
 */
@Test
public void testCyclicReferenceWithGroup() {
    try {
        new FormParseInit("/xform_tests/group_cyclic_reference.xml");
    } catch (XFormParseException e) {
        String detailMessage = e.getMessage();
        // Assert that we're using the shortest cycle algorithm
        assertTrue(detailMessage.contains("Shortest Cycle"));
        // There should only be three newlines since only the three core cyclic references were included
        int newlineCount = detailMessage.length() - detailMessage.replace("\n", "").length();
        assertTrue(newlineCount == 3);
        return;
    }
    fail("Cyclical reference did not throw XFormParseException");
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:19,代码来源:CyclicReferenceTests.java


示例2: SelectChoice

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
/**
 * 
 * @param labelID can be null
 * @param labelInnerText can be null
 * @param value should not be null
 * @param isLocalizable
 * @throws XFormParseException if value is null
 */
public SelectChoice (String labelID, String labelInnerText, String value, boolean isLocalizable) {
	this.isLocalizable = isLocalizable;
	this.textID = labelID;
	this.labelInnerText = labelInnerText;
	if(value != null){
		this.value = value;
	}else{
		throw new XFormParseException("SelectChoice{id,innerText}:{"+labelID+","+labelInnerText+"}, has null Value!");
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:19,代码来源:SelectChoice.java


示例3: SelectChoice

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
/**
 * @param labelID        can be null
 * @param labelInnerText can be null
 * @param value          should not be null
 * @throws XFormParseException if value is null
 */
public SelectChoice(String labelID, String labelInnerText, String value, boolean isLocalizable) {
    this.isLocalizable = isLocalizable;
    this.textID = labelID;
    this.labelInnerText = labelInnerText;
    if (value != null) {
        this.value = value;
    } else {
        throw new XFormParseException("SelectChoice{id,innerText}:{" + labelID + "," + labelInnerText + "}, has null Value!");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:SelectChoice.java


示例4: getFormFromResource

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
public static FormDef getFormFromResource(String resource) throws XFormParseException {
    InputStream is = System.class.getResourceAsStream(resource);
    if (is == null) {
        System.err.println("Can't find form resource \"" + resource + "\". Is it in the JAR?");
        return null;
    }

    return getFormFromInputStream(is);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:10,代码来源:XFormUtils.java


示例5: loadInstance

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
/**
 * Build a form definition and load a particular form instance into it.
 * The FormDef object returned isn't initialized, and hence will not have
 * 'instance(...)' data set.
 *
 * @param formInput     XML stream of the form definition
 * @param instanceInput XML stream of an instance of the form
 * @return The form definition with the given instance loaded. Returns null
 * if the instance doesn't match the form provided.
 * @throws IOException thrown when XML input streams aren't successfully
 *                     parsed
 */
public static FormDef loadInstance(InputStream formInput,
                                   InputStream instanceInput)
        throws IOException {
    FormDef formDef;
    FormInstance savedModel;

    try {
        formDef = XFormUtils.getFormFromInputStream(formInput);
    } catch (XFormParseException e) {
        throw new IOException(e.getMessage());
    }

    savedModel = XFormParser.restoreDataModel(instanceInput, null);

    // get the root of the saved and template instances
    TreeElement savedRoot = savedModel.getRoot();
    TreeElement templateRoot =
            formDef.getInstance().getRoot().deepCopy(true);

    // weak check for matching forms
    if (!savedRoot.getName().equals(templateRoot.getName()) ||
            savedRoot.getMult() != 0) {
        System.out.println("Instance and template form definition don't match");
        return null;
    } else {
        // populate the data model
        TreeReference tr = TreeReference.rootRef();
        tr.add(templateRoot.getName(), TreeReference.INDEX_UNBOUND);
        templateRoot.populate(savedRoot);

        // populated model to current form
        formDef.getInstance().setRoot(templateRoot);
    }

    return formDef;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:49,代码来源:FormInstanceLoader.java


示例6: getFormRaw

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
public static FormDef getFormRaw(InputStreamReader isr) throws XFormParseException, IOException{
	return _factory.getXFormParser(isr).parse();
}
 
开发者ID:medic,项目名称:javarosa,代码行数:4,代码来源:XFormUtils.java


示例7: setFailed

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
public void setFailed(XFormParseException e) {
     this.passedValidation = false;
     this.failureExpected = true;
     this.failureReason = e.getMessage();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:6,代码来源:JSONReporter.java


示例8: getFormRaw

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
public static FormDef getFormRaw(InputStreamReader isr) throws XFormParseException, IOException {
    return _factory.getXFormParser(isr).parse();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:4,代码来源:XFormUtils.java


示例9: testParseInvalidMaxDimen

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
@Test
public void testParseInvalidMaxDimen() {
    exception.expect(XFormParseException.class);
    exception.expectMessage("Invalid input for image max dimension: bad_dimen");
    new FormParseInit("/xform_tests/test_upload_extension_3.xml", extensionParsers);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:7,代码来源:UploadExtensionTest.java


示例10: customInstall

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
@Override
protected int customInstall(Resource r, Reference local, boolean upgrade) throws IOException, UnresolvedResourceException {
    registerAndroidLevelFormParsers();
    FormDef formDef;
    try {
        formDef = XFormExtensionUtils.getFormFromInputStream(local.getStream());
    } catch (XFormParseException xfpe) {
        throw new UnresolvedResourceException(r, xfpe.getMessage(), true);
    }


    this.namespace = formDef.getInstance().schema;
    if (namespace == null) {
        throw new UnresolvedResourceException(r, "Invalid XForm, no namespace defined", true);
    }


    //TODO: Where should this context be?
    ContentResolver cr = CommCareApplication.instance().getContentResolver();
    ContentProviderClient cpc = cr.acquireContentProviderClient(FormsProviderAPI.FormsColumns.CONTENT_URI);

    ContentValues cv = new ContentValues();
    cv.put(FormsProviderAPI.FormsColumns.DISPLAY_NAME, "NAME");
    cv.put(FormsProviderAPI.FormsColumns.DESCRIPTION, "NAME"); //nullable
    cv.put(FormsProviderAPI.FormsColumns.JR_FORM_ID, formDef.getMainInstance().schema); // ? 
    cv.put(FormsProviderAPI.FormsColumns.FORM_FILE_PATH, local.getLocalURI());
    cv.put(FormsProviderAPI.FormsColumns.FORM_MEDIA_PATH, GlobalConstants.MEDIA_REF);
    //cv.put(FormsProviderAPI.FormsColumns.SUBMISSION_URI, "NAME"); //nullable
    //cv.put(FormsProviderAPI.FormsColumns.BASE64_RSA_PUBLIC_KEY, "NAME"); //nullable


    Cursor existingforms = null;
    try {
        existingforms = cr.query(FormsProviderAPI.FormsColumns.CONTENT_URI,
                new String[]{FormsProviderAPI.FormsColumns._ID},
                FormsProviderAPI.FormsColumns.JR_FORM_ID + "=?",
                new String[]{formDef.getMainInstance().schema}, null);


        if (existingforms != null && existingforms.moveToFirst()) {
            //we already have one form. Hopefully this is during an upgrade...
            if (!upgrade) {
                //Hm, error out?
            }

            //So we know there's another form here. We should wait until it's time for
            //the upgrade and replace the pointer to here.
            Uri recordId = ContentUris.withAppendedId(FormsProviderAPI.FormsColumns.CONTENT_URI, existingforms.getLong(0));

            //Grab the URI we should update
            this.contentUri = recordId.toString();

            //TODO: Check to see if there is more than one form, and deal

        } else {
            Uri result = cpc.insert(FormsProviderAPI.FormsColumns.CONTENT_URI, cv);
            this.contentUri = result.toString();
        }
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        throw new IOException("couldn't talk to form database to install form");
    } finally {
        if (existingforms != null) {
            existingforms.close();
        }
    }

    if (cpc != null) {
        cpc.release();
    }

    return upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:75,代码来源:XFormAndroidInstaller.java


示例11: testProperErrorHandlingForFormArgs

import org.javarosa.xform.parse.XFormParseException; //导入依赖的package包/类
/**
 * Tests that XPath errors are handled as _parse_ errors during runtime, not as runtime errors
 */
@Test(expected = XFormParseException.class)
public void testProperErrorHandlingForFormArgs() {
    FormParseInit fpi = new FormParseInit("/xform_tests/xpath_args_parse_error.xml");
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:8,代码来源:ErrorHandlingTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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