本文整理汇总了Java中org.javarosa.core.model.instance.TreeElement.getChildAt方法的典型用法代码示例。如果您正苦于以下问题:Java TreeElement.getChildAt方法的具体用法?Java TreeElement.getChildAt怎么用?Java TreeElement.getChildAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.instance.TreeElement
的用法示例。
在下文中一共展示了TreeElement.getChildAt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例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//)
*/
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);
}
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
}
}
示例6: 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);
}
}
示例7: 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;
}
示例8: 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);
}
}
}