当前位置: 首页>>代码示例>>Java>>正文


Java IAnswerData.getValue方法代码示例

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


在下文中一共展示了IAnswerData.getValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: getVariableValue

import org.javarosa.core.model.data.IAnswerData; //导入方法依赖的package包/类
public static <T> T getVariableValue(String variableName,
                                     FormDef form,
                                     Class<T> classOfT) {
    IAnswerData variableValue = getVariableValue(variableName, form);
    if (variableValue != null) {
        Object value = variableValue.getValue();
        if (classOfT.isInstance(value)) {
            return classOfT.cast(value);
        }
    }
    return null;
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:13,代码来源:FormsUtils.java

示例4: unpackValue

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

示例5: canCreateRepeat

import org.javarosa.core.model.data.IAnswerData; //导入方法依赖的package包/类
public boolean canCreateRepeat(TreeReference repeatRef, FormIndex repeatIndex) {
   GroupDef repeat = (GroupDef) this.getChild(repeatIndex);

   // Check to see if this repeat can have children added by the user
   if (repeat.noAddRemove) {
      // Check to see if there's a count to use to determine how many
      // children this repeat
      // should have
      if (repeat.getCountReference() != null) {
         int currentMultiplicity = repeatIndex.getElementMultiplicity();

         // Lu Gram: the count XPath needs to be contextualized for nested
         // repeat groups...
         TreeReference countRef = FormInstance.unpackReference(repeat.getCountReference());
         TreeElement countNode = this.getMainInstance().resolveReference(
                 countRef.contextualize(repeatRef));
         if (countNode == null) {
            throw new RuntimeException("Could not locate the repeat count value expected at "
                    + repeat.getCountReference().getReference().toString());
         }
         // get the total multiplicity possible
         IAnswerData count = countNode.getValue();
         long fullcount = count == null ? 0 : (Integer) count.getValue();

         if (fullcount <= currentMultiplicity) {
            return false;
         }
      } else {
         // Otherwise the user can never add repeat instances
         return false;
      }
   }

   // TODO: If we think the node is still relevant, we also need to figure
   // out a way to test that assumption against
   // the repeat's constraints.

   return true;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:40,代码来源:FormDef.java

示例6: attachControlsToInstanceData

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

示例7: getValue

import org.javarosa.core.model.data.IAnswerData; //导入方法依赖的package包/类
public static Object getValue (String xpath, TreeReference context, FormInstance tree) {
	TreeElement node = tree.resolveReference(ref(xpath).contextualize(context));
	if (node == null) {
		throw new RuntimeException("Could not find node [" + xpath + "] when parsing saved instance!");
	}

	if (node.isRelevant()) {
		IAnswerData val = node.getValue();
		return (val == null ? null : val.getValue());
	} else {
		return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:14,代码来源:RestoreUtils.java


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