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


Java IConditionExpr类代码示例

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


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

示例1: printConditionalProperty

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
private static String printConditionalProperty (String property, FormDef f, TreeElement instanceNode) {
	int action = -1;
	String conditionHeader = null;
	boolean absolute = false;
	boolean absoluteReportable = false;
	String absoluteHeader = null;

	if (property.equals("relevant")) {
		action = Condition.ACTION_SHOW;
		conditionHeader = "Relevant if";
		absolute = instanceNode.isRelevant();
		absoluteReportable = false;
		absoluteHeader = "Never relevant";
	} else if (property.equals("required")) {
		action = Condition.ACTION_REQUIRE;
		conditionHeader = "Conditionally Required";
		absolute = instanceNode.isRequired();
		absoluteReportable = true;
		absoluteHeader = "Required";
	} else if (property.equals("readonly")) {
		action = Condition.ACTION_DISABLE;
		conditionHeader = "Conditionally Read-only";
		absolute = instanceNode.isEnabled();
		absoluteReportable = false;
		absoluteHeader = "Read-only";
	}

	IConditionExpr expr = f.getConditionExpressionForTrueAction(instanceNode, action);

	String line = null;
	if (expr != null) {
		line = conditionHeader + ": " + printCondition(expr);
	} else if (absolute == absoluteReportable) {
		line = absoluteHeader;
	}

	return line;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:39,代码来源:FormOverview.java

示例2: registerModule

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

示例3: getConditionExpressionForTrueAction

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

示例4: getRelativeValue

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
public IConditionExpr getRelativeValue () {
	TreeReference relRef = null;
	
	if (copyRef == null) {
		relRef = valueRef; //must be absolute in this case
	} else if (valueRef != null) {
		relRef = valueRef.relativize(copyRef);
	}
	
	return relRef != null ? RestoreUtils.xfFact.refToPathExpr(relRef) : null;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:12,代码来源:ItemsetBinding.java

示例5: readExternal

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
	nodesetRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
	nodesetExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapTagged(), pf);
	contextRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
	labelRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
	labelExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapTagged(), pf);
	valueRef = (TreeReference)ExtUtil.read(in, new ExtWrapNullable(TreeReference.class), pf);
	valueExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapNullable(new ExtWrapTagged()), pf);
	copyRef = (TreeReference)ExtUtil.read(in, new ExtWrapNullable(TreeReference.class), pf);
	labelIsItext = ExtUtil.readBool(in);
	copyMode = ExtUtil.readBool(in);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:13,代码来源:ItemsetBinding.java

示例6: evaluatePivot

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
private void evaluatePivot(CmpPivot pivot, IConditionExpr conditional, EvaluationContext c, FormInstance instance) throws UnpivotableExpressionException {
	double unit = unit();
	double val = pivot.getVal();
	double lt = val - unit;
	double gt = val + unit;

	c.isConstraint = true;

	c.candidateValue = castToValue(val);
	boolean eq = XPathFuncExpr.toBoolean(conditional.eval(instance, c)).booleanValue();

	c.candidateValue = castToValue(lt);
	boolean ltr = XPathFuncExpr.toBoolean(conditional.eval(instance, c)).booleanValue();

	c.candidateValue = castToValue(gt);
	boolean gtr = XPathFuncExpr.toBoolean(conditional.eval(instance, c)).booleanValue();

	if(ltr && !gtr) {
		max = new Double(val);
		maxInclusive = eq;
		maxCast= castToValue(max);
	}

	if(!ltr && gtr) {
		min = new Double(val);
		minInclusive = eq;
		minCast = castToValue(min);
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:30,代码来源:RangeHint.java

示例7: getRelativeValue

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
public IConditionExpr getRelativeValue() {
    TreeReference relRef = null;

    if (copyRef == null) {
        relRef = valueRef; //must be absolute in this case
    } else if (valueRef != null) {
        relRef = valueRef.relativize(copyRef);
    }

    return relRef != null ? RestoreUtils.refToPathExpr(relRef) : null;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:12,代码来源:ItemsetBinding.java

示例8: readExternal

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    nodesetRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
    nodesetExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapTagged(), pf);
    contextRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
    labelRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
    labelExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapTagged(), pf);
    valueRef = (TreeReference)ExtUtil.read(in, new ExtWrapNullable(TreeReference.class), pf);
    valueExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapNullable(new ExtWrapTagged()), pf);
    copyRef = (TreeReference)ExtUtil.read(in, new ExtWrapNullable(TreeReference.class), pf);
    labelIsItext = ExtUtil.readBool(in);
    copyMode = ExtUtil.readBool(in);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:13,代码来源:ItemsetBinding.java

示例9: evaluatePivot

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
private void evaluatePivot(CmpPivot pivot, IConditionExpr conditional, EvaluationContext c, FormInstance instance) throws UnpivotableExpressionException {
    double unit = unit();
    double val = pivot.getVal();
    double lt = val - unit;
    double gt = val + unit;

    c.isConstraint = true;

    c.candidateValue = castToValue(val);
    boolean eq = XPathFuncExpr.toBoolean(conditional.eval(instance, c)).booleanValue();

    c.candidateValue = castToValue(lt);
    boolean ltr = XPathFuncExpr.toBoolean(conditional.eval(instance, c)).booleanValue();

    c.candidateValue = castToValue(gt);
    boolean gtr = XPathFuncExpr.toBoolean(conditional.eval(instance, c)).booleanValue();
    
    if (ltr && !gtr) {
        max = new Double(val);
        maxInclusive = eq;
        maxCast = castToValue(max);
    }

    if (!ltr && gtr) {
        min = new Double(val);
        minInclusive = eq;
        minCast = castToValue(min);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:30,代码来源:RangeHint.java

示例10: readExternal

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
@Override
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    nodesetRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
    nodesetExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapTagged(), pf);
    contextRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
    labelRef = (TreeReference)ExtUtil.read(in, TreeReference.class, pf);
    labelExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapTagged(), pf);
    valueRef = (TreeReference)ExtUtil.read(in, new ExtWrapNullable(TreeReference.class), pf);
    valueExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapNullable(new ExtWrapTagged()), pf);
    copyRef = (TreeReference)ExtUtil.read(in, new ExtWrapNullable(TreeReference.class), pf);
    labelIsItext = ExtUtil.readBool(in);
    copyMode = ExtUtil.readBool(in);
    sortRef = (TreeReference)ExtUtil.read(in, new ExtWrapNullable(TreeReference.class), pf);
    sortExpr = (IConditionExpr)ExtUtil.read(in, new ExtWrapNullable(new ExtWrapTagged()), pf);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:16,代码来源:ItemsetBinding.java

示例11: evaluatePivot

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
private void evaluatePivot(CmpPivot pivot, IConditionExpr conditional, EvaluationContext c, FormInstance instance) throws UnpivotableExpressionException {
    double unit = unit();
    double val = pivot.getVal();
    double lt = val - unit;
    double gt = val + unit;

    c.isConstraint = true;

    c.candidateValue = castToValue(val);
    boolean eq = FunctionUtils.toBoolean(conditional.eval(instance, c));

    c.candidateValue = castToValue(lt);
    boolean ltr = FunctionUtils.toBoolean(conditional.eval(instance, c));

    c.candidateValue = castToValue(gt);
    boolean gtr = FunctionUtils.toBoolean(conditional.eval(instance, c));
    
    if (ltr && !gtr) {
        max = val;
        maxInclusive = eq;
        maxCast = castToValue(max);
    }

    if (!ltr && gtr) {
        min = val;
        minInclusive = eq;
        minCast = castToValue(min);
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:30,代码来源:RangeHint.java

示例12: printCondition

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
private static String printCondition (IConditionExpr c) {
	String expr = ((XPathConditional)c).xpath;

	return (expr != null ? expr : "condition unavailable");
}
 
开发者ID:medic,项目名称:javarosa,代码行数:6,代码来源:FormOverview.java

示例13: printConditionalProperty

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
private static String printConditionalProperty (String property, FormDef f, TreeElement instanceNode) {
    int action = -1;
    String conditionHeader = null;
    boolean absolute = false;
    boolean absoluteReportable = false;
    String absoluteHeader = null;

    if (property.equals("relevant")) {
        action = Condition.ACTION_SHOW;
        conditionHeader = "Relevant if";
        absolute = instanceNode.isRelevant();
        absoluteReportable = false;
        absoluteHeader = "Never relevant";
    } else if (property.equals("required")) {
        action = Condition.ACTION_REQUIRE;
        conditionHeader = "Conditionally Required";
        absolute = instanceNode.isRequired();
        absoluteReportable = true;
        absoluteHeader = "Required";
    } else if (property.equals("readonly")) {
        action = Condition.ACTION_DISABLE;
        conditionHeader = "Conditionally Read-only";
        absolute = instanceNode.isEnabled();
        absoluteReportable = false;
        absoluteHeader = "Read-only";
    }

    IConditionExpr expr = null;

    triggerLoop:
    for (Enumeration<Triggerable> e = f.getTriggerables(); e.hasMoreElements();) {
        Triggerable trig = e.nextElement();
        // 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.
        if (trig instanceof Condition) {
            Condition c = (Condition)trig;

            if (c.trueAction == action) {
                for (TreeReference target : c.targets) {
                    if (instanceNode == getInstanceNode(f.getInstance(), new XPathReference(target))) {
                        expr = c.expr;
                        break triggerLoop;
                    }
                }
            }
        }
    }

    String line = null;
    if (expr != null) {
        line = conditionHeader + ": " + printCondition(expr);
    } else if (absolute == absoluteReportable) {
        line = absoluteHeader;
    }

    return line;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:61,代码来源:FormOverview.java

示例14: printCondition

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
private static String printCondition (IConditionExpr c) {
    String expr = ((XPathConditional)c).xpath;

    return (expr != null ? expr : "condition unavailable");
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:6,代码来源:FormOverview.java

示例15: fillTemplateString

import org.javarosa.core.model.condition.IConditionExpr; //导入依赖的package包/类
/**
 * Performs substitutions on place-holder template from form text by
 * evaluating args in template using the current context.
 *
 * @param template   String
 * @param contextRef TreeReference
 * @param variables  Hashtable<String, ?>
 * @return String with the all args in the template filled with appropriate
 * context values.
 */
public String fillTemplateString(String template, TreeReference contextRef, Hashtable<String, ?> variables) {
    // argument to value mapping
    Hashtable<String, String> args = new Hashtable<String, String>();

    int depth = 0;
    // grab all template arguments that need to have substitutions performed
    Vector outstandingArgs = Localizer.getArgs(template);

    String templateAfterSubstitution;

    // Step through outstandingArgs from the template, looking up the value
    // they map to, evaluating that under the evaluation context and
    // storing in the local args mapping.
    // Then perform substitutions over the template until a fixpoint is found
    while (outstandingArgs.size() > 0) {
        for (int i = 0; i < outstandingArgs.size(); i++) {
            String argName = (String)outstandingArgs.elementAt(i);
            // lookup value an arg points to if it isn't in our local mapping
            if (!args.containsKey(argName)) {
                int ix = -1;
                try {
                    ix = Integer.parseInt(argName);
                } catch (NumberFormatException nfe) {
                    System.err.println("Warning: expect arguments to be numeric [" + argName + "]");
                }

                if (ix < 0 || ix >= outputFragments.size()) {
                    continue;
                }

                IConditionExpr expr = (IConditionExpr)outputFragments.elementAt(ix);
                EvaluationContext ec = new EvaluationContext(exprEvalContext, contextRef);
                ec.setOriginalContext(contextRef);
                ec.setVariables(variables);
                String value = expr.evalReadable(this.getMainInstance(), ec);
                args.put(argName, value);
            }
        }

        templateAfterSubstitution = Localizer.processArguments(template, args);

        // The last substitution made no progress, probably because the
        // argument isn't in outputFragments, so stop looping and
        // attempting more subs!
        if (template.equals(templateAfterSubstitution)) {
            return template;
        }

        template = templateAfterSubstitution;

        // Since strings being substituted might themselves have arguments that
        // need to be further substituted, we must recompute the unperformed
        // substitutions and continue to loop.
        outstandingArgs = Localizer.getArgs(template);

        if (depth++ >= TEMPLATING_RECURSION_LIMIT) {
            throw new RuntimeException("Dependency cycle in <output>s; recursion limit exceeded!!");
        }
    }

    return template;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:73,代码来源:FormDef.java


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