本文整理汇总了Java中org.ofbiz.minilang.method.conditional.Conditional类的典型用法代码示例。如果您正苦于以下问题:Java Conditional类的具体用法?Java Conditional怎么用?Java Conditional使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Conditional类属于org.ofbiz.minilang.method.conditional包,在下文中一共展示了Conditional类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Assert
import org.ofbiz.minilang.method.conditional.Conditional; //导入依赖的package包/类
public Assert(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
if (MiniLangValidate.validationOn()) {
MiniLangValidate.attributeNames(simpleMethod, element, "title", "error-list-name");
MiniLangValidate.constantAttributes(simpleMethod, element, "title", "error-list-name");
}
errorListFma = FlexibleMapAccessor.getInstance(MiniLangValidate.checkAttribute(element.getAttribute("error-list-name"), "error_list"));
titleExdr = FlexibleStringExpander.getInstance(element.getAttribute("title"));
List<? extends Element> childElements = UtilXml.childElementList(element);
if (MiniLangValidate.validationOn() && childElements.isEmpty()) {
MiniLangValidate.handleError("No conditional elements.", simpleMethod, element);
}
List<Conditional> conditionalList = new ArrayList<Conditional>(childElements.size());
for (Element conditionalElement : UtilXml.childElementList(element)) {
conditionalList.add(ConditionalFactory.makeConditional(conditionalElement, simpleMethod));
}
this.conditionalList = Collections.unmodifiableList(conditionalList);
}
示例2: exec
import org.ofbiz.minilang.method.conditional.Conditional; //导入依赖的package包/类
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
if (methodContext.isTraceOn()) {
outputTraceMessage(methodContext, "Begin assert.");
}
List<Object> messages = errorListFma.get(methodContext.getEnvMap());
String title = titleExdr.expandString(methodContext.getEnvMap());
for (Conditional condition : conditionalList) {
if (!condition.checkCondition(methodContext)) {
StringBuilder messageBuffer = new StringBuilder("Assertion ");
if (!title.isEmpty()) {
messageBuffer.append("[");
messageBuffer.append(title);
messageBuffer.append("] ");
}
messageBuffer.append("failed: ");
condition.prettyPrint(messageBuffer, methodContext);
if (messages == null) {
messages = new LinkedList<Object>();
errorListFma.put(methodContext.getEnvMap(), messages);
}
messages.add(messageBuffer.toString());
if (methodContext.isTraceOn()) {
outputTraceMessage(methodContext, "Condition evaluated to false: " + condition + ", adding error message.");
}
}
}
if (methodContext.isTraceOn()) {
outputTraceMessage(methodContext, "End assert.");
}
return true;
}
示例3: toString
import org.ofbiz.minilang.method.conditional.Conditional; //导入依赖的package包/类
@Override
public String toString() {
StringBuilder messageBuf = new StringBuilder("<assert");
if (!titleExdr.isEmpty()) {
messageBuf.append(" title=\"");
messageBuf.append(titleExdr);
messageBuf.append("\"");
}
messageBuf.append(">");
for (Conditional condition : conditionalList) {
messageBuf.append(condition);
}
messageBuf.append("</assert>");
return messageBuf.toString();
}