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


Java TreeElement.getValue方法代码示例

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


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

示例1: getVariableValue

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public static IAnswerData getVariableValue(String variableName,
                                           FormDef formDef) {
    TreeElement element = findChildForName(formDef.getInstance().getRoot(), variableName);
    if (element != null) {
        return element.getValue();
    }
    return null;
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:9,代码来源:FormsUtils.java

示例2: commitAnswer

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
/**
 * commitAnswer actually saves the data into the datamodel.
 *
 * @param element
 * @param index
 * @param data
 * @return true if saved successfully, false otherwise
 */
private boolean commitAnswer(TreeElement element, FormIndex index, IAnswerData data, boolean midSurvey) {
    if (data != null || element.getValue() != null) {
        // we should check if the data to be saved is already the same as
        // the data in the model, but we can't (no IAnswerData.equals())
        model.getForm().setValue(data, index.getReference(), element, midSurvey);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:19,代码来源:FormEntryController.java

示例3: getValue

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

示例4: printDefault

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private static String printDefault (TreeElement node) {
	String value = null;

	if (node.getPreloadHandler() != null) {
		if (node.getPreloadHandler().equals("date")) {
			if (node.getPreloadParams().equals("today")) {
				value = "Today's Date";
			}
		} else if (node.getPreloadHandler().equals("property")) {
			if (node.getPreloadParams().equals("DeviceID")) {
				value = "Device ID";
			}
		} else if (node.getPreloadHandler().equals("timestamp")) {
			if (node.getPreloadParams().equals("start")) {
				value = "Timestamp when form opened";
			} else if (node.getPreloadParams().equals("end")) {
				value = "Timestamp when form completed";
			}
		} else if (node.getPreloadHandler().equals("context")) {
			if (node.getPreloadParams().equals("UserID")) {
				value = "User ID";
			} else if (node.getPreloadParams().equals("UserName")) {
				value = "User Name";
			}
		} else if (node.getPreloadHandler().equals("patient")) {
			value = "Patient Record: " + node.getPreloadParams();
		}

		if (value == null) {
			value = "Preload Handler: " + node.getPreloadHandler();
			if (node.getPreloadParams() != null) {
				value = value + "; params: " + node.getPreloadParams();
			}
		}
	} else {
		if (node.getValue() != null) {
			XFormAnswerDataSerializer xfads = new XFormAnswerDataSerializer();
			if (xfads.canSerialize(node.getValue())) {
				value = (String)xfads.serializeAnswerData(node.getValue(), node.getDataType());
			} else {
				value = "unknown data";
			}
		}
	}

	return value;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:48,代码来源:FormOverview.java

示例5: serializeNode

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public String serializeNode(TreeElement instanceNode) {
	StringBuilder b = new StringBuilder();
	// don't serialize template nodes or non-relevant nodes
	if (!instanceNode.isRelevant()
			|| instanceNode.getMult() == TreeReference.INDEX_TEMPLATE)
		return null;

	if (instanceNode.getValue() != null) {
		Object serializedAnswer = serializer.serializeAnswerData(
				instanceNode.getValue(), instanceNode.getDataType());

		if (serializedAnswer instanceof Element) {
			// DON"T handle this.
			throw new RuntimeException("Can't handle serialized output for"
					+ instanceNode.getValue().toString() + ", "
					+ serializedAnswer);
		} else if (serializedAnswer instanceof String) {
			Element e = new Element();
			e.addChild(Node.TEXT, (String) serializedAnswer);

			String tag = instanceNode.getAttributeValue("", "tag");
			if ( tag != null ) {
				b.append(tag);
			}
			else {
				String name = instanceNode.getName();
				if ( name != null ) {
					b.append(name);
				}
			}
			b.append(delimiter);

			for (int k = 0; k < e.getChildCount(); k++) {
				b.append(e.getChild(k).toString().replace("\\", "\\\\").replace(delimiter, "\\" + delimiter));
				b.append(delimiter);
			}

		} else {
			throw new RuntimeException("Can't handle serialized output for"
					+ instanceNode.getValue().toString() + ", "
					+ serializedAnswer);
		}

		if (serializer.containsExternalData(instanceNode.getValue())
				.booleanValue()) {
			IDataPointer[] pointer = serializer
					.retrieveExternalDataPointer(instanceNode.getValue());
			for (int i = 0; i < pointer.length; ++i) {
				dataPointers.add(pointer[i]);
			}
		}
	}
	return b.toString();
}
 
开发者ID:medic,项目名称:javarosa,代码行数:55,代码来源:SMSSerializingVisitor.java

示例6: saveProperty

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private void saveProperty (String propName, TreeElement node) {
	IAnswerData answer = node.getValue();
	String value = (answer == null ? null : answer.getDisplayText());
	if (propName != null && propName.length() > 0 && value != null && value.length() > 0)
		PropertyManager._().setProperty(propName, value);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:7,代码来源:QuestionPreloader.java


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