本文整理汇总了Java中org.javarosa.core.model.instance.TreeElement.isRelevant方法的典型用法代码示例。如果您正苦于以下问题:Java TreeElement.isRelevant方法的具体用法?Java TreeElement.isRelevant怎么用?Java TreeElement.isRelevant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.instance.TreeElement
的用法示例。
在下文中一共展示了TreeElement.isRelevant方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printConditionalProperty
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的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;
}
示例2: isIndexRelevant
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
/**
* Determine if the current FormIndex is relevant. Only relevant indexes
* should be returned when filling out a form.
*
* @param index
* @return true if current element at FormIndex is relevant
*/
public boolean isIndexRelevant(FormIndex index) {
TreeReference ref = form.getChildInstanceRef(index);
boolean isAskNewRepeat = (getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT);
boolean isRepeatJuncture = (getEvent(index) == FormEntryController.EVENT_REPEAT_JUNCTURE);
boolean relevant;
if (isAskNewRepeat) {
relevant = form.isRepeatRelevant(ref) && form.canCreateRepeat(ref, index);
//repeat junctures are still relevant if no new repeat can be created; that option
//is simply missing from the menu
} else if (isRepeatJuncture) {
relevant = form.isRepeatRelevant(ref);
} else {
TreeElement node = form.getMainInstance().resolveReference(ref);
relevant = node.isRelevant(); // check instance flag first
}
if (relevant) { // if instance flag/condition says relevant, we still
// have to check the <group>/<repeat> hierarchy
FormIndex ancestorIndex = index;
while (!ancestorIndex.isTerminal()) {
// This should be safe now that the TreeReference is contained
// in the ancestor index itself
TreeElement ancestorNode =
form.getMainInstance().resolveReference(ancestorIndex.getLocalReference());
if (!ancestorNode.isRelevant()) {
relevant = false;
break;
}
ancestorIndex = ancestorIndex.getNextLevel();
}
}
return relevant;
}
示例3: getValue
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public static Object getValue (String xpath, TreeReference context, FormInstance tree) {
TreeElement node = tree.resolveReference(ref(xpath).contextualize(context));
if (node == null) {
throw new RuntimeException("Could not find node [" + xpath + "] when parsing saved instance!");
}
if (node.isRelevant()) {
IAnswerData val = node.getValue();
return (val == null ? null : val.getValue());
} else {
return null;
}
}
示例4: serializeNode
import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public String serializeNode(TreeElement instanceNode) {
StringBuilder b = new StringBuilder();
// don't serialize template nodes or non-relevant nodes
if (!instanceNode.isRelevant()
|| instanceNode.getMult() == TreeReference.INDEX_TEMPLATE)
return null;
if (instanceNode.getValue() != null) {
Object serializedAnswer = serializer.serializeAnswerData(
instanceNode.getValue(), instanceNode.getDataType());
if (serializedAnswer instanceof Element) {
// DON"T handle this.
throw new RuntimeException("Can't handle serialized output for"
+ instanceNode.getValue().toString() + ", "
+ serializedAnswer);
} else if (serializedAnswer instanceof String) {
Element e = new Element();
e.addChild(Node.TEXT, (String) serializedAnswer);
String tag = instanceNode.getAttributeValue("", "tag");
if ( tag != null ) {
b.append(tag);
}
else {
String name = instanceNode.getName();
if ( name != null ) {
b.append(name);
}
}
b.append(delimiter);
for (int k = 0; k < e.getChildCount(); k++) {
b.append(e.getChild(k).toString().replace("\\", "\\\\").replace(delimiter, "\\" + delimiter));
b.append(delimiter);
}
} else {
throw new RuntimeException("Can't handle serialized output for"
+ instanceNode.getValue().toString() + ", "
+ serializedAnswer);
}
if (serializer.containsExternalData(instanceNode.getValue())
.booleanValue()) {
IDataPointer[] pointer = serializer
.retrieveExternalDataPointer(instanceNode.getValue());
for (int i = 0; i < pointer.length; ++i) {
dataPointers.add(pointer[i]);
}
}
}
return b.toString();
}