本文整理汇总了Java中org.javarosa.core.model.QuestionDef.getNumChoices方法的典型用法代码示例。如果您正苦于以下问题:Java QuestionDef.getNumChoices方法的具体用法?Java QuestionDef.getNumChoices怎么用?Java QuestionDef.getNumChoices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.QuestionDef
的用法示例。
在下文中一共展示了QuestionDef.getNumChoices方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachChoice
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void attachChoice (QuestionDef q) {
if (q.getDynamicChoices() != null) //can't attach dynamic choices because they aren't guaranteed to exist yet
return;
SelectChoice choice = null;
if (index != -1 && index < q.getNumChoices()) {
choice = q.getChoice(index);
} else if (xmlValue != null && xmlValue.length() > 0) {
choice = q.getChoiceForValue(xmlValue);
}
if (choice != null) {
attachChoice(choice);
} else {
throw new XPathTypeMismatchException("value " + xmlValue + " could not be loaded into question " + q.getTextID()
+ ". Check to see if value " + xmlValue + " is a valid option for question " + q.getTextID() + ".");
}
}
示例2: attachChoice
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void attachChoice(QuestionDef q) {
if (q.getDynamicChoices() != null) //can't attach dynamic choices because they aren't guaranteed to exist yet
return;
SelectChoice choice = null;
if (index != -1 && index < q.getNumChoices()) {
choice = q.getChoice(index);
} else if (xmlValue != null && xmlValue.length() > 0) {
choice = q.getChoiceForValue(xmlValue);
}
if (choice != null) {
attachChoice(choice);
} else {
throw new XPathTypeMismatchException("value " + xmlValue + " could not be loaded into question " + q.getTextID()
+ ". Check to see if value " + xmlValue + " is a valid option for question " + q.getTextID() + ".");
}
}
示例3: attachChoice
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void attachChoice(QuestionDef q) {
if (q.getDynamicChoices() != null) {
// can't attach dynamic choices because they aren't guaranteed to exist yet
return;
}
SelectChoice choice = null;
if (index != -1 && index < q.getNumChoices()) {
choice = q.getChoice(index);
} else if (xmlValue != null && xmlValue.length() > 0) {
choice = q.getChoiceForValue(xmlValue);
}
if (choice != null) {
attachChoice(choice);
} else {
throw new XPathTypeMismatchException("value " + xmlValue + " could not be loaded into question " + q.getTextID()
+ ". Check to see if value " + xmlValue + " is a valid option for question " + q.getTextID() + ".");
}
}
示例4: testSelectChoicesNoLocalizer
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void testSelectChoicesNoLocalizer () {
QuestionDef q = fpi.getFirstQuestionDef();
if (q.getNumChoices() != 0) {
fail("Select choices not empty on init");
}
// fpi.getNextQuestion();
String onetext = "choice";
String twotext = "stacey's";
SelectChoice one = new SelectChoice(null,onetext, "val", false);
q.addSelectChoice(one);
SelectChoice two = new SelectChoice(null,twotext, "mom", false);
q.addSelectChoice(two);
if(!fep.getSelectChoices().toString().equals("[choice => val, stacey's => mom]")) {
fail("Could not add individual select choice"+fep.getSelectChoices().toString());
}
Object a = onetext;
Object b = fep.getSelectChoiceText(one);
assertEquals("Invalid select choice text returned",a, b);
assertEquals("Invalid select choice text returned", twotext, fep.getSelectChoiceText(two));
assertNull("Form Entry Caption incorrectly contains Image Text", fep.getSpecialFormSelectChoiceText(one, FormEntryCaption.TEXT_FORM_IMAGE));
assertNull("Form Entry Caption incorrectly contains Audio Text", fep.getSpecialFormSelectChoiceText(one, FormEntryCaption.TEXT_FORM_AUDIO));
q.removeSelectChoice(q.getChoice(0));
q.removeSelectChoice(q.getChoice(0));
}
示例5: testSelectChoicesNoLocalizer
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
@Test
public void testSelectChoicesNoLocalizer() {
QuestionDef q = fpi.getFirstQuestionDef();
if (q.getNumChoices() != 0) {
fail("Select choices not empty on init");
}
// fpi.getNextQuestion();
String onetext = "choice";
String twotext = "stacey's";
SelectChoice one = new SelectChoice(null, onetext, "val", false);
q.addSelectChoice(one);
SelectChoice two = new SelectChoice(null, twotext, "mom", false);
q.addSelectChoice(two);
if (!fep.getSelectChoices().toString().equals("[choice => val, stacey's => mom]")) {
fail("Could not add individual select choice" + fep.getSelectChoices().toString());
}
Object b = fep.getSelectChoiceText(one);
assertEquals("Invalid select choice text returned", onetext, b);
assertEquals("Invalid select choice text returned", twotext, fep.getSelectChoiceText(two));
assertNull("Form Entry Caption incorrectly contains Image Text", fep.getSpecialFormSelectChoiceText(one, FormEntryCaption.TEXT_FORM_IMAGE));
assertNull("Form Entry Caption incorrectly contains Audio Text", fep.getSpecialFormSelectChoiceText(one, FormEntryCaption.TEXT_FORM_AUDIO));
q.removeSelectChoice(q.getChoice(0));
q.removeSelectChoice(q.getChoice(0));
}