本文整理汇总了Java中org.javarosa.core.model.condition.Condition类的典型用法代码示例。如果您正苦于以下问题:Java Condition类的具体用法?Java Condition怎么用?Java Condition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Condition类属于org.javarosa.core.model.condition包,在下文中一共展示了Condition类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isRepeatRelevant
import org.javarosa.core.model.condition.Condition; //导入依赖的package包/类
public boolean isRepeatRelevant(TreeReference repeatRef) {
boolean relev = true;
Condition c = conditionRepeatTargetIndex.get(repeatRef.genericize());
if (c != null) {
relev = c.evalBool(mainInstance, new EvaluationContext(exprEvalContext, repeatRef));
}
//check the relevancy of the immediate parent
if (relev) {
TreeElement templNode = mainInstance.getTemplate(repeatRef);
TreeReference parentPath = templNode.getParent().getRef().genericize();
TreeElement parentNode = mainInstance.resolveReference(parentPath.contextualize(repeatRef));
relev = parentNode.isRelevant();
}
return relev;
}
示例2: printConditionalProperty
import org.javarosa.core.model.condition.Condition; //导入依赖的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;
}
示例3: getConditionExpressionForTrueAction
import org.javarosa.core.model.condition.Condition; //导入依赖的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;
}
示例4: getConditions
import org.javarosa.core.model.condition.Condition; //导入依赖的package包/类
/**
* API for retrieving the list of conditions, for use when
* serializing the form definition (e.g., into .cache file).
* @return
*/
public final ArrayList<Condition> getConditions() {
ArrayList<Condition> conditions = new ArrayList<Condition>();
for ( QuickTriggerable qt : unorderedTriggerables ) {
if ( qt.t instanceof Condition ) {
conditions.add((Condition) qt.t);
}
}
return conditions;
}
示例5: buildConditionRepeatTargetIndex
import org.javarosa.core.model.condition.Condition; //导入依赖的package包/类
private void buildConditionRepeatTargetIndex() {
conditionRepeatTargetIndex = new Hashtable<TreeReference, Condition>();
for (Triggerable t : triggerables) {
if (t instanceof Condition) {
for (TreeReference target : t.getTargets()) {
if (mainInstance.getTemplate(target) != null) {
conditionRepeatTargetIndex.put(target, (Condition)t);
}
}
}
}
}
示例6: readExternal
import org.javarosa.core.model.condition.Condition; //导入依赖的package包/类
/**
* Reads the form definition object from the supplied stream.
*
* Requires that the instance has been set to a prototype of the instance that
* should be used for deserialization.
*/
@Override
public void readExternal(DataInputStream dis, PrototypeFactory pf) throws IOException, DeserializationException {
setID(ExtUtil.readInt(dis));
setName(ExtUtil.nullIfEmpty(ExtUtil.readString(dis)));
setTitle((String)ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
setChildren((Vector)ExtUtil.read(dis, new ExtWrapListPoly(), pf));
setInstance((FormInstance)ExtUtil.read(dis, FormInstance.class, pf));
setLocalizer((Localizer)ExtUtil.read(dis, new ExtWrapNullable(Localizer.class), pf));
Vector vcond = (Vector)ExtUtil.read(dis, new ExtWrapList(Condition.class), pf);
for (Enumeration e = vcond.elements(); e.hasMoreElements(); ) {
addTriggerable((Condition)e.nextElement());
}
Vector vcalc = (Vector)ExtUtil.read(dis, new ExtWrapList(Recalculate.class), pf);
for (Enumeration e = vcalc.elements(); e.hasMoreElements(); ) {
addTriggerable((Recalculate)e.nextElement());
}
finalizeTriggerables();
outputFragments = (Vector)ExtUtil.read(dis, new ExtWrapListPoly(), pf);
submissionProfiles = (Hashtable<String, SubmissionProfile>)ExtUtil.read(dis, new ExtWrapMap(String.class, SubmissionProfile.class), pf);
formInstances = (Hashtable<String, DataInstance>)ExtUtil.read(dis, new ExtWrapMap(String.class, new ExtWrapTagged()), pf);
extensions = (Vector)ExtUtil.read(dis, new ExtWrapListPoly(), pf);
setEvaluationContext(new EvaluationContext(null));
actionController = (ActionController)ExtUtil.read(dis, ActionController.class, pf);
}
示例7: writeExternal
import org.javarosa.core.model.condition.Condition; //导入依赖的package包/类
/**
* Writes the form definition object to the supplied stream.
*/
@Override
public void writeExternal(DataOutputStream dos) throws IOException {
ExtUtil.writeNumeric(dos, getID());
ExtUtil.writeString(dos, ExtUtil.emptyIfNull(getName()));
ExtUtil.write(dos, new ExtWrapNullable(getTitle()));
ExtUtil.write(dos, new ExtWrapListPoly(getChildren()));
ExtUtil.write(dos, getMainInstance());
ExtUtil.write(dos, new ExtWrapNullable(localizer));
Vector<Condition> conditions = new Vector<Condition>();
Vector<Recalculate> recalcs = new Vector<Recalculate>();
for (int i = 0; i < triggerables.size(); i++) {
Triggerable t = triggerables.elementAt(i);
if (t instanceof Condition) {
conditions.addElement((Condition)t);
} else if (t instanceof Recalculate) {
recalcs.addElement((Recalculate)t);
}
}
ExtUtil.write(dos, new ExtWrapList(conditions));
ExtUtil.write(dos, new ExtWrapList(recalcs));
ExtUtil.write(dos, new ExtWrapListPoly(outputFragments));
ExtUtil.write(dos, new ExtWrapMap(submissionProfiles));
//for support of multi-instance forms
ExtUtil.write(dos, new ExtWrapMap(formInstances, new ExtWrapTagged()));
ExtUtil.write(dos, new ExtWrapListPoly(extensions));
ExtUtil.write(dos, actionController);
}
示例8: buildConditionRepeatTargetIndex
import org.javarosa.core.model.condition.Condition; //导入依赖的package包/类
private void buildConditionRepeatTargetIndex() {
conditionRepeatTargetIndex = new HashMap<>();
for (Triggerable t : triggerables) {
if (t instanceof Condition) {
for (TreeReference target : t.getTargets()) {
if (mainInstance.getTemplate(target) != null) {
conditionRepeatTargetIndex.put(target, (Condition)t);
}
}
}
}
}
示例9: writeExternal
import org.javarosa.core.model.condition.Condition; //导入依赖的package包/类
/**
* Writes the form definition object to the supplied stream.
*/
@Override
public void writeExternal(DataOutputStream dos) throws IOException {
ExtUtil.writeNumeric(dos, getID());
ExtUtil.writeString(dos, ExtUtil.emptyIfNull(getName()));
ExtUtil.write(dos, new ExtWrapNullable(getTitle()));
ExtUtil.write(dos, new ExtWrapListPoly(getChildren()));
ExtUtil.write(dos, getMainInstance());
ExtUtil.write(dos, new ExtWrapNullable(localizer));
Vector<Condition> conditions = new Vector<>();
Vector<Recalculate> recalcs = new Vector<>();
for (Triggerable t : triggerables) {
if (t instanceof Condition) {
conditions.addElement((Condition)t);
} else if (t instanceof Recalculate) {
recalcs.addElement((Recalculate)t);
}
}
ExtUtil.write(dos, new ExtWrapList(conditions));
ExtUtil.write(dos, new ExtWrapList(recalcs));
ExtUtil.write(dos, new ExtWrapListPoly(outputFragments));
ExtUtil.write(dos, new ExtWrapMap(submissionProfiles));
//for support of multi-instance forms
ExtUtil.write(dos, new ExtWrapMap(formInstances, new ExtWrapTagged()));
ExtUtil.write(dos, new ExtWrapListPoly(extensions));
ExtUtil.write(dos, actionController);
}
示例10: printConditionalProperty
import org.javarosa.core.model.condition.Condition; //导入依赖的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;
}
示例11: printConditionalProperty
import org.javarosa.core.model.condition.Condition; //导入依赖的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 (Iterator<Triggerable> e = f.getTriggerables(); e.hasNext();) {
Triggerable trig = e.next();
// 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;
}