本文整理汇总了Java中org.apache.ecs.xml.XML类的典型用法代码示例。如果您正苦于以下问题:Java XML类的具体用法?Java XML怎么用?Java XML使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XML类属于org.apache.ecs.xml包,在下文中一共展示了XML类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLabel
import org.apache.ecs.xml.XML; //导入依赖的package包/类
/**
* About how to create labels in wicket: https://cwiki.apache.org/confluence/display/WICKET/Wicket%27s+XHTML+tags
*/
private Label createLabel(final IModelElement<?> e, final Input input) {
final Label label = new Label();
label.addAttribute("wicket:for", e.getWicketId());
if (input == null) {
label.setClass("control-label col-sm-2");
} else {
label.addElement(input);
}
final XML wicketLabel = new XML("wicket:label");
wicketLabel.setTagText(e.getStaticTitle());
label.addElement(wicketLabel);
return label;
}
示例2: render
import org.apache.ecs.xml.XML; //导入依赖的package包/类
public void render(Result result) throws IOException {
XMLDocument doc = new XMLDocument();
XML root = new XML("result");
XML experiment = new XML("experiment");
experiment.addAttribute("date", new Date());
root.addElement(experiment);
for (ResultEntry resultEntry : result.getResultEntries()) {
XML entry = new XML("entry");
entry.addAttribute("algorithm", resultEntry.getAlgorithm());
entry.addAttribute("problem", resultEntry.getProblem());
entry.addAttribute("optimize-counter", resultEntry.getOptimizeCounter());
entry.addAttribute("exception", resultEntry.getException() == null ?
"" : resultEntry.getException().getClass().getSimpleName());
PreciseTimestamp start = resultEntry.getStartTimestamp();
PreciseTimestamp stop = resultEntry.getStopTimestamp();
entry.addAttribute("cpu-time", start.getCpuTimeSpent(stop));
entry.addAttribute("system-time", start.getSystemTimeSpent(stop));
entry.addAttribute("user-time", start.getUserTimeSpent(stop));
entry.addAttribute("clock-time", start.getClockTimeSpent(stop));
if (resultEntry.getBestConfiguration() != null) {
XML solution = new XML("best-solution");
solution.addAttribute("fitness", resultEntry.getBestFitness());
XML operations = new XML("operations");
for (OperationHistory operationHistory : resultEntry.getBestConfiguration().getOperationHistory().getChronologicalList()) {
XML operation = new XML("operation");
operation.addAttribute("label", operationHistory.getOperation().toString());
operation.addAttribute("index", operationHistory.getCounter());
operations.addElement(operation);
}
solution.addElement(operations);
// configuration attributes
XML attributes = new XML("attributes");
ConfigurationMap configurationMap = resultEntry.getProblem().getConfigurationMap();
for (int i = 0; i < resultEntry.getBestConfiguration().getDimension(); ++i) {
Integer integer = resultEntry.getBestConfiguration().valueAt(i);
XML attribute = new XML("attribute");
attribute.addAttribute("index", i);
attribute.addAttribute("value", integer);
attribute.addAttribute("human-readable-value", configurationMap.map(integer, i));
attributes.addElement(attribute);
}
solution.addElement(attributes);
entry.addElement(solution);
}
root.addElement(entry);
}
doc.addElement(root);
doc.output(this.printStream);
}