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


Java FormInstance.unpackReference方法代码示例

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


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

示例1: XFormAnswerDataSerializer

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public IDataPayload createSerializedPayload	(FormInstance model, IDataReference ref) throws IOException {
	init();
	rootRef = FormInstance.unpackReference(ref);
	if(this.serializer == null) {
		this.setAnswerDataSerializer(new XFormAnswerDataSerializer());
	}
	model.accept(this);
	if(theXmlDoc != null) {
		//TODO: Did this strip necessary data?
		byte[] form = XFormSerializer.getUtfBytes(theXmlDoc);
		if(dataPointers.size() == 0) {
			return new ByteArrayPayload(form, null, IDataPayload.PAYLOAD_TYPE_XML);
		}
		MultiMessagePayload payload = new MultiMessagePayload();
		payload.addPayload(new ByteArrayPayload(form, "xml_submission_file", IDataPayload.PAYLOAD_TYPE_XML));
          for (IDataPointer pointer : dataPointers) {
			payload.addPayload(new DataPointerPayload(pointer));
		}
		return payload;
	}
	else {
		return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:XFormSerializingVisitor.java

示例2: applyInstanceProperties

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
private void applyInstanceProperties (FormInstance instance) {
	for (int i = 0; i < bindings.size(); i++) {
		DataBinding bind = bindings.get(i);
		TreeReference ref = FormInstance.unpackReference(bind.getReference());
        List<TreeReference> nodes = new EvaluationContext(instance).expandReference(ref, true);

		if (nodes.size() > 0) {
			attachBindGeneral(bind);
		}
		for (int j = 0; j < nodes.size(); j++) {
			TreeReference nref = nodes.get(j);
			attachBind(instance.resolveReference(nref), bind);
		}
	}

	applyControlProperties(instance);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:18,代码来源:XFormParser.java

示例3: attachBindGeneral

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
private static void attachBindGeneral (DataBinding bind) {
	TreeReference ref = FormInstance.unpackReference(bind.getReference());

	if (bind.relevancyCondition != null) {
		bind.relevancyCondition.addTarget(ref);
	}
	if (bind.requiredCondition != null) {
		bind.requiredCondition.addTarget(ref);
	}
	if (bind.readonlyCondition != null) {
		bind.readonlyCondition.addTarget(ref);
	}
	if (bind.calculate != null) {
		bind.calculate.addTarget(ref);
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:XFormParser.java

示例4: createModelIfNecessary

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
/**
 * For the current index: Checks whether the index represents a node which
 * should exist given a non-interactive repeat, along with a count for that
 * repeat which is beneath the dynamic level specified.
 *
 * If this index does represent such a node, the new model for the repeat is
 * created behind the scenes and the index for the initial question is
 * returned.
 *
 * Note: This method will not prevent the addition of new repeat elements in
 * the interface, it will merely use the xforms repeat hint to create new
 * nodes that are assumed to exist
 *
 * @param index The index to be evaluated as to whether the underlying model is
 *        hinted to exist
 */
private void createModelIfNecessary(FormIndex index) {
    if (index.isInForm()) {
        IFormElement e = getForm().getChild(index);
        if (e instanceof GroupDef) {
            GroupDef g = (GroupDef) e;
            if (g.getRepeat() && g.getCountReference() != null) {
            	// Lu Gram: repeat count XPath needs to be contextualized for nested repeat groups
            	TreeReference countRef = FormInstance.unpackReference(g.getCountReference());
            	TreeReference contextualized = countRef.contextualize(index.getReference());
                IAnswerData count = getForm().getMainInstance().resolveReference(contextualized).getValue();
                if (count != null) {
                    long fullcount = ((Integer) count.getValue()).intValue();
                    TreeReference ref = getForm().getChildInstanceRef(index);
                    TreeElement element = getForm().getMainInstance().resolveReference(ref);
                    if (element == null) {
                        if (index.getTerminal().getInstanceIndex() < fullcount) {

                          try {
                            getForm().createNewRepeat(index);
                          } catch (InvalidReferenceException ire) {
                            ire.printStackTrace();
                            throw new RuntimeException("Invalid Reference while creting new repeat!" + ire.getMessage());
                          }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:47,代码来源:FormEntryModel.java

示例5: serializeInstance

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public byte[] serializeInstance(FormInstance model, IDataReference ref) throws IOException {
	init();
	rootRef = FormInstance.unpackReference(ref);
	if(this.serializer == null) {
		this.setAnswerDataSerializer(new XFormAnswerDataSerializer());
	}

	model.accept(this);
	if(theXmlDoc != null) {
		return XFormSerializer.getUtfBytes(theXmlDoc);
	}
	else {
		return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:16,代码来源:XFormSerializingVisitor.java

示例6: registerModule

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public void registerModule() {
	String[] classes = {
			"org.javarosa.model.xform.XPathReference",
			"org.javarosa.xpath.XPathConditional"
	};
	
	PrototypeManager.registerPrototypes(classes);
	PrototypeManager.registerPrototypes(XPathParseTool.xpathClasses);
	RestoreUtils.xfFact = new IXFormyFactory () {
		public TreeReference ref (String refStr) {
			return FormInstance.unpackReference(new XPathReference(refStr));
		}
		
		public IDataPayload serializeInstance (FormInstance dm) {
			try {
				return (new XFormSerializingVisitor()).createSerializedPayload(dm);
			} catch (IOException e) {
				return null;
			}
		}

		public FormInstance parseRestore(byte[] data, Class restorableType) {
			return XFormParser.restoreDataModel(data, restorableType);
		}
		
		public IAnswerData parseData (String textVal, int dataType, TreeReference ref, FormDef f) {
			return XFormAnswerDataParser.getAnswerData(textVal, dataType, XFormParser.ghettoGetQuestionDef(dataType, f, ref));
		}

		public String serializeData(IAnswerData data) {
			return (String)(new XFormAnswerDataSerializer().serializeAnswerData(data));
		}

		public IConditionExpr refToPathExpr(TreeReference ref) {
			return new XPathConditional(XPathPathExpr.fromRef(ref));
		}
	};
}
 
开发者ID:medic,项目名称:javarosa,代码行数:39,代码来源:XFormsModule.java

示例7: serializeInstance

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public byte[] serializeInstance(FormInstance model, IDataReference ref) throws IOException {
	init();
	rootRef = FormInstance.unpackReference(ref);
	if (this.serializer == null) {
		this.setAnswerDataSerializer(new XFormAnswerDataSerializer());
	}
	model.accept(this);
	if (theSmsStr != null) {
		//Encode in UTF-16 by default, since it's the default for complex messages
		return theSmsStr.getBytes("UTF-16BE");
	} else {
		return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:15,代码来源:SMSSerializingVisitor.java

示例8: createSerializedPayload

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
public IDataPayload createSerializedPayload(FormInstance model, IDataReference ref)
		throws IOException {
	init();
	rootRef = FormInstance.unpackReference(ref);
	if (this.serializer == null) {
		this.setAnswerDataSerializer(new XFormAnswerDataSerializer());
	}
	model.accept(this);
	if (theSmsStr != null) {
		byte[] form = theSmsStr.getBytes("UTF-8");
		return new ByteArrayPayload(form, null, IDataPayload.PAYLOAD_TYPE_SMS);
	} else {
		return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:16,代码来源:SMSSerializingVisitor.java

示例9: verifyControlBindings

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的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);
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:36,代码来源:XFormParser.java

示例10: buildCalculate

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的package包/类
private static Recalculate buildCalculate (String xpath, IDataReference contextRef) throws XPathSyntaxException {
	XPathConditional calc = new XPathConditional(xpath);

	Recalculate r = new Recalculate(calc, FormInstance.unpackReference(contextRef));
	return r;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:7,代码来源:XFormParser.java

示例11: verifyRepeatMemberBindings

import org.javarosa.core.model.instance.FormInstance; //导入方法依赖的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));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:51,代码来源:XFormParser.java


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