本文整理汇总了Java中org.javarosa.core.model.data.IAnswerData类的典型用法代码示例。如果您正苦于以下问题:Java IAnswerData类的具体用法?Java IAnswerData怎么用?Java IAnswerData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAnswerData类属于org.javarosa.core.model.data包,在下文中一共展示了IAnswerData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAnswers
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
/**
* @return a HashMap of answers entered by the user for this set of widgets
*/
public LinkedHashMap<FormIndex, IAnswerData> getAnswers() {
LinkedHashMap<FormIndex, IAnswerData> answers = new LinkedHashMap<FormIndex, IAnswerData>();
Iterator<QuestionWidget> i = widgets.iterator();
while (i.hasNext()) {
/*
* The FormEntryPrompt has the FormIndex, which is where the answer gets stored. The
* QuestionWidget has the answer the user has entered.
*/
QuestionWidget q = i.next();
FormEntryPrompt p = q.getPrompt();
answers.put(p.getIndex(), q.getAnswer());
}
return answers;
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:19,代码来源:ODKView.java
示例2: saveAnswersForCurrentScreen
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
/**
* Attempt to save the answer(s) in the current screen to into the data
* model.
*
* @param evaluateConstraints
* @return false if any error occurs while saving (constraint violated,
* etc...), true otherwise.
*/
private boolean saveAnswersForCurrentScreen(boolean evaluateConstraints) {
FormController formController = Collect.getInstance()
.getFormController();
// only try to save if the current event is a question or a field-list
// group
if (formController.currentPromptIsQuestion()) {
LinkedHashMap<FormIndex, IAnswerData> answers = ((ODKView) mCurrentView)
.getAnswers();
try {
FailedConstraint constraint = formController.saveAllScreenAnswers(answers, evaluateConstraints);
if (constraint != null) {
createConstraintToast(constraint.index, constraint.status);
return false;
}
} catch (JavaRosaException e) {
Log.e(t, e.getMessage(), e);
createErrorDialog(e.getCause().getMessage(), DO_NOT_EXIT);
return false;
}
}
return true;
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:31,代码来源:FormEntryActivity.java
示例3: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的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
示例4: testGeoShapeSupportForEnclosedArea
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
public void testGeoShapeSupportForEnclosedArea() throws Exception {
// Read the form definition
String FORM_NAME = (new File(PathConst.getTestResourcePath(), "area.xml")).getAbsolutePath();
InputStream is = null;
FormDef formDef = null;
is = new FileInputStream(new File(FORM_NAME));
formDef = XFormUtils.getFormFromInputStream(is);
// trigger all calculations
formDef.initialize(true, new InstanceInitializationFactory());
// get the calculated area
IAnswerData areaResult = formDef.getMainInstance().getRoot().getChildAt(1).getValue();
assertTrue((int) Math.rint((Double) areaResult.getValue()) == 151452);
}
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:GeoShapeAreaTest.java
示例5: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的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
示例6: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的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
示例7: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的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
示例8: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的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
示例9: toString
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
@Override
public String toString() {
if (getAffectedRef() == null) {
return "";
} else {
StringBuilder sb = new StringBuilder();
String refStr = getAffectedRef().toShortString();
sb.append(refStr);
if (value != null) {
sb.append(" (");
if (value instanceof IAnswerData) {
sb.append(((IAnswerData) value).getDisplayText());
} else {
sb.append(String.valueOf(value));
}
sb.append(")");
}
return sb.toString();
}
}
开发者ID:medic,项目名称:javarosa,代码行数:21,代码来源:EvaluationResult.java
示例10: evaluateConstraint
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
public boolean evaluateConstraint(TreeReference ref, IAnswerData data) {
if (data == null) {
return true;
}
TreeElement node = mainInstance.resolveReference(ref);
Constraint c = node.getConstraint();
if (c == null) {
return true;
}
EvaluationContext ec = new EvaluationContext(exprEvalContext, ref);
ec.isConstraint = true;
ec.candidateValue = data;
boolean result = c.constraint.eval(mainInstance, ec);
getEventNotifier().publishEvent(new Event("Constraint", new EvaluationResult(ref, new Boolean(result))));
return result;
}
开发者ID:medic,项目名称:javarosa,代码行数:22,代码来源:FormDef.java
示例11: preloadInstance
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
/**
* Preload the Data Model with the preload values that are enumerated in the
* data bindings.
*/
public void preloadInstance(TreeElement node) {
// if (node.isLeaf()) {
IAnswerData preload = null;
if (node.getPreloadHandler() != null) {
preload = preloader.getQuestionPreload(node.getPreloadHandler(), node.getPreloadParams());
}
if (preload != null) { // what if we want to wipe out a value in the
// instance?
node.setAnswer(preload);
}
// } else {
if (!node.isLeaf()) {
for (int i = 0; i < node.getNumChildren(); i++) {
TreeElement child = node.getChildAt(i);
if (child.getMult() != TreeReference.INDEX_TEMPLATE)
// don't preload templates; new repeats are preloaded as they're
// created
preloadInstance(child);
}
}
// }
}
开发者ID:medic,项目名称:javarosa,代码行数:27,代码来源:FormDef.java
示例12: wrapIndeterminedObject
import org.javarosa.core.model.data.IAnswerData; //导入依赖的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
示例13: retrieveExternalDataPointer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
public IDataPointer[] retrieveExternalDataPointer(IAnswerData data) {
for (IAnswerDataSerializer serializer : additionalSerializers) {
Boolean contains = serializer.containsExternalData(data);
if(contains != null) {
return serializer.retrieveExternalDataPointer(data);
}
}
if( data instanceof PointerAnswerData) {
IDataPointer[] pointer = new IDataPointer[1];
pointer[0] = (IDataPointer)((PointerAnswerData)data).getValue();
return pointer;
}
else if (data instanceof MultiPointerAnswerData ) {
return (IDataPointer[])((MultiPointerAnswerData)data).getValue();
}
//This shouldn't have been called.
return null;
}
开发者ID:medic,项目名称:javarosa,代码行数:19,代码来源:XFormAnswerDataSerializer.java
示例14: saveAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
/**
* Attempts to save an answer to the specified index.
*
* @param answer
* @param index
* @param evaluateConstraints
* @return status as determined in FormEntryController
*/
public int saveAnswer(IAnswerData answer, FormIndex index,
boolean evaluateConstraints) throws JavaRosaException {
FormController formController = Collect.getInstance()
.getFormController();
if (evaluateConstraints) {
return formController.answerQuestion(index, answer);
} else {
formController.saveAnswer(index, answer);
return FormEntryController.ANSWER_OK;
}
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:20,代码来源:FormEntryActivity.java
示例15: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的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
示例16: getDoubleAnswerValue
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
private Double getDoubleAnswerValue() {
IAnswerData dataHolder = mPrompt.getAnswerValue();
Double d = null;
if (dataHolder != null) {
Object dataValue = dataHolder.getValue();
if ( dataValue != null ) {
if (dataValue instanceof Integer){
d = Double.valueOf(((Integer)dataValue).intValue());
} else {
d = (Double) dataValue;
}
}
}
return d;
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:16,代码来源:DecimalWidget.java
示例17: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
clearFocus();
String s = mAnswer.getText().toString();
if (s == null || s.equals("")) {
return null;
} else {
try {
return new DecimalData(Double.valueOf(s).doubleValue());
} catch (Exception NumberFormatException) {
return null;
}
}
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:15,代码来源:DecimalWidget.java
示例18: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
if (mAnswer == null) {
return null;
} else {
return new StringData(mAnswer);
}
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:9,代码来源:ItemsetWidget.java
示例19: getAnswer
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
String s = mStringAnswer.getText().toString();
if (s == null || s.equals("")) {
return null;
} else {
return new StringData(s);
}
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:10,代码来源:BarcodeWidget.java
示例20: getIntegerAnswerValue
import org.javarosa.core.model.data.IAnswerData; //导入依赖的package包/类
private Integer getIntegerAnswerValue() {
IAnswerData dataHolder = mPrompt.getAnswerValue();
Integer d = null;
if (dataHolder != null) {
Object dataValue = dataHolder.getValue();
if ( dataValue != null ) {
if (dataValue instanceof Double){
d = Integer.valueOf(((Double) dataValue).intValue());
} else {
d = (Integer)dataValue;
}
}
}
return d;
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:16,代码来源:ExIntegerWidget.java
注:本文中的org.javarosa.core.model.data.IAnswerData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论