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

Java Selection类代码示例

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

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



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

示例1: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    List<Selection> vc = new ArrayList<Selection>();
    for (int i = 0; i < mCheckboxes.size(); i++) {
    	CheckBox c = mCheckboxes.get(i);
        if (c.isChecked()) {
            vc.add(new Selection(mItems.get(i)));
        }
    }

    if (vc.size() == 0) {
        return null;
    } else {
        return new SelectMultiData(vc);
    }

}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:18,代码来源:ListMultiWidget.java


示例2: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
	clearFocus();
    List<Selection> vc = new ArrayList<Selection>();
    for (int i = 0; i < mItems.size(); i++) {
        if (selections[i]) {
            SelectChoice sc = mItems.get(i);
            vc.add(new Selection(sc));
        }
    }
    if (vc.size() == 0) {
        return null;
    } else {
        return new SelectMultiData(vc);
    }

}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:18,代码来源:SpinnerMultiWidget.java


示例3: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    List<Selection> vc = new ArrayList<Selection>();
    for ( int i = 0; i < mCheckboxes.size() ; ++i ) {
    	CheckBox c = mCheckboxes.get(i);
    	if ( c.isChecked() ) {
    		vc.add(new Selection(mItems.get(i)));
    	}
    }

    if (vc.size() == 0) {
        return null;
    } else {
        return new SelectMultiData(vc);
    }

}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:18,代码来源:SelectMultiWidget.java


示例4: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    List<Selection> vc = new ArrayList<Selection>();
    for (int i = 0; i < mItems.size(); i++) {
        if (selected[i]) {
            SelectChoice sc = mItems.get(i);
            vc.add(new Selection(sc));
        }
    }

    if (vc.size() == 0) {
        return null;
    } else {
        return new SelectMultiData(vc);
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:17,代码来源:GridMultiWidget.java


示例5: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的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


示例6: getSelectItemText

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
/**
 * Attempts to return the specified Item (from a select or 1select) text.
 * Will check for text in the following order:<br/>
 * Localized Text (long form) -> Localized Text (no special form) <br />
 * If no textID is available, method will return this item's labelInnerText.
 * @param sel the selection (item), if <code>null</code> will throw a IllegalArgumentException
 * @return Question Text.  <code>null</code> if no text for this element exists (after all fallbacks).
 * @throws RunTimeException if this method is called on an element that is NOT a QuestionDef
 * @throws IllegalArgumentException if Selection is <code>null</code>
 */
public String getSelectItemText(Selection sel){
	//throw tantrum if this method is called when it shouldn't be or sel==null
	if(!(getFormElement() instanceof QuestionDef)) throw new RuntimeException("Can't retrieve question text for non-QuestionDef form elements!");
	if(sel == null) throw new IllegalArgumentException("Cannot use null as an argument!");

	//Just in case the selection hasn't had a chance to be initialized yet.
	if(sel.index == -1) { sel.attachChoice(this.getQuestion()); }

	//check for the null id case and return labelInnerText if it is so.
	String tid = sel.choice.getTextID();
	if(tid == null || tid == "") return substituteStringArgs(sel.choice.getLabelInnerText());

	//otherwise check for 'long' form of the textID, then for the default form and return
	String returnText;
	returnText = getIText(tid, "long");
	if(returnText == null) returnText = getIText(tid,null);

	return substituteStringArgs(returnText);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:30,代码来源:FormEntryPrompt.java


示例7: getDisplayText

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
/**
 * @return THE XMLVALUE!!
 */
/*
 * (non-Javadoc)
 * @see org.javarosa.core.model.data.IAnswerData#getDisplayText()
 */
   @Override
public String getDisplayText () {
	StringBuilder b = new StringBuilder();

	for (int i = 0; i < vs.size(); i++) {
		Selection s = (Selection)vs.get(i);
		b.append(s.getValue());
		if (i < vs.size() - 1)
			b.append(", ");
	}

	return b.toString();
}
 
开发者ID:medic,项目名称:javarosa,代码行数:21,代码来源:SelectMultiData.java


示例8: wrapIndeterminedObject

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
/**
 * Note: This method is a hack to fix the problem that we don't know what
 * data type we're using when we have a preloader. That should get fixed, 
 * and this method should be removed.
 * @param o
 * @return
 */
public static IAnswerData wrapIndeterminedObject(Object o) {
	if(o == null) {
		return null;
	}
	
	//TODO: Replace this all with an uncast data
	if(o instanceof String) {
		return new StringData((String)o);
	} else if(o instanceof Date) {
		return new DateData((Date)o);
	} else if (o instanceof Integer) {
		return new IntegerData((Integer)o);
	} else if (o instanceof Long) {
		return new LongData((Long)o);
	} else if (o instanceof Double) {
		return new DecimalData((Double)o);
	} else if(o instanceof List) {
		return new SelectMultiData((List<Selection>)o);
	} else if(o instanceof IAnswerData) {
		return (IAnswerData)o;
	}
	return new StringData(o.toString());
}
 
开发者ID:medic,项目名称:javarosa,代码行数:31,代码来源:PreloadUtils.java


示例9: testVectorImmutability

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
public void testVectorImmutability() {
	SelectMultiData data = new SelectMultiData(firstTwo);
	Selection[] copy = new Selection[firstTwo.size()];
	firstTwo.toArray(copy);
	firstTwo.set(0, two);
	firstTwo.remove(1);
	
	List<Selection> internal = (List<Selection>)data.getValue();

	assertVectorIdentity("External Reference: ", internal, copy);
	
	data.setValue(lastTwo);
       List<Selection> start = (List<Selection>)data.getValue();
	
	Selection[] external = new Selection[start.size()];
	start.toArray(external);
	
	start.remove(1);
	start.set(0, one);
	
	assertVectorIdentity("Internal Reference: ", (List<Selection>)data.getValue(), external);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:SelectMultiDataTests.java


示例10: getWidgetValue

import org.javarosa.core.model.data.helper.Selection; //导入依赖的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


示例11: getSelectItemText

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
/**
 * Attempts to return the specified Item (from a select or 1select) text.
 * Will check for text in the following order:<br/>
 * Localized Text (long form) -> Localized Text (no special form) <br />
 * If no textID is available, method will return this item's labelInnerText.
 *
 * @param sel the selection (item), if <code>null</code> will throw a IllegalArgumentException
 * @return Question Text.  <code>null</code> if no text for this element exists (after all fallbacks).
 * @throws IllegalArgumentException if Selection is <code>null</code>
 */
public String getSelectItemText(Selection sel) {
    //throw tantrum if this method is called when it shouldn't be or sel==null
    if (!(getFormElement() instanceof QuestionDef))
        throw new RuntimeException("Can't retrieve question text for non-QuestionDef form elements!");
    if (sel == null) throw new IllegalArgumentException("Cannot use null as an argument!");

    //Just in case the selection hasn't had a chance to be initialized yet.
    if (sel.index == -1) {
        sel.attachChoice(this.getQuestion());
    }

    //check for the null id case and return labelInnerText if it is so.
    String tid = sel.choice.getTextID();
    if (tid == null || "".equals(tid)) {
        return substituteStringArgs(sel.choice.getLabelInnerText());
    }

    //otherwise check for 'long' form of the textID, then for the default form and return
    String returnText;
    returnText = getIText(tid, "long");
    if (returnText == null) returnText = getIText(tid, null);

    return substituteStringArgs(returnText);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:35,代码来源:FormEntryPrompt.java


示例12: getDisplayText

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
/**
 * @return THE XMLVALUE!!
 */
/*
 * (non-Javadoc)
 * @see org.javarosa.core.model.data.IAnswerData#getDisplayText()
 */
public String getDisplayText() {
    String str = "";

    for (int i = 0; i < vs.size(); i++) {
        Selection s = vs.elementAt(i);
        str += s.getValue();
        if (i < vs.size() - 1)
            str += ", ";
    }

    return str;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:20,代码来源:SelectMultiData.java


示例13: serializeAnswerData

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
/**
 * @param data The AnswerDataObject to be serialized
 * @return A string containing the xforms compliant format
 * for a <select> tag, a string containing a list of answers
 * separated by space characters.
 */
public Object serializeAnswerData(SelectMultiData data) {
    Vector selections = (Vector)data.getValue();
    Enumeration en = selections.elements();
    StringBuffer selectString = new StringBuffer();

    while (en.hasMoreElements()) {
        Selection selection = (Selection)en.nextElement();
        if (selectString.length() > 0)
            selectString.append(DELIMITER);
        selectString.append(selection.getValue());
    }
    //As Crazy, and stupid, as it sounds, this is the XForms specification
    //for storing multiple selections.
    return selectString.toString();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:22,代码来源:XFormAnswerDataSerializer.java


示例14: setUp

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    question = new QuestionDef();
    question.setID(57);

    OrderedHashtable oh = new OrderedHashtable();
    Vector v = new Vector();
    for (int i = 0; i < 3; i++) {
        question.addSelectChoice(new SelectChoice("", "Selection" + i, "Selection" + i, false));
    }

    one = new Selection("Selection1");
    one.attachChoice(question);
    two = new Selection("Selection2");
    two.attachChoice(question);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:SelectOneDataTests.java


示例15: testVectorImmutability

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Test
public void testVectorImmutability() {
    SelectMultiData data = new SelectMultiData(firstTwo);
    Selection[] copy = new Selection[firstTwo.size()];
    firstTwo.copyInto(copy);
    firstTwo.setElementAt(two, 0);
    firstTwo.removeElementAt(1);

    Vector internal = (Vector)data.getValue();

    assertVectorIdentity("External Reference: ", internal, copy);

    data.setValue(lastTwo);
    Vector start = (Vector)data.getValue();

    Selection[] external = new Selection[start.size()];
    start.copyInto(external);

    start.removeElementAt(1);
    start.setElementAt(one, 0);

    assertVectorIdentity("Internal Reference: ", (Vector)data.getValue(), external);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:24,代码来源:SelectMultiDataTests.java


示例16: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的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


示例17: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    Vector<Selection> vc = new Vector<>();
    for (int i = 0; i < mItems.size(); i++) {
        CheckBox c = ((CheckBox)findViewById(CHECKBOX_ID + i));
        if (c.isChecked()) {
            vc.add(new Selection(mItems.get(i)));
        }

    }

    if (vc.size() == 0) {
        return null;
    } else {
        return new SelectMultiData(vc);
    }

}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:19,代码来源:ListMultiWidget.java


示例18: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    Vector<Selection> vc = new Vector<>();
    for (int i = 0; i < mItems.size(); i++) {
        CheckBox c = ((CheckBox)findViewById(buttonIdBase + i));
        if (c.isChecked()) {
            vc.add(new Selection(mItems.get(i)));
        }
    }

    if (vc.size() == 0) {
        return null;
    } else {
        return new SelectMultiData(vc);
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:17,代码来源:SelectMultiWidget.java


示例19: getAnswer

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
    Vector<Selection> vc = new Vector<>();
    for (int i = 0; i < mItems.size(); i++) {
        if (selected[i]) {
            SelectChoice sc = mItems.get(i);
            vc.add(new Selection(sc));
        }
    }

    if (vc.size() == 0) {
        return null;
    } else {
        return new SelectMultiData(vc);
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:17,代码来源:GridMultiWidget.java


示例20: testVectorImmutability

import org.javarosa.core.model.data.helper.Selection; //导入依赖的package包/类
@Test
public void testVectorImmutability() {
    SelectMultiData data = new SelectMultiData(firstTwo);
    Selection[] copy = new Selection[firstTwo.size()];
    firstTwo.copyInto(copy);
    firstTwo.setElementAt(two, 0);
    firstTwo.removeElementAt(1);

    Vector internal = (Vector)data.getValue();

    assertVectorIdentity("External Reference: ", internal, copy);

    data.setValue(lastTwo);
    Vector<Selection> start = data.getValue();

    Selection[] external = new Selection[start.size()];
    start.copyInto(external);

    start.removeElementAt(1);
    start.setElementAt(one, 0);

    assertVectorIdentity("Internal Reference: ", (Vector)data.getValue(), external);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:24,代码来源:SelectMultiDataTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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