當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。