当前位置: 首页>>代码示例>>Java>>正文


Java QuestionDef.putQuestionString方法代码示例

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


在下文中一共展示了QuestionDef.putQuestionString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPromptIDsNoLocalizer

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
@Test
public void testPromptIDsNoLocalizer() {
    QuestionDef q = new QuestionDef();

    q.setTextID("long text id");
    if (!"long text id".equals(q.getTextID())) {
        fail("Long text ID getter/setter broken");
    }

    QuestionString hint = new QuestionString("hint");
    hint.setTextId("hint text id");
    q.putQuestionString("hint", hint);
    if (!"hint text id".equals(q.getQuestionString("hint").getTextId())) {
        fail("hint text ID getter/setter broken");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:TextFormTests.java

示例2: parseHelperText

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
 * Handles hint elements (text-only) and help elements (similar, but may include multimedia)
 *
 * @param q The QuestionDef object to augment with the hint/help
 * @param e The Element to parse
 */
private void parseHelperText(QuestionDef q, Element e) {
    Vector<String> usedAtts = new Vector<String>();
    usedAtts.addElement(REF_ATTR);
    String XMLText = getXMLText(e, true);
    String innerText = getLabel(e);
    String ref = e.getAttributeValue("", REF_ATTR);
    String name = e.getName();

    QuestionString mQuestionString = new QuestionString(name);
    q.putQuestionString(name, mQuestionString);

    if (ref != null) {
        if (ref.startsWith(ITEXT_OPEN) && ref.endsWith(ITEXT_CLOSE)) {
            String textRef = ref.substring(ITEXT_OPEN.length(), ref.indexOf(ITEXT_CLOSE));
            verifyTextMappings(textRef, "<" + name + ">", true);
            mQuestionString.setTextId(textRef);
        } else {
            // TODO: shouldn't this raise an XFormParseException?
            throw new RuntimeException("malformed ref [" + ref + "] for <" + name + ">");
        }
    }

    mQuestionString.setTextInner(innerText);
    mQuestionString.setTextFallback(XMLText);

    if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
        reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:36,代码来源:XFormParser.java

示例3: testPromptsWithLocalizer

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
@Test
public void testPromptsWithLocalizer() {
    Localizer l = new Localizer();

    TableLocaleSource table = new TableLocaleSource();
    l.addAvailableLocale("locale");
    l.setDefaultLocale("locale");
    table.setLocaleMapping("prompt;long", "loc: long text");
    table.setLocaleMapping("prompt;short", "loc: short text");
    table.setLocaleMapping("help", "loc: help text");
    l.registerLocaleResource("locale", table);

    l.setLocale("locale");


    QuestionDef q = new QuestionDef();

    QuestionString helpString = new QuestionString("long");
    helpString.setTextId("help");

    q.putQuestionString("long", helpString);
    FormEntryPrompt fep = new DummyFormEntryPrompt(l, "prompt", q);

    if (!"loc: long text".equals(fep.getLongText())) {
        fail("Long text did not localize properly");
    }
    if (!"loc: short text".equals(fep.getShortText())) {
        fail("Short text did not localize properly");
    }

}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:32,代码来源:TextFormTests.java

示例4: testPromptsNoLocalizer

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
@Test
public void testPromptsNoLocalizer() {
    QuestionDef q = new QuestionDef();

    q.putQuestionString("help", new QuestionString("help", "help text"));
    if (!"help text".equals(q.getQuestionString("help").getTextInner())) {
        fail("Help text getter/setter broken");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:10,代码来源:TextFormTests.java

示例5: parseHelperText

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
 * Handles hint elements (text-only) and help elements (similar, but may include multimedia)
 *
 * @param q The QuestionDef object to augment with the hint/help
 * @param e The Element to parse
 */
private void parseHelperText(QuestionDef q, Element e) {
    Vector<String> usedAtts = new Vector<>();
    usedAtts.addElement(REF_ATTR);
    String XMLText = getXMLText(e, true);
    String innerText = getLabel(e);
    String ref = e.getAttributeValue("", REF_ATTR);
    String name = e.getName();

    QuestionString mQuestionString = new QuestionString(name);
    q.putQuestionString(name, mQuestionString);

    if (ref != null) {
        if (ref.startsWith(ITEXT_OPEN) && ref.endsWith(ITEXT_CLOSE)) {
            String textRef = ref.substring(ITEXT_OPEN.length(), ref.indexOf(ITEXT_CLOSE));
            verifyTextMappings(textRef, "<" + name + ">", true);
            mQuestionString.setTextId(textRef);
        } else {
            // TODO: shouldn't this raise an XFormParseException?
            throw new RuntimeException("malformed ref [" + ref + "] for <" + name + ">");
        }
    }

    mQuestionString.setTextInner(innerText);
    mQuestionString.setTextFallback(XMLText);

    if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
        reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:36,代码来源:XFormParser.java


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