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

Java SelectOneData类代码示例

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

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



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

示例1: getAnswer

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
	clearFocus();
	String response = autocomplete.getText().toString();
    for (SelectChoice sc : mItems) {
        if (response.equals(mPrompt.getSelectChoiceText(sc))) {
            return new SelectOneData(new Selection(sc));
        }
    }

    // If the user has typed text into the autocomplete box that doesn't match any answer, warn
    // them that their
    // solution didn't count.
    if (!response.equals("")) {
        Toast.makeText(getContext(),
            "Warning: \"" + response + "\" does not match any answers. No answer recorded.",
            Toast.LENGTH_LONG).show();
    }
    return null;
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:21,代码来源:AutoCompleteWidget.java


示例2: classForDataType

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
/**
 * map xforms data types to the Class that represents that data in a FormInstance
 * @param dataType
 * @return
 */
public static Class classForDataType (int dataType) {
	switch (dataType) {
	case Constants.DATATYPE_NULL: return StringData.class;
	case Constants.DATATYPE_TEXT: return StringData.class;
	case Constants.DATATYPE_INTEGER: return IntegerData.class;
	case Constants.DATATYPE_LONG: return LongData.class;
	case Constants.DATATYPE_DECIMAL: return DecimalData.class;
	case Constants.DATATYPE_BOOLEAN: return BooleanData.class;
	case Constants.DATATYPE_DATE: return DateData.class;
	case Constants.DATATYPE_TIME: return TimeData.class;
	case Constants.DATATYPE_DATE_TIME: return DateTimeData.class;
	case Constants.DATATYPE_CHOICE: return SelectOneData.class;
	case Constants.DATATYPE_CHOICE_LIST: return SelectMultiData.class;
	case Constants.DATATYPE_GEOPOINT: return GeoPointData.class;
	case Constants.DATATYPE_GEOSHAPE: return GeoShapeData.class;
	case Constants.DATATYPE_GEOTRACE: return GeoTraceData.class;
	default: return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:CompactInstanceWrapper.java


示例3: getWidgetValue

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
protected IAnswerData getWidgetValue () {
    int selectedIndex = -1;

    for (int i = 0; i < choiceGroup().size(); i++) {
        if (choiceGroup().isSelected(i)) {
            selectedIndex = i;
            break;
        }
    }
    if(selectedIndex == -1) {
        return null;
    }

    Selection s = prompt.getSelectChoices().elementAt(selectedIndex).selection();
    return new SelectOneData(s);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:SelectOneEntryWidget.java


示例4: getAnswer

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    // So that we can see any error message that gets shown as a result of this
    comboBox.dismissDropDown();

    comboBox.autoCorrectCapitalization();
    String enteredText = comboBox.getText().toString();
    if (choiceTexts.contains(enteredText)) {
        int i = choiceTexts.indexOf(enteredText);
        return new SelectOneData(new Selection(choices.elementAt(i)));
    } else if ("".equals(enteredText)) {
        return null;
    } else {
        return new InvalidData("The text entered is not a valid answer choice",
                new SelectOneData(new Selection(enteredText)));
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:18,代码来源:ComboboxWidget.java


示例5: testGroupRelevancyInsideRepeat

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
/**
 * Ensures that the relevancy condition for a group insided of a repeat is
 * properly accounted for when building the triggerables DAG
 */
@Test
public void testGroupRelevancyInsideRepeat() throws XPathSyntaxException {
    FormParseInit fpi = new FormParseInit("/xform_tests/group_relevancy_in_repeat.xml");
    FormEntryController fec =  initFormEntry(fpi);

    do {
        QuestionDef q = fpi.getCurrentQuestion();

        if (q != null && q.getControlType() == Constants.CONTROL_SELECT_ONE) {
            IAnswerData ans = new SelectOneData(new Selection("yes"));
            fec.answerQuestion(ans);
            // test that a value that should be updated has been updated
            ExprEvalUtils.testEval("/data/some_group/repeat_sum",
                    fpi.getFormDef().getInstance(), null, 25.0);
        }
    } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:22,代码来源:FormDefTest.java


示例6: testItemsetPopulationAndFilter

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
@Test
public void testItemsetPopulationAndFilter() {
    FormParseInit fpi = new FormParseInit("/xform_tests/itemset_population_test.xhtml");

    FormEntryController fec = fpi.getFormEntryController();

    do {
        QuestionDef q = fpi.getCurrentQuestion();
        if (q == null) {
            continue;
        }
        TreeReference currentRef = fec.getModel().getFormIndex().getReference();
        if(currentRef == null) { continue; }

        if(currentRef.genericize().toString().equals("/data/filter")) {
            fec.answerQuestion(new SelectOneData(new Selection("a")));
        }

        if(currentRef.genericize().toString().equals("/data/question")) {
            assertEquals("Itemset Filter returned the wrong size",
                    fec.getModel().getQuestionPrompt().getSelectChoices().size(),
                    3);
        }

    } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:27,代码来源:FormDefTest.java


示例7: getAnswer

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    int i = getCheckedId();
    if (i == -1) {
        return null;
    } else {
        SelectChoice sc = mItems.get(i);
        return new SelectOneData(new Selection(sc));
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:11,代码来源:ListWidget.java


示例8: getAnswer

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
	int i = getCheckedId();
	if (i == -1) {
		return null;
	} else {
		SelectChoice sc = mItems.get(i);
		return new SelectOneData(new Selection(sc));
	}
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:11,代码来源:SelectOneWidget.java


示例9: getAnswer

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    for (int i = 0; i < choices.length; ++i) {
        if (selected[i]) {
            SelectChoice sc = mItems.get(i);
            return new SelectOneData(new Selection(sc));
        }
    }
    return null;
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:11,代码来源:GridWidget.java


示例10: getAnswer

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
	clearFocus();
    int i = spinner.getSelectedItemPosition();
    if (i == -1 || i == mItems.size()) {
        return null;
    } else {
        SelectChoice sc = mItems.get(i);
        return new SelectOneData(new Selection(sc));
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:12,代码来源:SpinnerWidget.java


示例11: unpackValue

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
public static Object unpackValue (IAnswerData val) {
	if (val == null) {
		return "";
	} else if (val instanceof UncastData) {
		return val.getValue();
	} else if (val instanceof IntegerData) {
		return new Double(((Integer)val.getValue()).doubleValue());
	} else if (val instanceof LongData) {
		return new Double(((Long)val.getValue()).doubleValue());
	} else if (val instanceof DecimalData) {
		return val.getValue();
	} else if (val instanceof StringData) {
		return val.getValue();
	} else if (val instanceof SelectOneData) {
		return ((Selection)val.getValue()).getValue();
	} else if (val instanceof SelectMultiData) {
		return (new XFormAnswerDataSerializer()).serializeAnswerData(val);
	} else if (val instanceof DateData) {
		return val.getValue();
	} else if (val instanceof BooleanData) {
		return val.getValue();
	} else if (val instanceof GeoPointData) {
		// we have no access fns that interact with double[4] arrays (the getValue() data type)...
		return val.getDisplayText();
	} else if (val instanceof GeoShapeData) {
		// we have no access fns that interact with GeoShape objects (the getValue() data type)...
		return val.getDisplayText();
	} else if (val instanceof GeoTraceData) {
		// we have no access fns that interact with GeoTrace objects (the getValue() data type)...
		return val.getDisplayText();
	} else {
		System.out.println("warning: unrecognized data type in xpath expr: " + val.getClass().getName());
		return val.getValue(); //is this a good idea?
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:36,代码来源:XPathPathExpr.java


示例12: attachControlsToInstanceData

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
private void attachControlsToInstanceData(TreeElement node) {
   for (int i = 0; i < node.getNumChildren(); i++) {
      attachControlsToInstanceData(node.getChildAt(i));
   }

   IAnswerData val = node.getValue();
   List<Selection> selections = null;
   if (val instanceof SelectOneData) {
      selections = new ArrayList<Selection>();
      selections.add((Selection) val.getValue());
   } else if (val instanceof SelectMultiData) {
      selections = (List<Selection>) val.getValue();
   }

   if (selections != null) {
      QuestionDef q = findQuestionByRef(node.getRef(), this);
      if (q == null) {
         throw new RuntimeException(
                 "FormDef.attachControlsToInstanceData: can't find question to link");
      }

      if (q.getDynamicChoices() != null) {
         // droos: i think we should do something like initializing the
         // itemset here, so that default answers
         // can be linked to the selectchoices. however, there are
         // complications. for example, the itemset might
         // not be ready to be evaluated at form initialization; it may
         // require certain questions to be answered
         // first. e.g., if we evaluate an itemset and it has no choices, the
         // xform engine will throw an error
         // itemset TODO
      }

      for (int i = 0; i < selections.size(); i++) {
         Selection s = selections.get(i);
         s.attachChoice(q);
      }
   }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:40,代码来源:FormDef.java


示例13: populateTemplate

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
public void populateTemplate(TreeElement incoming, FormDef f) {
	if (this.isLeaf()) {
		IAnswerData value = incoming.getValue();
		if (value == null) {
			this.setValue(null);
		} else {
			Class classType = CompactInstanceWrapper.classForDataType(this.dataType);

			if (classType == null) {
				throw new RuntimeException("data type [" + value.getClass().getName() + "] not supported inside itemset");
			} else if (classType.isAssignableFrom(value.getClass()) &&
						!(value instanceof SelectOneData || value instanceof SelectMultiData)) {
				this.setValue(value);
			} else {
				String textVal = RestoreUtils.xfFact.serializeData(value);
				IAnswerData typedVal = RestoreUtils.xfFact.parseData(textVal, this.dataType, this.getRef(), f);
				this.setValue(typedVal);
			}
		}
	} else {
		for (int i = 0; i < this.getNumChildren(); i++) {
			TreeElement child = this.getChildAt(i);
			List<TreeElement> newChildren = incoming.getChildrenWithName(child.getName());

			if (child.getMaskVar(MASK_REPEATABLE)) {
			    for (int k = 0; k < newChildren.size(); k++) {
			    	TreeElement template = f.getMainInstance().getTemplate(child.getRef());
			        TreeElement newChild = template.deepCopy(false);
			        newChild.setMult(k);
			        if(children == null) { children = new ArrayList<TreeElement>(); }
			        this.children.add(i + k + 1, newChild);
			        newChild.populateTemplate(newChildren.get(k), f);
			    }
			    i += newChildren.size();
			} else {
				child.populateTemplate(newChildren.get(0), f);
			}
		}
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:41,代码来源:TreeElement.java


示例14: canSerialize

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
public boolean canSerialize(IAnswerData data) {
	if (data instanceof StringData || data instanceof DateData || data instanceof TimeData ||
	    data instanceof SelectMultiData || data instanceof SelectOneData ||
	    data instanceof IntegerData || data instanceof DecimalData || data instanceof PointerAnswerData	||
	    data instanceof MultiPointerAnswerData ||
	    data instanceof GeoPointData || data instanceof GeoTraceData || data instanceof GeoShapeData ||
	    data instanceof LongData || data instanceof DateTimeData || data instanceof UncastData) {
		return true;
	} else {
		return false;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:13,代码来源:XFormAnswerDataSerializer.java


示例15: serializeAnswerData

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
public Object serializeAnswerData(IAnswerData data) {
	if (data instanceof StringData) {
		return serializeAnswerData((StringData)data);
	} else if (data instanceof SelectMultiData) {
		return serializeAnswerData((SelectMultiData)data);
	} else if (data instanceof SelectOneData) {
		return serializeAnswerData((SelectOneData)data);
	} else if (data instanceof IntegerData){
		return serializeAnswerData((IntegerData)data);
	} else if (data instanceof LongData){
		return serializeAnswerData((LongData)data);
	} else if (data instanceof DecimalData) {
		return serializeAnswerData((DecimalData)data);
	} else if (data instanceof DateData) {
		return serializeAnswerData((DateData)data);
	} else if (data instanceof TimeData) {
		return serializeAnswerData((TimeData)data);
	} else if (data instanceof PointerAnswerData) {
		return serializeAnswerData((PointerAnswerData)data);
	} else if (data instanceof MultiPointerAnswerData) {
		return serializeAnswerData((MultiPointerAnswerData)data);
	} else if (data instanceof GeoShapeData) {
           return serializeAnswerData((GeoShapeData)data);
	} else if (data instanceof GeoTraceData) {
           return serializeAnswerData((GeoTraceData)data);
	} else if (data instanceof GeoPointData) {
           return serializeAnswerData((GeoPointData)data);
       } else if (data instanceof DateTimeData) {
           return serializeAnswerData((DateTimeData)data);
       } else if (data instanceof BooleanData) {
           return serializeAnswerData((BooleanData)data);
       } else if (data instanceof UncastData) {
           return serializeAnswerData((UncastData)data);
       }

	return null;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:38,代码来源:XFormAnswerDataSerializer.java


示例16: testSetData

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
public void testSetData() {
	SelectOneData data = new SelectOneData(one);
	data.setValue(two);
	
	assertTrue("SelectOneData did not set value properly. Maintained old value.", !(data.getValue().equals(one)));
	assertEquals("SelectOneData did not properly set value ", data.getValue(), two);
	
	data.setValue(one);
	assertTrue("SelectOneData did not set value properly. Maintained old value.", !(data.getValue().equals(two)));
	assertEquals("SelectOneData did not properly reset value ", data.getValue(), one);
	
}
 
开发者ID:medic,项目名称:javarosa,代码行数:13,代码来源:SelectOneDataTests.java


示例17: testNullData

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
public void testNullData() {
	boolean exceptionThrown = false;
	SelectOneData data = new SelectOneData();
	data.setValue(one);
	try { 
		data.setValue(null);
	} catch (NullPointerException e) {
		exceptionThrown = true;
	}
	assertTrue("SelectOneData failed to throw an exception when setting null data", exceptionThrown);
	assertTrue("SelectOneData overwrote existing value on incorrect input", data.getValue().equals(one));
}
 
开发者ID:medic,项目名称:javarosa,代码行数:13,代码来源:SelectOneDataTests.java


示例18: getAnswerText

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
public String getAnswerText() {
    IAnswerData data = this.getAnswerValue();

    if (data == null)
        return null;
    else {
        String text;

        //[email protected] - Aug 11, 2010 - Added special logic to
        //capture and display the appropriate value for selections
        //and multi-selects.
        if (data instanceof SelectOneData) {
            text = this.getSelectItemText((Selection)data.getValue());
        } else if (data instanceof SelectMultiData) {
            String returnValue = "";
            Vector<Selection> values = (Vector<Selection>)data.getValue();
            for (Selection value : values) {
                returnValue += this.getSelectItemText(value) + " ";
            }
            text = returnValue;
        } else {
            text = data.getDisplayText();
        }

        if (getControlType() == Constants.CONTROL_SECRET) {
            String obfuscated = "";
            for (int i = 0; i < text.length(); ++i) {
                obfuscated += "*";
            }
            text = obfuscated;
        }
        return text;
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:35,代码来源:FormEntryPrompt.java


示例19: unpackValue

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
public static Object unpackValue(IAnswerData val) {
    if (val == null) {
        return "";
    } else if (val instanceof UncastData) {
        return val.getValue();
    } else if (val instanceof IntegerData) {
        return new Double(((Integer)val.getValue()).doubleValue());
    } else if (val instanceof LongData) {
        return new Double(((Long)val.getValue()).doubleValue());
    } else if (val instanceof DecimalData) {
        return val.getValue();
    } else if (val instanceof StringData) {
        return val.getValue();
    } else if (val instanceof SelectOneData) {
        return ((Selection)val.getValue()).getValue();
    } else if (val instanceof SelectMultiData) {
        return (new XFormAnswerDataSerializer()).serializeAnswerData(val);
    } else if (val instanceof DateData) {
        return val.getValue();
    } else if (val instanceof DateTimeData) {
        return val.getValue();
    } else if (val instanceof BooleanData) {
        return val.getValue();
    } else if (val instanceof GeoPointData) {
        return val.uncast().getString();
    } else {
        System.out.println("warning: unrecognized data type in xpath expr: " + val.getClass().getName());

        //TODO: Does this mess up any of our other plans?
        return val.uncast().getString();
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:33,代码来源:XPathPathExpr.java


示例20: attachControlsToInstanceData

import org.javarosa.core.model.data.SelectOneData; //导入依赖的package包/类
private void attachControlsToInstanceData(TreeElement node) {
    for (int i = 0; i < node.getNumChildren(); i++) {
        attachControlsToInstanceData(node.getChildAt(i));
    }

    IAnswerData val = node.getValue();
    Vector selections = null;
    if (val instanceof SelectOneData) {
        selections = new Vector();
        selections.addElement(val.getValue());
    } else if (val instanceof SelectMultiData) {
        selections = (Vector)val.getValue();
    }

    if (selections != null) {
        QuestionDef q = findQuestionByRef(node.getRef(), this);
        if (q == null) {
            throw new RuntimeException("FormDef.attachControlsToInstanceData: can't find question to link");
        }

        if (q.getDynamicChoices() != null) {
            //droos: i think we should do something like initializing the itemset here, so that default answers
            //can be linked to the selectchoices. however, there are complications. for example, the itemset might
            //not be ready to be evaluated at form initialization; it may require certain questions to be answered
            //first. e.g., if we evaluate an itemset and it has no choices, the xform engine will throw an error
            //itemset TODO
        }

        for (int i = 0; i < selections.size(); i++) {
            Selection s = (Selection)selections.elementAt(i);
            s.attachChoice(q);
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:35,代码来源:FormDef.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java JTicketsBagSimple类代码示例发布时间:2022-05-23
下一篇:
Java BytesPushThroughSerializer类代码示例发布时间: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