• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java XPathReference类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: readExternal

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
/**
 * Reads a group definition object from the supplied stream.
 */
public void readExternal(DataInputStream dis, PrototypeFactory pf) throws IOException, DeserializationException {
    setID(ExtUtil.readInt(dis));
    setAppearanceAttr((String)ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
    setBind((XPathReference)ExtUtil.read(dis, new ExtWrapTagged(), pf));
    setTextID((String)ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
    setLabelInnerText((String)ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
    setRepeat(ExtUtil.readBool(dis));
    setChildren((Vector)ExtUtil.read(dis, new ExtWrapListPoly(), pf));

    noAddRemove = ExtUtil.readBool(dis);
    count = (XPathReference)ExtUtil.read(dis, new ExtWrapNullable(new ExtWrapTagged()), pf);

    chooseCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    addCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    delCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    doneCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    addEmptyCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    doneEmptyCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    entryHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    delHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    mainHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:26,代码来源:GroupDef.java


示例2: getAbsRef

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
/**
 * Converts a (possibly relative) reference into an absolute reference
 * based on its parent
 *
 * @param ref       potentially null reference
 * @param parentRef must be an absolute path
 */
public static XPathReference getAbsRef(XPathReference ref, TreeReference parentRef) {
    TreeReference tref;

    if (!parentRef.isAbsolute()) {
        throw new RuntimeException("XFormParser.getAbsRef: parentRef must be absolute");
    }

    if (ref != null) {
        tref = ref.getReference();
    } else {
        tref = TreeReference.selfRef(); //only happens for <group>s with no binding
    }

    tref = tref.parent(parentRef);
    if (tref == null) {
        throw new XFormParseException("Binding path [" + tref + "] not allowed with parent binding of [" + parentRef + "]");
    }

    return new XPathReference(tref);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:28,代码来源:XFormParser.java


示例3: getEntityFromID

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
/**
 * Takes an ID and identifies a reference in the provided context which corresponds
 * to that element if one can be found.
 *
 * NOT GUARANTEED TO WORK! May return an entity if one exists
 */
public TreeReference getEntityFromID(EvaluationContext ec, String elementId) {
    //The uniqueid here is the value selected, so we can in theory track down the value we're looking for.

    //Get root nodeset
    TreeReference nodesetRef = this.getNodeset().clone();
    Vector<XPathExpression> predicates = nodesetRef.getPredicate(nodesetRef.size() - 1);
    if (predicates == null) {
        predicates = new Vector<XPathExpression>();
    }
    predicates.addElement(new XPathEqExpr(XPathEqExpr.EQ, XPathReference.getPathExpr(this.getValue()), new XPathStringLiteral(elementId)));
    nodesetRef.addPredicate(nodesetRef.size() - 1, predicates);

    Vector<TreeReference> elements = ec.expandReference(nodesetRef);
    if (elements.size() == 1) {
        return elements.firstElement();
    } else if (elements.size() > 1) {
        //Lots of nodes. Can't really choose one yet.
        return null;
    } else {
        return null;
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:29,代码来源:EntityDatum.java


示例4: Detail

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
public Detail(String id, DisplayUnit title, String nodeset,
              Detail[] details,
              DetailField[] fields,
              OrderedHashtable<String, String> variables,
              Vector<Action> actions) {
    if (details.length > 0 && fields.length > 0) {
        throw new IllegalArgumentException("A detail may contain either sub-details or fields, but not both.");
    }

    this.id = id;
    this.title = title;
    if (nodeset != null) {
        this.nodeset = XPathReference.getPathExpr(nodeset).getReference();
    }
    this.details = details;
    this.fields = fields;
    this.variables = variables;
    this.actions = actions;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:20,代码来源:Detail.java


示例5: handle

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
/**
 * Handle pollsensor node, creating a new PollSensor action with the node that sensor data will be written to.
 *
 * @param e      pollsensor Element
 * @param parent FormDef for the form being parsed
 */
@Override
public void handle(XFormParser p, Element e, Object parent) {
    String event = e.getAttributeValue(null, "event");
    FormDef form = (FormDef)parent;
    PollSensorAction action;

    String ref = e.getAttributeValue(null, "ref");
    if (ref != null) {
        XPathReference dataRef = new XPathReference(ref);
        dataRef = XFormParser.getAbsRef(dataRef, TreeReference.rootRef());
        TreeReference treeRef = FormInstance.unpackReference(dataRef);
        p.registerActionTarget(treeRef);
        action = new PollSensorAction(treeRef);
    } else {
        action = new PollSensorAction();
    }

    form.getActionController().registerEventListener(event, action);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:26,代码来源:PollSensorExtensionParser.java


示例6: readExternal

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
/**
 * Reads a group definition object from the supplied stream.
 */
@Override
public void readExternal(DataInputStream dis, PrototypeFactory pf) throws IOException, DeserializationException {
    setID(ExtUtil.readInt(dis));
    setAppearanceAttr((String)ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
    setBind((XPathReference)ExtUtil.read(dis, new ExtWrapTagged(), pf));
    setTextID((String)ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
    setLabelInnerText((String)ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
    setIsRepeat(ExtUtil.readBool(dis));
    setChildren((Vector)ExtUtil.read(dis, new ExtWrapListPoly(), pf));

    noAddRemove = ExtUtil.readBool(dis);
    count = (XPathReference)ExtUtil.read(dis, new ExtWrapNullable(new ExtWrapTagged()), pf);

    chooseCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    addCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    delCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    doneCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    addEmptyCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    doneEmptyCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    entryHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    delHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
    mainHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:27,代码来源:GroupDef.java


示例7: parseItemsetLabelElement

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
private void parseItemsetLabelElement(Element child, ItemsetBinding itemset, Vector<String> labelUA) {
    String labelXpath = child.getAttributeValue("", REF_ATTR);
    boolean labelItext = false;

    if (XFormUtils.showUnusedAttributeWarning(child, labelUA)) {
        reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(child, labelUA), getVagueLocation(child));
    }

    if (labelXpath != null) {
        if (labelXpath.startsWith("jr:itext(") && labelXpath.endsWith(")")) {
            labelXpath = labelXpath.substring("jr:itext(".length(), labelXpath.indexOf(")"));
            labelItext = true;
        }
    } else {
        throw new XFormParseException("<label> in <itemset> requires 'ref'");
    }

    XPathPathExpr labelPath = XPathReference.getPathExpr(labelXpath);
    itemset.labelRef = FormInstance.unpackReference(getAbsRef(new XPathReference(labelPath), itemset.nodesetRef));
    itemset.labelExpr = new XPathConditional(labelPath);
    itemset.labelIsItext = labelItext;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:23,代码来源:XFormParser.java


示例8: getAbsRef

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
/**
 * Converts a (possibly relative) reference into an absolute reference
 * based on its parent
 *
 * @param ref       potentially null reference
 * @param parentRef must be an absolute path
 */
public static XPathReference getAbsRef(XPathReference ref, TreeReference parentRef) {
    TreeReference tref;

    if (!parentRef.isAbsolute()) {
        throw new RuntimeException("XFormParser.getAbsRef: parentRef must be absolute");
    }

    if (ref != null) {
        tref = ref.getReference();
    } else {
        tref = TreeReference.selfRef(); //only happens for <group>s with no binding
    }

    TreeReference refPreContextualization = tref;
    tref = tref.parent(parentRef);
    if (tref == null) {
        throw new XFormParseException("Binding path [" + refPreContextualization.toString(true) + "] not allowed with parent binding of [" + parentRef + "]");
    }

    return new XPathReference(tref);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:29,代码来源:XFormParser.java


示例9: getSubmissionDataReference

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
/**
 * Find the portion of the form that is to be submitted
 *
 * @return
 */
private IDataReference getSubmissionDataReference() {
    FormDef formDef = mFormEntryController.getModel().getForm();
    // Determine the information about the submission...
    SubmissionProfile p = formDef.getSubmissionProfile();
    if (p == null || p.getRef() == null) {
        return new XPathReference("/");
    } else {
        return p.getRef();
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:16,代码来源:FormController.java


示例10: buildIndex

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
public FormIndex buildIndex(List<Integer> indexes, List<Integer> multiplicities, List<IFormElement> elements) {
   FormIndex cur = null;
   List<Integer> curMultiplicities = new ArrayList<Integer>();
   for (int j = 0; j < multiplicities.size(); ++j) {
      curMultiplicities.add(multiplicities.get(j));
   }

   List<IFormElement> curElements = new ArrayList<IFormElement>();
   for (int j = 0; j < elements.size(); ++j) {
      curElements.add(elements.get(j));
   }

   for (int i = indexes.size() - 1; i >= 0; i--) {
      int ix = indexes.get(i);
      int mult = multiplicities.get(i);

      // ----begin unclear why this is here... side effects???
      // TODO: ... No words. Just fix it.
      IFormElement ife = elements.get(i);
      XPathReference xpr = (ife != null) ? (XPathReference) ife.getBind() : null;
      TreeReference ref = (xpr != null) ? (TreeReference) xpr.getReference() : null;
      // ----end
      if (!(elements.get(i) instanceof GroupDef && ((GroupDef) elements.get(i))
              .getRepeat())) {
         mult = -1;
      }

      cur = new FormIndex(cur, ix, mult, getChildInstanceRef(curElements, curMultiplicities));
      curMultiplicities.remove(curMultiplicities.size() - 1);
      curElements.remove(curElements.size() - 1);
   }
   return cur;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:34,代码来源:FormDef.java


示例11: getConditionExpressionForTrueAction

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
/**
 * Pull this in from FormOverview so that we can make fields private.
 * 
 * @param instanceNode
 * @param action
 * @return
 */
public final IConditionExpr getConditionExpressionForTrueAction(
		FormInstance mainInstance, TreeElement instanceNode, int action) {
	IConditionExpr expr = null;
	for (int i = 0; i < triggerablesDAG.size() && expr == null; i++) {
		// Clayton Sims - Jun 1, 2009 : Not sure how legitimate this
		// cast is. It might work now, but break later.
		// Clayton Sims - Jun 24, 2009 : Yeah, that change broke things.
		// For now, we won't bother to print out anything that isn't
		// a condition.
		QuickTriggerable qt = triggerablesDAG.get(i);
		if (qt.t instanceof Condition) {
			Condition c = (Condition) qt.t;

			if (c.trueAction == action) {
				List<TreeReference> targets = c.getTargets();
				for (int j = 0; j < targets.size() && expr == null; j++) {
					TreeReference target = targets.get(j);

					TreeReference tr = (TreeReference) (new XPathReference(
							target)).getReference();
					TreeElement element = mainInstance.getTemplatePath(tr);
					if (instanceNode == element) {
						expr = c.getExpr();
					}
				}
			}
		}
	}
	return expr;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:38,代码来源:IDag.java


示例12: caseFilter

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
private EntityFilter<Case> caseFilter() {
    //We need to determine if we're using ownership for purging. For right now, only in sync mode
    Vector<String> owners = null;
    if(CommCareProperties.TETHER_SYNC.equals(PropertyManager._().getSingularProperty(CommCareProperties.TETHER_MODE))) {
        owners = new Vector<String>();
        Vector<String> users = new Vector<String>();
        for(IStorageIterator<User> userIterator = StorageManager.getStorage(User.STORAGE_KEY).iterate(); userIterator.hasMore();) {
            String id = userIterator.nextRecord().getUniqueId();
            owners.addElement(id);
            users.addElement(id);
        }

        //Now add all of the relevant groups
        //TODO: Wow. This is.... kind of megasketch
        for(String userId : users) {
            DataInstance instance = CommCareUtil.loadFixtureForUser("user-groups", userId);
            if(instance == null) { continue; }
            EvaluationContext ec = new EvaluationContext(instance);
            for(TreeReference ref : ec.expandReference(XPathReference.getPathExpr("/groups/group/@id").getReference())) {
                AbstractTreeElement<AbstractTreeElement> idelement = ec.resolveReference(ref);
                if(idelement.getValue() != null) {
                    owners.addElement(idelement.getValue().uncast().getString());
                }
            }
        }
    }


    return new CasePurgeFilter((RMSStorageUtilityIndexed<Case>)StorageManager.getStorage(Case.STORAGE_KEY), owners);

}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:32,代码来源:CommCareContext.java


示例13: readExternal

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    setId((String)ExtUtil.read(in, new ExtWrapNullable(String.class), pf));
    setDataType(ExtUtil.readInt(in));
    setPreload((String)ExtUtil.read(in, new ExtWrapNullable(String.class), pf));
    setPreloadParams((String)ExtUtil.read(in, new ExtWrapNullable(String.class), pf));
    ref = (XPathReference)ExtUtil.read(in, new ExtWrapTagged());

    //don't bother reading relevancy/required/readonly/constraint/calculate right now; they're only used during parse anyway
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:10,代码来源:DataBinding.java


示例14: getXPathAttrExpression

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
public static XPathPathExpr getXPathAttrExpression(String attribute) {
    //Cache tables can only take in integers due to some terrible 1.3 design issues
    //so we have to manually cache our attribute string's hash and follow from there.
    XPathPathExpr cached = table.retrieve(attribute);

    if (cached == null) {
        cached = XPathReference.getPathExpr("@" + attribute);
        table.register(attribute, cached);
    }
    return cached;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:12,代码来源:TreeUtilities.java


示例15: SubmissionProfile

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
public SubmissionProfile(XPathReference ref, String method, String action, String mediatype, Hashtable<String, String> attributeMap) {
    this.method = method;
    this.ref = ref;
    this.action = action;
    this.mediaType = mediatype;
    this.attributeMap = attributeMap;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:8,代码来源:SubmissionProfile.java


示例16: readExternal

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    ref = (XPathReference)ExtUtil.read(in, new ExtWrapTagged(XPathReference.class));
    method = ExtUtil.readString(in);
    action = ExtUtil.readString(in);
    mediaType = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
    attributeMap = (Hashtable<String, String>)ExtUtil.read(in, new ExtWrapMap(String.class, String.class));
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:8,代码来源:SubmissionProfile.java


示例17: readExternal

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
public void readExternal(DataInputStream dis, PrototypeFactory pf) throws IOException, DeserializationException {
    setID(ExtUtil.readInt(dis));
    binding = (XPathReference)ExtUtil.read(dis, new ExtWrapNullable(new ExtWrapTagged()), pf);
    setAppearanceAttr((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
    setControlType(ExtUtil.readInt(dis));
    choices = ExtUtil.nullIfEmpty((Vector)ExtUtil.read(dis, new ExtWrapList(SelectChoice.class), pf));
    for (int i = 0; i < getNumChoices(); i++) {
        choices.elementAt(i).setIndex(i);
    }
    setDynamicChoices((ItemsetBinding)ExtUtil.read(dis, new ExtWrapNullable(ItemsetBinding.class)));
    mQuestionStrings = (Hashtable<String, QuestionString>)ExtUtil.read(dis, new ExtWrapMap(String.class, QuestionString.class));
    extensions = (Vector)ExtUtil.read(dis, new ExtWrapListPoly(), pf);
    actionController = (ActionController)ExtUtil.read(dis, new ExtWrapNullable(ActionController.class), pf);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:15,代码来源:QuestionDef.java


示例18: verifyControlBindings

import org.javarosa.model.xform.XPathReference; //导入依赖的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);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:36,代码来源:XFormParser.java


示例19: parseSubmission

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
public SubmissionProfile parseSubmission(String method, String action, XPathReference ref, Element element) {
    String mediatype = element.getAttributeValue(null, "mediatype");
    Hashtable<String, String> attributeMap = new Hashtable<String, String>();
    int nAttr = element.getAttributeCount();
    for (int i = 0; i < nAttr; ++i) {
        String name = element.getAttributeName(i);
        if (name.equals("ref")) continue;
        if (name.equals("bind")) continue;
        if (name.equals("method")) continue;
        if (name.equals("action")) continue;
        String value = element.getAttributeValue(i);
        attributeMap.put(name, value);
    }
    return new SubmissionProfile(ref, method, action, mediatype, attributeMap);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:16,代码来源:SubmissionParser.java


示例20: addDataRef

import org.javarosa.model.xform.XPathReference; //导入依赖的package包/类
protected void addDataRef(FormInstance dm, String ref, IAnswerData data) {
    TreeReference treeRef = XPathReference.getPathExpr(ref).getReference();
    treeRef = inlinePositionArgs(treeRef);

    addNodeRef(dm, treeRef);


    if (data != null) {
        dm.resolveReference(treeRef).setValue(data);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:12,代码来源:XPathEvalTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AWTFontManager类代码示例发布时间:2022-05-22
下一篇:
Java Direction类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap