本文整理汇总了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");
}
}
示例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));
}
}
示例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");
}
}
示例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");
}
}
示例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));
}
}