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


Java TreeElement.getDataType方法代码示例

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


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

示例1: applyControlProperties

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private void applyControlProperties (FormInstance instance) {
	for (int h = 0; h < 2; h++) {
        List<TreeReference> selectRefs = (h == 0 ? selectOnes : selectMultis);
		int type = (h == 0 ? Constants.DATATYPE_CHOICE : Constants.DATATYPE_CHOICE_LIST);

		for (int i = 0; i < selectRefs.size(); i++) {
			TreeReference ref = selectRefs.get(i);
           List<TreeReference> nodes = new EvaluationContext(instance).expandReference(ref, true);
			for (int j = 0; j < nodes.size(); j++) {
				TreeElement node = instance.resolveReference(nodes.get(j));
				if (node.getDataType() == Constants.DATATYPE_CHOICE || node.getDataType() == Constants.DATATYPE_CHOICE_LIST) {
					//do nothing
				} else if (node.getDataType() == Constants.DATATYPE_NULL || node.getDataType() == Constants.DATATYPE_TEXT) {
					node.setDataType(type);
				} else {
					reporter.warning(XFormParserReporter.TYPE_INVALID_STRUCTURE,
							"Select question " + ref.toString() + " appears to have data type that is incompatible with selection", null);
				}
			}
		}
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:XFormParser.java

示例2: listQuestion

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private static void listQuestion (FormDef f, QuestionDef q,FormEntryController fec, int indent, StringBuilder sb) {
	FormEntryModel femodel = fec.getModel();
	TreeElement instanceNode = getInstanceNode(f.getInstance(), q.getBind());
	String caption = "";
	FormEntryPrompt fep = femodel.getQuestionPrompt();
	caption = fep.getLongText();

	int type = instanceNode.getDataType();

	if (q.getControlType() != Constants.CONTROL_TRIGGER) {
		println(sb, indent, "Question: \"" + caption + "\"");
		println(sb, indent + 1, "Type: " + printType(type));
	} else {
		println(sb, indent, "Info: \"" + caption + "\"");
	}

	if (q.getControlType() == Constants.CONTROL_SELECT_ONE || q.getControlType() == Constants.CONTROL_SELECT_MULTI) {
		printChoices(f,q,fec, indent + 1, sb);
	}

	printProperty("relevant", f, instanceNode, indent + 1, sb);

	printProperty("required", f, instanceNode, indent + 1, sb);

	printProperty("readonly", f, instanceNode, indent + 1, sb);

	String defaultValue = printDefault(instanceNode);
	if (defaultValue != null) {
		println(sb, indent + 1, "Default: " + defaultValue);
	}

	if (instanceNode.getConstraint() != null) {
		println(sb, indent + 1, "Constraint: " + printCondition(instanceNode.getConstraint().constraint));
	}

	println(sb);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:38,代码来源:FormOverview.java

示例3: createBugRuntimeException

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private RuntimeException createBugRuntimeException(TreeElement treeElement, String textVal) {
    return new RuntimeException("The appearance column of the field " + treeElement.getName() + " contains a search() call and the field type is " + treeElement.getDataType() + " and the saved answer is " + textVal);
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:4,代码来源:ExternalAnswerResolver.java

示例4: schemizeInstance

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private static Element schemizeInstance (TreeElement node) {
	String name = node.getName();
	boolean terminal = node.isLeaf();
	boolean repeatable = node.isRepeatable();

	if (repeatable && node.getMult() != TreeReference.INDEX_TEMPLATE) {
		return null;
	}

	Element e = new Element();
	e.setName("element");
	e.setAttribute(null, "name", name);
	e.setAttribute(null, "minOccurs", "0"); //technically only needed if node has a 'relevant' attribute bound to it, but no easy way to tell
	if (repeatable) {
		e.setAttribute(null, "maxOccurs", "unbounded");
	}

	if (!terminal) {
		Element ct = new Element();
		ct.setName("complexType");
		e.addChild(Node.ELEMENT, ct);

		Element seq = new Element();
		seq.setName("sequence");
		ct.addChild(Node.ELEMENT, seq);

		for (int i = 0; i < node.getNumChildren(); i++) {
			Element child = schemizeInstance((TreeElement)node.getChildAt(i));
			if (child != null) {
				seq.addChild(Node.ELEMENT, child);
			}
		}
	} else {
		String type;

		switch (node.getDataType()) {
		case Constants.DATATYPE_NULL:
		case Constants.DATATYPE_TEXT:
			type = "string";
			break;
		case Constants.DATATYPE_INTEGER: type = "integer"; break;
		case Constants.DATATYPE_LONG: type = "long"; break;
		case Constants.DATATYPE_DECIMAL: type = "decimal"; break;
		case Constants.DATATYPE_BOOLEAN: type = "boolean"; break;
		case Constants.DATATYPE_DATE: type = "date"; break;
		case Constants.DATATYPE_DATE_TIME: type = "dateTime"; break;
		case Constants.DATATYPE_TIME: type = "time"; break;
		case Constants.DATATYPE_CHOICE:
		case Constants.DATATYPE_CHOICE_LIST:
			type = (String)choiceTypeMapping.get(node);
			if (type == null) {
				System.err.println("can't find choices for select-type question [" + node.getName() + "]");
			}
			break;
		case Constants.DATATYPE_GEOPOINT: type = "jr:geopoint"; break;
		case Constants.DATATYPE_GEOSHAPE: type = "jr:geoshape"; break;
		case Constants.DATATYPE_GEOTRACE: type = "jr:geotrace"; break;
		default:
			type = null;
			System.err.println("unrecognized type [" + node.getDataType() + ";" + node.getName() + "]");
			break;
		}

		if (type != null) {
			e.setAttribute(null, "type", type);
		}
	}

	return e;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:71,代码来源:InstanceSchema.java

示例5: apply

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public void apply (TreeReference ref, Object result, FormInstance mainInstance) {
	TreeElement element = mainInstance.resolveReference(ref);
	int dataType = element.getDataType();
	element.setAnswer(wrapData(result, dataType));
}
 
开发者ID:medic,项目名称:javarosa,代码行数:6,代码来源:Recalculate.java


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