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


Java TreeElement类代码示例

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


TreeElement类属于org.javarosa.core.model.instance包,在下文中一共展示了TreeElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractFormParameters

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
/**
 * Extract the form id, version and uiVersion.
 *
 * @param rootElement
 *          - the tree element that is the root submission.
 * @param defaultFormIdValue
 *          - used if no "id" attribute found. This should already be
 *          slash-substituted.
 * @return
 */
private XFormParameters extractFormParameters(TreeElement rootElement, String defaultFormIdValue) {

  String formIdValue = null;
  String versionString = rootElement.getAttributeValue(null, "version");

  // search for the "id" attribute
  for (int i = 0; i < rootElement.getAttributeCount(); i++) {
    String name = rootElement.getAttributeName(i);
    if (name.equals(ParserConsts.FORM_ID_ATTRIBUTE_NAME)) {
      formIdValue = rootElement.getAttributeValue(i);
      formIdValue = formIdValue.replaceAll(ParserConsts.FORWARD_SLASH,
          ParserConsts.FORWARD_SLASH_SUBSTITUTION);
      break;
    }
  }

  return new XFormParameters((formIdValue == null) ? defaultFormIdValue : formIdValue,
      versionString);
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:30,代码来源:BaseFormParserForJavaRosa.java

示例2: FormInstanceValidator

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
public FormInstanceValidator(InputStream formInput, InputStream instanceInput) throws Exception {
		theForm = XFormUtils.getFormFromInputStream(formInput);
		
		savedModel = XFormParser.restoreDataModel(instanceInput, null);
        TreeElement templateRoot = theForm.getInstance().getRoot().deepCopy(true);

        //sanity check instance names before loading
        if (!savedModel.getRoot().getName().equals(templateRoot.getName()) || savedModel.getRoot().getMult() != 0) {
			System.out.println("Instance model name does not match xform instance name.");
			System.out.println("Instance: " + savedModel.getName() + " Xform: " + templateRoot.getName());
			System.exit(1);
        }
        
        model = new FormEntryModel(theForm);
        controller = new FormEntryController(model);

        
        //Populate XForm Model 
//        TreeReference tr = TreeReference.rootRef();
//        tr.add(templateRoot.getName(), TreeReference.INDEX_UNBOUND);
//        templateRoot.populate(savedRoot, f);
//
//        f.getInstance().setRoot(templateRoot);
	}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:FormInstanceValidator.java

示例3: isIndexReadonly

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
/**
 * @param index
 * @return true if the element at the specified index is read only
 */
public boolean isIndexReadonly(FormIndex index) {
    if (index.isBeginningOfFormIndex() || index.isEndOfFormIndex())
        return true;

    TreeReference ref = form.getChildInstanceRef(index);
    boolean isAskNewRepeat = (getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT ||
    						  getEvent(index) == FormEntryController.EVENT_REPEAT_JUNCTURE);

    if (isAskNewRepeat) {
        return false;
    } else {
        TreeElement node = form.getMainInstance().resolveReference(ref);
        return !node.isEnabled();
    }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:FormEntryModel.java

示例4: setRepeatNextMultiplicity

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
private boolean setRepeatNextMultiplicity(List<IFormElement> elements, List<Integer> multiplicities) {
	// find out if node is repeatable
	TreeReference nodeRef = form.getChildInstanceRef(elements, multiplicities);
	TreeElement node = form.getMainInstance().resolveReference(nodeRef);
	if (node == null || node.isRepeatable()) { // node == null if there are no
		// instances of the repeat
		int mult;
		if (node == null) {
			mult = 0; // no repeats; next is 0
		} else {
			String name = node.getName();
			TreeElement parentNode = form.getMainInstance().resolveReference(nodeRef.getParentRef());
			mult = parentNode.getChildMultiplicity(name);
		}
		multiplicities.set(multiplicities.size() - 1, Integer.valueOf(repeatStructure == REPEAT_STRUCTURE_NON_LINEAR ? TreeReference.INDEX_REPEAT_JUNCTURE : mult));
		return true;
	} else {
		return false;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:21,代码来源:FormEntryModel.java

示例5: attachBind

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
private static void attachBind(TreeElement node, DataBinding bind) {
	node.setDataType(bind.getDataType());

	if (bind.relevancyCondition == null) {
		node.setRelevant(bind.relevantAbsolute);
	}
	if (bind.requiredCondition == null) {
		node.setRequired(bind.requiredAbsolute);
	}
	if (bind.readonlyCondition == null) {
		node.setEnabled(!bind.readonlyAbsolute);
	}
	if (bind.constraint != null) {
		node.setConstraint(new Constraint(bind.constraint, bind.constraintMessage));
	}

	node.setPreloadHandler(bind.getPreload());
	node.setPreloadParams(bind.getPreloadParams());
	node.setBindAttributes(bind.getAdditionalAttributes());
}
 
开发者ID:medic,项目名称:javarosa,代码行数:21,代码来源:XFormParser.java

示例6: loadXmlInstance

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
/**
 * Load a compatible xml instance into FormDef f
 *
 * call before f.initialize()!
 */
public static void loadXmlInstance(FormDef f, Document xmlInst) {
       TreeElement savedRoot = XFormParser.restoreDataModel(xmlInst, null).getRoot();
       TreeElement templateRoot = f.getMainInstance().getRoot().deepCopy(true);

       // weak check for matching forms
       // TODO: should check that namespaces match?
    if (!savedRoot.getName().equals(templateRoot.getName()) || savedRoot.getMult() != 0) {
    	throw new RuntimeException("Saved form instance does not match template form definition");
    }

    // populate the data model
    TreeReference tr = TreeReference.rootRef();
    tr.add(templateRoot.getName(), TreeReference.INDEX_UNBOUND);
    templateRoot.populate(savedRoot, f);

    // populated model to current form
    f.getMainInstance().setRoot(templateRoot);

    // if the new instance is inserted into the formdef before f.initialize() is called, this
    // locale refresh is unnecessary
    //   Localizer loc = f.getLocalizer();
    //   if (loc != null) {
    //       f.localeChanged(loc.getLocale(), loc);
    //	 }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:31,代码来源:XFormParser.java

示例7: applyControlProperties

import org.javarosa.core.model.instance.TreeElement; //导入依赖的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

示例8: createRepeatGroup

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
@Override
public void createRepeatGroup(FormInstance mainInstance,
		EvaluationContext evalContext, TreeReference createRef,
		TreeElement parentElement, TreeElement createdElement) {

	// trigger conditions that depend on the creation of this new node
	Set<QuickTriggerable> qtSet1 = triggerTriggerables(mainInstance,
			evalContext, createRef, true, new HashSet<QuickTriggerable>(0));
	publishSummary("Created (phase 1)", createRef, qtSet1);

	// initialize conditions for the node (and sub-nodes)
	Set<QuickTriggerable> qtSet2 = initializeTriggerables(mainInstance,
			evalContext, createRef, true, new HashSet<QuickTriggerable>(0));
	publishSummary("Created (phase 2)", createRef, qtSet2);

	Set<QuickTriggerable> alreadyEvaluated = new HashSet<QuickTriggerable>(
			qtSet1);
	alreadyEvaluated.addAll(qtSet2);

	evaluateChildrenTriggerables(mainInstance, evalContext, createdElement,
			true, true, alreadyEvaluated);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:Fast2014DagImpl.java

示例9: evaluateChildrenTriggerables

import org.javarosa.core.model.instance.TreeElement; //导入依赖的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

示例10: 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);
		}
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:27,代码来源:Fast2014DagImpl.java

示例11: createRepeatGroup

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
@Override
public void createRepeatGroup(FormInstance mainInstance,
      EvaluationContext evalContext, TreeReference createRef,
      TreeElement parentElement, TreeElement createdElement) {

   // trigger conditions that depend on the creation of this new node
   Set<QuickTriggerable> qtSet1 = triggerTriggerables(mainInstance,
         evalContext, createRef, new HashSet<QuickTriggerable>(0));
   publishSummary("Created (phase 1)", createRef, qtSet1);

   // initialize conditions for the node (and sub-nodes)
   Set<QuickTriggerable> qtSet2 = initializeTriggerables(mainInstance,
         evalContext, createRef, new HashSet<QuickTriggerable>(0));
   publishSummary("Created (phase 2)", createRef, qtSet2);

   Set<QuickTriggerable> alreadyEvaluated = new HashSet<QuickTriggerable>(
         qtSet1);
   alreadyEvaluated.addAll(qtSet2);

   evaluateChildrenTriggerables(mainInstance, evalContext,
         createdElement, true, alreadyEvaluated);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:Safe2014DagImpl.java

示例12: copyItemsetAnswer

import org.javarosa.core.model.instance.TreeElement; //导入依赖的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,
         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,
         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,代码来源:Safe2014DagImpl.java

示例13: 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);
      }
   }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:28,代码来源:Safe2014DagImpl.java

示例14: checkRepeatsForTemplate

import org.javarosa.core.model.instance.TreeElement; //导入依赖的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

示例15: checkHomogeneity

import org.javarosa.core.model.instance.TreeElement; //导入依赖的package包/类
private void checkHomogeneity (FormInstance instance) {
     List<TreeReference> refs = getRepeatableRefs();
	for (int i = 0; i < refs.size(); i++) {
		TreeReference ref = refs.get(i);
		TreeElement template = null;
        List<TreeReference> nodes = new EvaluationContext(instance).expandReference(ref);
		for (int j = 0; j < nodes.size(); j++) {
			TreeReference nref = nodes.get(j);
			TreeElement node = instance.resolveReference(nref);
			if (node == null) //don't crash on '/'... invalid repeat binding will be caught later
				continue;

			if (template == null)
				template = instance.getTemplate(nref);

			if (!FormInstance.isHomogeneous(template, node)) {
				reporter.warning(XFormParserReporter.TYPE_INVALID_STRUCTURE, "Not all repeated nodes for a given repeat binding [" + nref.toString() + "] are homogeneous! This will cause serious problems!", null);
			}
		}
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:22,代码来源:XFormParser.java


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