本文整理汇总了Java中org.javarosa.core.model.IFormElement.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java IFormElement.getChildren方法的具体用法?Java IFormElement.getChildren怎么用?Java IFormElement.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.IFormElement
的用法示例。
在下文中一共展示了IFormElement.getChildren方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containsRepeatGuesses
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
/**
* This method does a recursive check of whether there are any repeat guesses
* in the element or its subtree. This is a necessary step when initializing
* the model to be able to identify whether new repeats can be used.
*
* @param parent The form element to begin checking
* @return true if the element or any of its descendants is a repeat
* which has a count guess, false otherwise.
*/
private boolean containsRepeatGuesses(IFormElement parent) {
if(parent instanceof GroupDef) {
GroupDef g = (GroupDef)parent;
if (g.getRepeat() && g.getCountReference() != null) {
return true;
}
}
List<IFormElement> children = parent.getChildren();
if(children == null) { return false; }
for (IFormElement child : children) {
if(containsRepeatGuesses(child)) {return true;}
}
return false;
}
示例2: containsRepeatGuesses
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
/**
* This method does a recursive check of whether there are any repeat guesses
* in the element or its subtree. This is a necessary step when initializing
* the model to be able to identify whether new repeats can be used.
*
* @param parent The form element to begin checking
* @return true if the element or any of its descendants is a repeat
* which has a count guess, false otherwise.
*/
private boolean containsRepeatGuesses(IFormElement parent) {
if (parent instanceof GroupDef) {
GroupDef g = (GroupDef)parent;
if (g.getRepeat() && g.getCountReference() != null) {
return true;
}
}
Vector<IFormElement> children = parent.getChildren();
if (children == null) {
return false;
}
for (Enumeration en = children.elements(); en.hasMoreElements(); ) {
if (containsRepeatGuesses((IFormElement)en.nextElement())) {
return true;
}
}
return false;
}
示例3: containsRepeatGuesses
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
/**
* This method does a recursive check of whether there are any repeat guesses
* in the element or its subtree. This is a necessary step when initializing
* the model to be able to identify whether new repeats can be used.
*
* @param parent The form element to begin checking
* @return true if the element or any of its descendants is a repeat
* which has a count guess, false otherwise.
*/
private boolean containsRepeatGuesses(IFormElement parent) {
if (parent instanceof GroupDef) {
GroupDef g = (GroupDef)parent;
if (g.isRepeat() && g.getCountReference() != null) {
return true;
}
}
Vector<IFormElement> children = parent.getChildren();
if (children == null) {
return false;
}
for (Enumeration en = children.elements(); en.hasMoreElements(); ) {
if (containsRepeatGuesses((IFormElement)en.nextElement())) {
return true;
}
}
return false;
}
示例4: verifyControlBindings
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
private void verifyControlBindings (IFormElement fe, FormInstance instance, List<String> errors) { //throws XmlPullParserException {
if (fe.getChildren() == null)
return;
for (int i = 0; i < fe.getChildren().size(); i++) {
IFormElement child = fe.getChildren().get(i);
IDataReference ref = null;
String type = null;
if (child instanceof GroupDef) {
ref = ((GroupDef)child).getBind();
type = (((GroupDef)child).getRepeat() ? "Repeat" : "Group");
} else if (child instanceof QuestionDef) {
ref = ((QuestionDef)child).getBind();
type = "Question";
}
TreeReference tref = FormInstance.unpackReference(ref);
if (child instanceof QuestionDef && tref.size() == 0) {
//group can bind to '/'; repeat can't, but that's checked above
reporter.warning(XFormParserReporter.TYPE_INVALID_STRUCTURE, "Cannot bind control to '/'",null);
} else {
List<TreeReference> nodes = new EvaluationContext(instance).expandReference(tref, true);
if (nodes.size() == 0) {
String error = type+ " bound to non-existent node: [" + tref.toString() + "]";
reporter.error(error);
errors.add(error);
}
//we can't check whether questions map to the right kind of node ('data' node vs. 'sub-tree' node) as that depends
//on the question's data type, which we don't know yet
}
verifyControlBindings(child, instance, errors);
}
}
示例5: verifyControlBindings
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
private void verifyControlBindings(IFormElement fe, FormInstance instance, Vector<String> errors) { //throws XmlPullParserException {
if (fe.getChildren() == null)
return;
for (int i = 0; i < fe.getChildren().size(); i++) {
IFormElement child = fe.getChildren().elementAt(i);
XPathReference ref = null;
String type = null;
if (child instanceof GroupDef) {
ref = child.getBind();
type = (((GroupDef)child).getRepeat() ? "Repeat" : "Group");
} else if (child instanceof QuestionDef) {
ref = child.getBind();
type = "Question";
}
TreeReference tref = FormInstance.unpackReference(ref);
if (child instanceof QuestionDef && tref.size() == 0) {
//group can bind to '/'; repeat can't, but that's checked above
reporter.warning(XFormParserReporter.TYPE_INVALID_STRUCTURE, "Cannot bind control to '/'", null);
} else {
Vector<TreeReference> nodes = new EvaluationContext(instance).expandReference(tref, true);
if (nodes.size() == 0) {
String error = type + " bound to non-existent node: [" + tref.toString() + "]";
reporter.error(error);
errors.addElement(error);
}
//we can't check whether questions map to the right kind of node ('data' node vs. 'sub-tree' node) as that depends
//on the question's data type, which we don't know yet
}
verifyControlBindings(child, instance, errors);
}
}
示例6: verifyControlBindings
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
private void verifyControlBindings(IFormElement fe, FormInstance instance, Vector<String> errors) { //throws XmlPullParserException {
if (fe.getChildren() == null)
return;
for (int i = 0; i < fe.getChildren().size(); i++) {
IFormElement child = fe.getChildren().elementAt(i);
XPathReference ref = null;
String type = null;
if (child instanceof GroupDef) {
ref = child.getBind();
type = (((GroupDef)child).isRepeat() ? "Repeat" : "Group");
} else if (child instanceof QuestionDef) {
ref = child.getBind();
type = "Question";
}
TreeReference tref = FormInstance.unpackReference(ref);
if (child instanceof QuestionDef && tref.size() == 0) {
//group can bind to '/'; repeat can't, but that's checked above
reporter.warning(XFormParserReporter.TYPE_INVALID_STRUCTURE, "Cannot bind control to '/'", null);
} else {
Vector<TreeReference> nodes = new EvaluationContext(instance).expandReference(tref, true);
if (nodes.size() == 0) {
String error = type + " bound to non-existent node: [" + tref.toString() + "]";
reporter.error(error);
errors.addElement(error);
}
//we can't check whether questions map to the right kind of node ('data' node vs. 'sub-tree' node) as that depends
//on the question's data type, which we don't know yet
}
verifyControlBindings(child, instance, errors);
}
}
示例7: decrementHelper
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
private void decrementHelper(List<Integer> indexes, List<Integer> multiplicities, List<IFormElement> elements) {
int i = indexes.size() - 1;
if (i != -1) {
int curIndex = indexes.get(i).intValue();
int curMult = multiplicities.get(i).intValue();
if (repeatStructure == REPEAT_STRUCTURE_NON_LINEAR &&
elements.get(elements.size() - 1) instanceof GroupDef && ((GroupDef)elements.get(elements.size() - 1)).getRepeat() &&
multiplicities.get(multiplicities.size() - 1).intValue() != TreeReference.INDEX_REPEAT_JUNCTURE) {
multiplicities.set(i, Integer.valueOf(TreeReference.INDEX_REPEAT_JUNCTURE));
return;
} else if (repeatStructure != REPEAT_STRUCTURE_NON_LINEAR && curMult > 0) {
multiplicities.set(i, Integer.valueOf(curMult - 1));
} else if (curIndex > 0) {
// set node to previous element
indexes.set(i, Integer.valueOf(curIndex - 1));
multiplicities.set(i, Integer.valueOf(0));
elements.set(i, (i == 0 ? form : elements.get(i - 1)).getChild(curIndex - 1));
if (setRepeatNextMultiplicity(elements, multiplicities))
return;
} else {
// at absolute beginning of current level; index to parent
indexes.remove(i);
multiplicities.remove(i);
elements.remove(i);
return;
}
}
IFormElement element = (i < 0 ? form : elements.get(i));
while (!(element instanceof QuestionDef)) {
if(element.getChildren() == null || element.getChildren().size() == 0) {
//if there are no children we just return the current index (the group itself)
return;
}
int subIndex = element.getChildren().size() - 1;
element = element.getChild(subIndex);
indexes.add(Integer.valueOf(subIndex));
multiplicities.add(Integer.valueOf(0));
elements.add(element);
if (setRepeatNextMultiplicity(elements, multiplicities))
return;
}
}
示例8: verifyRepeatMemberBindings
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
private void verifyRepeatMemberBindings (IFormElement fe, FormInstance instance, GroupDef parentRepeat) {
if (fe.getChildren() == null)
return;
for (int i = 0; i < fe.getChildren().size(); i++) {
IFormElement child = fe.getChildren().get(i);
boolean isRepeat = (child instanceof GroupDef && ((GroupDef)child).getRepeat());
//get bindings of current node and nearest enclosing repeat
TreeReference repeatBind = (parentRepeat == null ? TreeReference.rootRef() : FormInstance.unpackReference(parentRepeat.getBind()));
TreeReference childBind = FormInstance.unpackReference(child.getBind());
//check if current binding is within scope of repeat binding
if (!repeatBind.isParentOf(childBind, false)) {
//catch <repeat nodeset="/a/b"><input ref="/a/c" /></repeat>: repeat question is not a child of the repeated node
throw new XFormParseException("<repeat> member's binding [" + childBind.toString() + "] is not a descendant of <repeat> binding [" + repeatBind.toString() + "]!");
} else if (repeatBind.equals(childBind) && isRepeat) {
//catch <repeat nodeset="/a/b"><repeat nodeset="/a/b">...</repeat></repeat> (<repeat nodeset="/a/b"><input ref="/a/b" /></repeat> is ok)
throw new XFormParseException("child <repeat>s [" + childBind.toString() + "] cannot bind to the same node as their parent <repeat>; only questions/groups can");
}
//check that, in the instance, current node is not within the scope of any closer repeat binding
//build a list of all the node's instance ancestors
List<TreeElement> repeatAncestry = new ArrayList<TreeElement>();
TreeElement repeatNode = (repeatTree == null ? null : repeatTree.getRoot());
if (repeatNode != null) {
repeatAncestry.add(repeatNode);
for (int j = 1; j < childBind.size(); j++) {
repeatNode = repeatNode.getChild(childBind.getName(j), 0);
if (repeatNode != null) {
repeatAncestry.add(repeatNode);
} else {
break;
}
}
}
//check that no nodes between the parent repeat and the target are repeatable
for (int k = repeatBind.size(); k < childBind.size(); k++) {
TreeElement rChild = (k < repeatAncestry.size() ? repeatAncestry.get(k) : null);
boolean repeatable = (rChild == null ? false : rChild.isRepeatable());
if (repeatable && !(k == childBind.size() - 1 && isRepeat)) {
//catch <repeat nodeset="/a/b"><input ref="/a/b/c/d" /></repeat>...<repeat nodeset="/a/b/c">...</repeat>:
// question's/group's/repeat's most immediate repeat parent in the instance is not its most immediate repeat parent in the form def
throw new XFormParseException("<repeat> member's binding [" + childBind.toString() + "] is within the scope of a <repeat> that is not its closest containing <repeat>!");
}
}
verifyRepeatMemberBindings(child, instance, (isRepeat ? (GroupDef)child : parentRepeat));
}
}
示例9: verifyRepeatMemberBindings
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
private void verifyRepeatMemberBindings(IFormElement fe, FormInstance instance, GroupDef parentRepeat) {
if (fe.getChildren() == null)
return;
for (int i = 0; i < fe.getChildren().size(); i++) {
IFormElement child = fe.getChildren().elementAt(i);
boolean isRepeat = (child instanceof GroupDef && ((GroupDef)child).getRepeat());
//get bindings of current node and nearest enclosing repeat
TreeReference repeatBind = (parentRepeat == null ? TreeReference.rootRef() : FormInstance.unpackReference(parentRepeat.getBind()));
TreeReference childBind = FormInstance.unpackReference(child.getBind());
//check if current binding is within scope of repeat binding
if (!repeatBind.isParentOf(childBind, false)) {
//catch <repeat nodeset="/a/b"><input ref="/a/c" /></repeat>: repeat question is not a child of the repeated node
throw new XFormParseException("<repeat> member's binding [" + childBind.toString() + "] is not a descendant of <repeat> binding [" + repeatBind.toString() + "]!");
} else if (repeatBind.equals(childBind) && isRepeat) {
//catch <repeat nodeset="/a/b"><repeat nodeset="/a/b">...</repeat></repeat> (<repeat nodeset="/a/b"><input ref="/a/b" /></repeat> is ok)
throw new XFormParseException("child <repeat>s [" + childBind.toString() + "] cannot bind to the same node as their parent <repeat>; only questions/groups can");
}
//check that, in the instance, current node is not within the scope of any closer repeat binding
//build a list of all the node's instance ancestors
Vector<TreeElement> repeatAncestry = new Vector<TreeElement>();
TreeElement repeatNode = (repeatTree == null ? null : repeatTree.getRoot());
if (repeatNode != null) {
repeatAncestry.addElement(repeatNode);
for (int j = 1; j < childBind.size(); j++) {
repeatNode = repeatNode.getChild(childBind.getName(j), 0);
if (repeatNode != null) {
repeatAncestry.addElement(repeatNode);
} else {
break;
}
}
}
//check that no nodes between the parent repeat and the target are repeatable
for (int k = repeatBind.size(); k < childBind.size(); k++) {
TreeElement rChild = (k < repeatAncestry.size() ? repeatAncestry.elementAt(k) : null);
boolean repeatable = (rChild != null && rChild.isRepeatable());
if (repeatable && !(k == childBind.size() - 1 && isRepeat)) {
//catch <repeat nodeset="/a/b"><input ref="/a/b/c/d" /></repeat>...<repeat nodeset="/a/b/c">...</repeat>:
// question's/group's/repeat's most immediate repeat parent in the instance is not its most immediate repeat parent in the form def
throw new XFormParseException("<repeat> member's binding [" + childBind.toString() + "] is within the scope of a <repeat> that is not its closest containing <repeat>!");
}
}
verifyRepeatMemberBindings(child, instance, (isRepeat ? (GroupDef)child : parentRepeat));
}
}
示例10: verifyRepeatMemberBindings
import org.javarosa.core.model.IFormElement; //导入方法依赖的package包/类
private void verifyRepeatMemberBindings(IFormElement fe, FormInstance instance, GroupDef parentRepeat) {
if (fe.getChildren() == null)
return;
for (int i = 0; i < fe.getChildren().size(); i++) {
IFormElement child = fe.getChildren().elementAt(i);
boolean isRepeat = (child instanceof GroupDef && ((GroupDef)child).isRepeat());
//get bindings of current node and nearest enclosing repeat
TreeReference repeatBind = (parentRepeat == null ? TreeReference.rootRef() : FormInstance.unpackReference(parentRepeat.getBind()));
TreeReference childBind = FormInstance.unpackReference(child.getBind());
//check if current binding is within scope of repeat binding
if (!repeatBind.isParentOf(childBind, false)) {
//catch <repeat nodeset="/a/b"><input ref="/a/c" /></repeat>: repeat question is not a child of the repeated node
throw new XFormParseException("<repeat> member's binding [" + childBind.toString() + "] is not a descendant of <repeat> binding [" + repeatBind.toString() + "]!");
} else if (repeatBind.equals(childBind) && isRepeat) {
//catch <repeat nodeset="/a/b"><repeat nodeset="/a/b">...</repeat></repeat> (<repeat nodeset="/a/b"><input ref="/a/b" /></repeat> is ok)
throw new XFormParseException("child <repeat>s [" + childBind.toString() + "] cannot bind to the same node as their parent <repeat>; only questions/groups can");
}
//check that, in the instance, current node is not within the scope of any closer repeat binding
//build a list of all the node's instance ancestors
Vector<TreeElement> repeatAncestry = new Vector<>();
TreeElement repeatNode = (repeatTree == null ? null : repeatTree.getRoot());
if (repeatNode != null) {
repeatAncestry.addElement(repeatNode);
for (int j = 1; j < childBind.size(); j++) {
repeatNode = repeatNode.getChild(childBind.getName(j), 0);
if (repeatNode != null) {
repeatAncestry.addElement(repeatNode);
} else {
break;
}
}
}
//check that no nodes between the parent repeat and the target are repeatable
for (int k = repeatBind.size(); k < childBind.size(); k++) {
TreeElement rChild = (k < repeatAncestry.size() ? repeatAncestry.elementAt(k) : null);
boolean repeatable = (rChild != null && rChild.isRepeatable());
if (repeatable && !(k == childBind.size() - 1 && isRepeat)) {
//catch <repeat nodeset="/a/b"><input ref="/a/b/c/d" /></repeat>...<repeat nodeset="/a/b/c">...</repeat>:
// question's/group's/repeat's most immediate repeat parent in the instance is not its most immediate repeat parent in the form def
throw new XFormParseException("<repeat> member's binding [" + childBind.toString() + "] is within the scope of a <repeat> that is not its closest containing <repeat>!");
}
}
verifyRepeatMemberBindings(child, instance, (isRepeat ? (GroupDef)child : parentRepeat));
}
}