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


Java XPathReference类代码示例

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


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


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