本文整理汇总了Java中org.javarosa.core.model.instance.TreeElement.getNumChildren方法的典型用法代码示例。如果您正苦于以下问题:Java TreeElement.getNumChildren方法的具体用法?Java TreeElement.getNumChildren怎么用?Java TreeElement.getNumChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.instance.TreeElement
的用法示例。
在下文中一共展示了TreeElement.getNumChildren方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateChildrenTriggerables
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private void evaluateChildrenTriggerables(FormInstance mainInstance,
EvaluationContext evalContext, TreeElement newNode,
boolean createdOrDeleted, boolean midSurvey,
Set<QuickTriggerable> alreadyEvaluated) {
// iterate into the group children and evaluate any triggerables that
// depend one them, if they are not already calculated.
int numChildren = newNode.getNumChildren();
for (int i = 0; i < numChildren; i++) {
TreeReference anchorRef = newNode.getChildAt(i).getRef();
Set<QuickTriggerable> childTriggerables = triggerTriggerables(
mainInstance, evalContext, anchorRef,
midSurvey, alreadyEvaluated);
publishSummary((createdOrDeleted ? "Created" : "Deleted"),
anchorRef, childTriggerables);
}
}
示例2: addChildrenOfReference
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
/**
* This is a utility method to get all of the references of a node. It can
* be replaced when we support dependent XPath Steps (IE: /path/to//)
*/
public void addChildrenOfReference(FormInstance mainInstance,
EvaluationContext evalContext, TreeReference original,
Set<TreeReference> toAdd, boolean expandRepeatables) {
// original has already been added to the 'toAdd' list.
TreeElement repeatTemplate = expandRepeatables ? mainInstance
.getTemplatePath(original) : null;
if (repeatTemplate != null) {
for (int i = 0; i < repeatTemplate.getNumChildren(); ++i) {
TreeElement child = repeatTemplate.getChildAt(i);
toAdd.add(child.getRef().genericize());
addChildrenOfElement(mainInstance, evalContext, child, toAdd, expandRepeatables);
}
} else {
List<TreeReference> refSet = evalContext
.expandReference(original);
for (TreeReference ref : refSet) {
addChildrenOfElement(mainInstance, evalContext, evalContext.resolveReference(ref),
toAdd, expandRepeatables);
}
}
}
示例3: addChildrenOfReference
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
/**
* This is a utility method to get all of the references of a node. It can
* be replaced when we support dependent XPath Steps (IE: /path/to//)
*/
private void addChildrenOfReference(FormInstance mainInstance,
EvaluationContext evalContext, TreeReference original,
Set<TreeReference> toAdd, boolean expandRepeatables) {
// original has already been added to the 'toAdd' list.
TreeElement repeatTemplate = expandRepeatables ? mainInstance
.getTemplatePath(original) : null;
if (repeatTemplate != null) {
for (int i = 0; i < repeatTemplate.getNumChildren(); ++i) {
TreeElement child = repeatTemplate.getChildAt(i);
toAdd.add(child.getRef().genericize());
addChildrenOfElement(mainInstance, evalContext, child, toAdd,
expandRepeatables);
}
} else {
List<TreeReference> refSet = evalContext.expandReference(original);
for (TreeReference ref : refSet) {
addChildrenOfElement(mainInstance, evalContext,
evalContext.resolveReference(ref), toAdd,
expandRepeatables);
}
}
}
示例4: checkRepeatsForTemplate
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private static void checkRepeatsForTemplate (TreeElement repeatTreeNode, TreeReference ref, FormInstance instance, List<TreeReference> missing) {
String name = repeatTreeNode.getName();
int mult = (repeatTreeNode.isRepeatable() ? TreeReference.INDEX_TEMPLATE : 0);
ref = ref.extendRef(name, mult);
if (repeatTreeNode.isRepeatable()) {
TreeElement template = instance.resolveReference(ref);
if (template == null) {
missing.add(ref);
}
}
for (int i = 0; i < repeatTreeNode.getNumChildren(); i++) {
checkRepeatsForTemplate(repeatTreeNode.getChildAt(i), ref, instance, missing);
}
}
示例5: findDepthFirst
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
/**
* Traverse the submission looking for the first matching tag in depth-first order.
*
* @param parent
* @param name
* @return
*/
private TreeElement findDepthFirst(TreeElement parent, String name) {
int len = parent.getNumChildren();
for ( int i = 0; i < len ; ++i ) {
TreeElement e = parent.getChildAt(i);
if ( name.equals(e.getName()) ) {
return e;
} else if ( e.getNumChildren() != 0 ) {
TreeElement v = findDepthFirst(e, name);
if ( v != null ) return v;
}
}
return null;
}
示例6: findDepthFirst
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
/**
* Traverse the submission looking for the first matching tag in depth-first
* order.
*
* @param parent
* @param name
* @return
*/
private TreeElement findDepthFirst(TreeElement parent, String name) {
int len = parent.getNumChildren();
for (int i = 0; i < len; ++i) {
TreeElement e = parent.getChildAt(i);
if (name.equals(e.getName())) {
return e;
} else if (e.getNumChildren() != 0) {
TreeElement v = findDepthFirst(e, name);
if (v != null)
return v;
}
}
return null;
}
示例7: 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);
}
}
}
示例8: 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()));
}
}
示例9: addChildrenOfElement
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private void addChildrenOfElement(TreeElement el, ArrayList<TreeReference> toAdd) {
for (int i = 0; i < el.getNumChildren(); ++i) {
TreeElement child = el.getChildAt(i);
toAdd.add(child.getRef().genericize());
addChildrenOfElement(child, toAdd);
}
}
示例10: evaluateChildrenTriggerables
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private void evaluateChildrenTriggerables(FormInstance mainInstance,
EvaluationContext evalContext, TreeElement newNode,
boolean createdOrDeleted, Set<QuickTriggerable> alreadyEvaluated) {
// iterate into the group children and evaluate any triggerables that
// depend one them, if they are not already calculated.
int numChildren = newNode.getNumChildren();
for (int i = 0; i < numChildren; i++) {
TreeReference anchorRef = newNode.getChildAt(i).getRef();
Set<QuickTriggerable> childTriggerables = triggerTriggerables(
mainInstance, evalContext, anchorRef, alreadyEvaluated);
publishSummary((createdOrDeleted ? "Created" : "Deleted"),
anchorRef, childTriggerables);
}
}
示例11: removeInvalidTemplates
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private boolean removeInvalidTemplates (TreeElement instanceNode, TreeElement repeatTreeNode, boolean templateAllowed) {
int mult = instanceNode.getMult();
boolean repeatable = (repeatTreeNode == null ? false : repeatTreeNode.isRepeatable());
if (mult == TreeReference.INDEX_TEMPLATE) {
if (!templateAllowed) {
reporter.warning(XFormParserReporter.TYPE_INVALID_STRUCTURE, "Template nodes for sub-repeats must be located within the template node of the parent repeat; ignoring template... [" + instanceNode.getName() + "]", null);
return true;
} else if (!repeatable) {
reporter.warning(XFormParserReporter.TYPE_INVALID_STRUCTURE, "Warning: template node found for ref that is not repeatable; ignoring... [" + instanceNode.getName() + "]", null);
return true;
}
}
if (repeatable && mult != TreeReference.INDEX_TEMPLATE)
templateAllowed = false;
for (int i = 0; i < instanceNode.getNumChildren(); i++) {
TreeElement child = instanceNode.getChildAt(i);
TreeElement rchild = (repeatTreeNode == null ? null : repeatTreeNode.getChild(child.getName(), 0));
if (removeInvalidTemplates(child, rchild, templateAllowed)) {
instanceNode.removeChildAt(i);
i--;
}
}
return false;
}
示例12: trimRepeatChildren
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private static void trimRepeatChildren (TreeElement node) {
for (int i = 0; i < node.getNumChildren(); i++) {
TreeElement child = node.getChildAt(i);
if (child.isRepeatable()) {
node.removeChildAt(i);
i--;
} else {
trimRepeatChildren(child);
}
}
}
示例13: checkDuplicateNodesAreRepeatable
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
private static void checkDuplicateNodesAreRepeatable (TreeElement node) {
int mult = node.getMult();
if (mult > 0) { //repeated node
if (!node.isRepeatable()) {
System.out.println("Warning: repeated nodes [" + node.getName() + "] detected that have no repeat binding in the form; DO NOT bind questions to these nodes or their children!");
//we could do a more comprehensive safety check in the future
}
}
for (int i = 0; i < node.getNumChildren(); i++) {
checkDuplicateNodesAreRepeatable(node.getChildAt(i));
}
}
示例14: 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;
}