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


Java XML类代码示例

本文整理汇总了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;
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:17,代码来源:HtmlComponentBuilder.java

示例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);
}
 
开发者ID:cvut,项目名称:JCOP,代码行数:64,代码来源:XMLRender.java


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