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


Java TreeElement.isLeaf方法代码示例

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


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

示例1: serializeTree

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public void serializeTree(TreeElement root) {
	for (int j = 0; j < root.getNumChildren(); j++) {
		TreeElement tee = root.getChildAt(j);
		if (tee.isLeaf()) {
			String e = serializeNode(tee);
			if(e != null) {
				theSmsStr += e;
			}
		}
		else {
			serializeTree(tee);
		}
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:15,代码来源:SMSSerializingVisitor.java

示例2: writeTreeElement

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
/**
 * recursively write out a node of the instance
 * @param out
 * @param e
 * @param ref
 * @throws IOException
 */
private void writeTreeElement (DataOutputStream out, TreeElement e) throws IOException {
	TreeElement templ = instance.getTemplatePath(e.getRef());
	boolean isGroup = !templ.isLeaf();

	if (isGroup) {
	   List<String> childTypesHandled = new ArrayList<String>(templ.getNumChildren());
		for (int i = 0; i < templ.getNumChildren(); i++) {
			String childName = templ.getChildAt(i).getName();
			if (!childTypesHandled.contains(childName)) {
				childTypesHandled.add(childName);

				int mult = e.getChildMultiplicity(childName);
				if (mult > 0 && !e.getChild(childName, 0).isRelevant()) {
					mult = 0;
				}

				ExtUtil.writeNumeric(out, mult);
				for (int j = 0; j < mult; j++) {
					writeTreeElement(out, e.getChild(childName, j));
				}
			}
		}
	} else {
		ExtUtil.write(out, new ExtWrapAnswerData(e.getDataType(), e.getValue()));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:34,代码来源:CompactInstanceWrapper.java

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


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