本文整理汇总了Java中org.javarosa.core.model.instance.FormInstance类的典型用法代码示例。如果您正苦于以下问题:Java FormInstance类的具体用法?Java FormInstance怎么用?Java FormInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormInstance类属于org.javarosa.core.model.instance包,在下文中一共展示了FormInstance类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: expandReference
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
public List<TreeReference> expandReference(TreeReference ref, boolean includeTemplates) {
if (!ref.isAbsolute()) {
return null;
}
FormInstance baseInstance;
if(ref.getInstanceName() != null ) {
baseInstance = getInstance(ref.getInstanceName());
} else {
baseInstance = instance;
}
if ( baseInstance == null ) {
throw new RuntimeException("Unable to expand reference " + ref.toString(true) + ", no appropriate instance in evaluation context");
}
List<TreeReference> v = new ArrayList<TreeReference>(1);
expandReference(ref, baseInstance, baseInstance.getRoot().getRef(), v, includeTemplates);
return v;
}
开发者ID:medic,项目名称:javarosa,代码行数:21,代码来源:EvaluationContext.java
示例2: 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
示例3: checkRepeatsForTemplate
import org.javarosa.core.model.instance.FormInstance; //导入依赖的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);
}
}
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:XFormParser.java
示例4: exportRMS
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
public static FormInstance exportRMS (IStorageUtility storage, Class type, String parentTag, IRecordFilter filter) {
if (!Externalizable.class.isAssignableFrom(type) || !Restorable.class.isAssignableFrom(type)) {
return null;
}
FormInstance dm = newDataModel(parentTag);
IStorageIterator ri = storage.iterate();
while (ri.hasMore()) {
Object obj = ri.nextRecord();
if (filter == null || filter.filter(obj)) {
FormInstance objModel = ((Restorable)obj).exportData();
mergeDataModel(dm, objModel, topRef(dm));
}
}
return dm;
}
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:RestoreUtils.java
示例5: eval
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
public Object eval (FormInstance model, EvaluationContext evalContext) {
boolean aval = XPathFuncExpr.toBoolean(a.eval(model, evalContext)).booleanValue();
//short-circuiting
if ((!aval && op == AND) || (aval && op == OR)) {
return new Boolean(aval);
}
boolean bval = XPathFuncExpr.toBoolean(b.eval(model, evalContext)).booleanValue();
boolean result = false;
switch (op) {
case AND: result = aval && bval; break;
case OR: result = aval || bval; break;
}
return new Boolean(result);
}
开发者ID:medic,项目名称:javarosa,代码行数:18,代码来源:XPathBoolExpr.java
示例6: pivot
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
public Object pivot (FormInstance model, EvaluationContext evalContext, List<Object> pivots, Object sentinal) throws UnpivotableExpressionException {
//Pivot both args
Object aval = a.pivot(model, evalContext, pivots, sentinal);
Object bval = b.pivot(model, evalContext, pivots, sentinal);
//If either is the sentinal, we don't have a good way to represent the resulting expression, so fail
if(aval == sentinal || bval == sentinal) {
throw new UnpivotableExpressionException();
}
//If either has added a pivot, this expression can't produce any more pivots, so signal that
if(aval == null || bval == null) {
return null;
}
//Otherwise, return the value
return this.eval(model, evalContext);
}
开发者ID:medic,项目名称:javarosa,代码行数:19,代码来源:XPathBinaryOpExpr.java
示例7: eval
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
public Object eval (FormInstance model, EvaluationContext evalContext) {
Object aval = a.eval(model, evalContext);
Object bval = b.eval(model, evalContext);
boolean result = false;
//xpath spec says comparisons only defined for numbers (not defined for strings)
aval = XPathFuncExpr.toNumeric(aval);
bval = XPathFuncExpr.toNumeric(bval);
double fa = ((Double)aval).doubleValue();
double fb = ((Double)bval).doubleValue();
switch (op) {
case LT: result = fa < fb; break;
case GT: result = fa > fb; break;
case LTE: result = fa <= fb; break;
case GTE: result = fa >= fb; break;
}
return new Boolean(result);
}
开发者ID:medic,项目名称:javarosa,代码行数:22,代码来源:XPathCmpExpr.java
示例8: addChildrenOfReference
import org.javarosa.core.model.instance.FormInstance; //导入依赖的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);
}
}
}
开发者ID:medic,项目名称:javarosa,代码行数:28,代码来源:Safe2014DagImpl.java
示例9: addMainInstanceToFormDef
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
private void addMainInstanceToFormDef(Element e, FormInstance instanceModel) {
//TreeElement root = buildInstanceStructure(e, null);
loadInstanceData(e, instanceModel.getRoot(), _f);
checkDependencyCycles();
_f.setInstance(instanceModel);
try {
_f.finalizeTriggerables();
} catch(IllegalStateException ise) {
throw new XFormParseException(ise.getMessage() == null ? "Form has an illegal cycle in its calculate and relevancy expressions!" : ise.getMessage());
}
//print unused attribute warning message for parent element
//if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
// reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
//}
}
开发者ID:medic,项目名称:javarosa,代码行数:18,代码来源:XFormParser.java
示例10: initializeTriggerables
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
/**
* Walks the current set of conditions, and evaluates each of them with the
* current context.
*/
@Override
public Collection<QuickTriggerable> initializeTriggerables(FormInstance mainInstance, EvaluationContext evalContext,
TreeReference rootRef, boolean midSurvey) {
TreeReference genericRoot = rootRef.genericize();
ArrayList<QuickTriggerable> applicable = new ArrayList<QuickTriggerable>();
for (int i = 0; i < triggerablesDAG.size(); i++) {
QuickTriggerable qt = triggerablesDAG.get(i);
for (int j = 0; j < qt.t.getTargets().size(); j++) {
TreeReference target = qt.t.getTargets().get(j);
if (genericRoot.isParentOf(target, false)) {
applicable.add(qt);
break;
}
}
}
return evaluateTriggerables(mainInstance, evalContext, applicable, rootRef);
}
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:April2014DagImpl.java
示例11: triggerTriggerables
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
/**
* The entry point for the DAG cascade after a value is changed in the model.
*
* @param ref
* The full contextualized unambiguous reference of the value that
* was changed.
*/
@Override
public Collection<QuickTriggerable> triggerTriggerables(FormInstance mainInstance, EvaluationContext evalContext,
TreeReference ref, boolean midSurvey) {
// turn unambiguous ref into a generic ref
// to identify what nodes should be triggered by this
// reference changing
TreeReference genericRef = ref.genericize();
// get triggerables which are activated by the generic reference
ArrayList<QuickTriggerable> triggered = triggerIndex.get(genericRef);
if (triggered == null) {
return Collections.emptySet();
}
ArrayList<QuickTriggerable> triggeredCopy = new ArrayList<QuickTriggerable>(triggered);
// Evaluate all of the triggerables in our new list
return evaluateTriggerables(mainInstance, evalContext, triggeredCopy, ref);
}
开发者ID:medic,项目名称:javarosa,代码行数:27,代码来源:April2014DagImpl.java
示例12: 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
示例13: applyControlProperties
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
private void applyControlProperties (FormInstance instance) {
for (int h = 0; h < 2; h++) {
List<TreeReference> selectRefs = (h == 0 ? selectOnes : selectMultis);
int type = (h == 0 ? Constants.DATATYPE_CHOICE : Constants.DATATYPE_CHOICE_LIST);
for (int i = 0; i < selectRefs.size(); i++) {
TreeReference ref = selectRefs.get(i);
List<TreeReference> nodes = new EvaluationContext(instance).expandReference(ref, true);
for (int j = 0; j < nodes.size(); j++) {
TreeElement node = instance.resolveReference(nodes.get(j));
if (node.getDataType() == Constants.DATATYPE_CHOICE || node.getDataType() == Constants.DATATYPE_CHOICE_LIST) {
//do nothing
} else if (node.getDataType() == Constants.DATATYPE_NULL || node.getDataType() == Constants.DATATYPE_TEXT) {
node.setDataType(type);
} else {
reporter.warning(XFormParserReporter.TYPE_INVALID_STRUCTURE,
"Select question " + ref.toString() + " appears to have data type that is incompatible with selection", null);
}
}
}
}
}
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:XFormParser.java
示例14: initializeTriggerables
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
/**
* Walks the current set of conditions, and evaluates each of them with the
* current context.
*/
@Override
public Collection<QuickTriggerable> initializeTriggerables(FormInstance mainInstance,
EvaluationContext evalContext, TreeReference rootRef,
boolean midSurvey) {
TreeReference genericRoot = rootRef.genericize();
ArrayList<QuickTriggerable> applicable = new ArrayList<QuickTriggerable>();
for (int i = 0; i < triggerablesDAG.size(); i++) {
QuickTriggerable qt = triggerablesDAG.get(i);
for (int j = 0; j < qt.t.getTargets().size(); j++) {
TreeReference target = qt.t.getTargets().get(j);
if (genericRoot.isParentOf(target, false)) {
applicable.add(qt);
break;
}
}
}
return evaluateTriggerables(mainInstance, evalContext, applicable, rootRef);
}
开发者ID:medic,项目名称:javarosa,代码行数:26,代码来源:LegacyDagImpl.java
示例15: evaluateChildrenTriggerables
import org.javarosa.core.model.instance.FormInstance; //导入依赖的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);
}
}
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:Fast2014DagImpl.java
示例16: copyItemsetAnswer
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
@Override
public void copyItemsetAnswer(FormInstance mainInstance,
EvaluationContext evalContext, TreeReference copyRef,
TreeElement copyToElement, boolean midSurvey) {
TreeReference targetRef = copyToElement.getRef();
Set<QuickTriggerable> qtSet1 = triggerTriggerables(mainInstance,
evalContext, copyRef, midSurvey,
new HashSet<QuickTriggerable>(0));// trigger conditions that
// depend on the creation of
// these new nodes
publishSummary("Copied itemset answer (phase 1)", targetRef, qtSet1);
Set<QuickTriggerable> qtSet2 = initializeTriggerables(mainInstance,
evalContext, copyRef, midSurvey,
new HashSet<QuickTriggerable>(0));// initialize conditions for
// the node (and sub-nodes)
publishSummary("Copied itemset answer (phase 2)", targetRef, qtSet2);
// not 100% sure this will work since destRef is ambiguous as the last
// step, but i think it's supposed to work
}
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:Fast2014DagImpl.java
示例17: evaluateTriggerables
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
/**
* Step 2 in evaluating DAG computation updates from a value being changed
* in the instance. This step is responsible for taking the root set of
* directly triggered conditions, identifying which conditions should
* further be triggered due to their update, and then dispatching all of the
* evaluations.
*
* @param tv
* A set of all of the trigerrables directly triggered by the
* value changed
* @param anchorRef
*/
private Set<QuickTriggerable> evaluateTriggerables(FormInstance mainInstance,
EvaluationContext evalContext,
Set<QuickTriggerable> tv, TreeReference anchorRef,
boolean midSurvey,
Set<QuickTriggerable> alreadyEvaluated) {
// add all cascaded triggerables to queue
// Iterate through all of the currently known triggerables to be
// triggered
// Iterate through all of the currently known triggerables to be
// triggered
Set<QuickTriggerable> refSet = new HashSet<QuickTriggerable>(tv);
for (; !refSet.isEmpty();) {
Set<QuickTriggerable> newSet = new HashSet<QuickTriggerable>();
for (QuickTriggerable qt : refSet) {
fillTriggeredElements(mainInstance, evalContext, qt, tv, newSet,
midSurvey);
}
refSet = newSet;
}
return doEvaluateTriggerables(mainInstance, evalContext, tv, anchorRef, alreadyEvaluated);
}
开发者ID:medic,项目名称:javarosa,代码行数:36,代码来源:Fast2014DagImpl.java
示例18: addChildrenOfReference
import org.javarosa.core.model.instance.FormInstance; //导入依赖的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);
}
}
}
开发者ID:medic,项目名称:javarosa,代码行数:27,代码来源:Fast2014DagImpl.java
示例19: initializeTriggerables
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
private Set<QuickTriggerable> initializeTriggerables(
FormInstance mainInstance, EvaluationContext evalContext,
TreeReference rootRef, boolean midSurvey,
Set<QuickTriggerable> alreadyEvaluated) {
TreeReference genericRoot = rootRef.genericize();
Set<QuickTriggerable> applicable = new HashSet<QuickTriggerable>();
for (int i = 0; i < triggerablesDAG.size(); i++) {
QuickTriggerable qt = triggerablesDAG.get(i);
for (int j = 0; j < qt.t.getTargets().size(); j++) {
TreeReference target = qt.t.getTargets().get(j);
if (genericRoot.isParentOf(target, false)) {
applicable.add(qt);
break;
}
}
}
return evaluateTriggerables(mainInstance, evalContext, applicable,
rootRef, midSurvey, alreadyEvaluated);
}
开发者ID:medic,项目名称:javarosa,代码行数:22,代码来源:Fast2014DagImpl.java
示例20: triggerTriggerables
import org.javarosa.core.model.instance.FormInstance; //导入依赖的package包/类
private Set<QuickTriggerable> triggerTriggerables(
FormInstance mainInstance, EvaluationContext evalContext,
TreeReference ref, boolean midSurvey,
Set<QuickTriggerable> alreadyEvaluated) {
// turn unambiguous ref into a generic ref
// to identify what nodes should be triggered by this
// reference changing
TreeReference genericRef = ref.genericize();
// get triggerables which are activated by the generic reference
ArrayList<QuickTriggerable> triggered = triggerIndex.get(genericRef);
if (triggered == null) {
return alreadyEvaluated;
}
Set<QuickTriggerable> triggeredCopy = new HashSet<QuickTriggerable>(
triggered);
// Evaluate all of the triggerables in our new set
return evaluateTriggerables(mainInstance, evalContext, triggeredCopy,
ref, midSurvey, alreadyEvaluated);
}
开发者ID:medic,项目名称:javarosa,代码行数:24,代码来源:Fast2014DagImpl.java
注:本文中的org.javarosa.core.model.instance.FormInstance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论