本文整理汇总了Java中org.javarosa.core.model.instance.FormInstance.getRoot方法的典型用法代码示例。如果您正苦于以下问题:Java FormInstance.getRoot方法的具体用法?Java FormInstance.getRoot怎么用?Java FormInstance.getRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.instance.FormInstance
的用法示例。
在下文中一共展示了FormInstance.getRoot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public void visit(FormInstance tree) {
theXmlDoc = new Document();
//TreeElement root = tree.getRoot();
TreeElement root = tree.resolveReference(rootRef);
//For some reason resolveReference won't ever return the root, so we'll
//catch that case and just start at the root.
if(root == null) {
root = tree.getRoot();
}
if (root != null) {
theXmlDoc.addChild(Node.ELEMENT, serializeNode(root));
}
Element top = theXmlDoc.getElement(0);
String[] prefixes = tree.getNamespacePrefixes();
for(int i = 0 ; i < prefixes.length; ++i ) {
top.setPrefix(prefixes[i], tree.getNamespaceURI(prefixes[i]));
}
if (tree.schema != null) {
top.setNamespace(tree.schema);
top.setPrefix("", tree.schema);
}
}
示例2: visit
import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public void visit(FormInstance tree) {
nodeSet = new String();
TreeElement root = tree.getRoot();
// TreeElement root = tree.resolveReference(rootRef);
instanceID = root.getAttributeValue("", "id");
xmlns = root.getAttributeValue("", "xmlns");
delimiter = root.getAttributeValue("", "delimiter");
if ( delimiter == null ) {
// for the spelling-impaired...
delimiter = root.getAttributeValue("", "delimeter");
}
prefix = root.getAttributeValue("", "prefix");
instanceID = (instanceID != null)? instanceID : "unknown";
xmlns = (xmlns != null)? xmlns : " ";
delimiter = (delimiter != null ) ? delimiter : "#";
prefix = (prefix != null) ? prefix : "J1!"+instanceID+"!";
//Don't bother adding any delimiters, yet. Delimiters are
//added before tags/data
theSmsStr = prefix;
// serialize each node (and it's children) to get it's answers
serializeTree(root);
theSmsStr = theSmsStr.trim();
}
示例3: mergeDataModel
import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public static void mergeDataModel (FormInstance parent, FormInstance child, TreeReference parentRef) {
TreeElement parentNode = parent.resolveReference(parentRef);
//ugly
if (parentNode == null) {
parentRef = parent.addNode(parentRef);
parentNode = parent.resolveReference(parentRef);
}
TreeElement childNode = child.getRoot();
int mult = parentNode.getChildMultiplicity(childNode.getName());
childNode.setMult(mult);
parentNode.addChild(childNode);
}
示例4: eval
import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public XPathNodeset eval (FormInstance m, EvaluationContext ec) {
TreeReference genericRef = getReference();
TreeReference ref;
if(genericRef.getContext() == TreeReference.CONTEXT_ORIGINAL) {
ref = genericRef.contextualize(ec.getOriginalContext());
} else {
ref = genericRef.contextualize(ec.getContextRef());
}
//We don't necessarily know the model we want to be working with until we've contextualized the
//node
//check if this nodeset refers to a non-main instance
if(ref.getInstanceName() != null && ref.isAbsolute())
{
FormInstance nonMain = ec.getInstance(ref.getInstanceName());
if(nonMain != null)
{
m = nonMain;
}
else
{
throw new XPathMissingInstanceException(ref.getInstanceName(), "Instance referenced by " + ref.toString(true) + " does not exist");
}
} else {
//TODO: We should really stop passing 'm' around and start just getting the right instance from ec
//at a more central level
m = ec.getMainInstance();
if(m == null) {
String refStr = ref == null ? "" : ref.toString(true);
throw new XPathException("Cannot evaluate the reference [" + refStr + "] in the current evaluation context. No default instance has been declared!");
}
}
// regardless of the above, we want to ensure there is a definition
if(m.getRoot() == null) {
//This instance is _declared_, but doesn't actually have any data in it.
throw new XPathMissingInstanceException(ref.getInstanceName(), "Instance referenced by " + ref.toString(true) + " has not been loaded");
}
// this makes no sense...
// if (ref.isAbsolute() && m.getTemplatePath(ref) == null) {
// List<TreeReference> nodesetRefs = new List<TreeReference>();
// return new XPathNodeset(nodesetRefs, m, ec);
// }
List<TreeReference> nodesetRefs = ec.expandReference(ref);
//to fix conditions based on non-relevant data, filter the nodeset by relevancy
for (int i = 0; i < nodesetRefs.size(); i++) {
if (!m.resolveReference(nodesetRefs.get(i)).isRelevant()) {
nodesetRefs.remove(i);
i--;
}
}
return new XPathNodeset(nodesetRefs, m, ec);
}