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


Java Directives.up方法代码示例

本文整理汇总了Java中org.xembly.Directives.up方法的典型用法代码示例。如果您正苦于以下问题:Java Directives.up方法的具体用法?Java Directives.up怎么用?Java Directives.up使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xembly.Directives的用法示例。


在下文中一共展示了Directives.up方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createConfigurationElement

import org.xembly.Directives; //导入方法依赖的package包/类
/**
 * Add the configuration element for a workflow action
 *
 * @param properties The configuration properties
 * @param directives The Xembly Directives object to which to add the new XML elements
 */
private void createConfigurationElement(Map<String, String> properties, Directives directives) {
    if (properties == null) {
        return;
    }

    directives.add("configuration");

    for (Map.Entry<String, String> entry : properties.entrySet()) {
        directives.add("property")
                .add("name")
                .set(entry.getKey())
                .up()
                .add("value")
                .set(entry.getValue())
                .up()
                .up();
    }
    directives.up();
}
 
开发者ID:etsy,项目名称:arbiter,代码行数:26,代码来源:OozieWorkflowGenerator.java

示例2: xembly

import org.xembly.Directives; //导入方法依赖的package包/类
/**
 * To Xembly.
 * @param item The item
 * @param full Full info?
 * @return Directives
 * @throws IOException If fails
 */
private static Iterable<Directive> xembly(
    final Item item, final boolean full) throws IOException {
    final long time = Long.parseLong(item.get("time").getN());
    final long when = Long.parseLong(item.get("when").getN());
    final long ttl = Long.parseLong(item.get("ttl").getN())
        * TimeUnit.SECONDS.toMillis(1L);
    final Directives dirs = new Directives()
        .add("target")
        .add("url")
        .set(item.get("url").getS()).up()
        .add("time").set(time).up()
        .add("time_utc").set(DyStatus.utc(time)).up()
        .add("age").set(DyStatus.age(time)).up()
        .add("code").set(Integer.parseInt(item.get("code").getN())).up()
        .add("attempts")
        .set(Long.parseLong(item.get("attempts").getN())).up()
        .add("when").set(when).up()
        .add("when_utc").set(DyStatus.utc(when)).up()
        .add("ttl").set(ttl).up()
        .add("ttl_utc").set(DyStatus.utc(ttl)).up()
        .add("minutes_left").set(DyStatus.age(when)).up()
        .add("ttl_minutes_left").set(DyStatus.age(ttl)).up();
    if (full) {
        dirs.add("request")
            .set(Xembler.escape(item.get("request").getS())).up()
            .add("response")
            .set(Xembler.escape(item.get("response").getS())).up();
    }
    return dirs.up();
}
 
开发者ID:yegor256,项目名称:rehttp,代码行数:38,代码来源:DyStatus.java

示例3: createActionElement

import org.xembly.Directives; //导入方法依赖的package包/类
/**
 * Add the XML element for an action
 *
 * @param action The action for which to add the element
 * @param workflowGraph The full workflow graph
 * @param transition The OK transition for this action
 * @param errorTransition The error transition for this action if it is not inside a fork/join pair
 * @param directives The Xembly Directives object to which to add the new XML elements
 */
private void createActionElement(Action action, DirectedAcyclicGraph<Action, DefaultEdge> workflowGraph, Action transition, Action errorTransition, Directives directives) {
    ActionType type = getActionType(action.getType());

    directives.add("action")
            .attr("name", action.getName())
            .add(type.getTag());

    if (type.getXmlns() != null) {
        directives.attr("xmlns", type.getXmlns());
    }

    // There is an outer action tag and an inner tag corresponding to the action type
    Map<String, List<String>> interpolated = NamedArgumentInterpolator.interpolate(type.getDefaultArgs(), action.getNamedArgs(), type.getDefaultInterpolations(), action.getPositionalArgs());
    Map<String, String> mergedConfigurationProperties = new HashMap<>(type.getProperties());
    if (action.getConfigurationProperties() != null) {
        mergedConfigurationProperties.putAll(action.getConfigurationProperties());
    }
    addInnerActionElements(mergedConfigurationProperties, type.getConfigurationPosition(), directives, interpolated, action.getPositionalArgs());
    directives.up();

    String okTransitionName = action.getForceOk() != null ? action.getForceOk() : transition.getName();
    directives.add("ok")
            .attr("to", okTransitionName)
            .up();

    // We allow forcing a particular error transition regardless of other considerations
    String interpolatedForceError = NamedArgumentInterpolator.interpolate(action.getForceError(), ImmutableMap.of("okTransition", okTransitionName), type.getDefaultInterpolations());
    String errorTransitionName = interpolatedForceError != null ? interpolatedForceError : errorTransition.getName();
    // Find the enclosing fork/join pair
    // If an action is inside a fork/join, it should transition to the join on error
    String enclosingJoinName = getEnclosingForkJoinName(action, workflowGraph);
    if (enclosingJoinName != null) {
        errorTransitionName = interpolatedForceError != null ? interpolatedForceError : enclosingJoinName;
    }
    directives.add("error")
            .attr("to", errorTransitionName)
            .up();
}
 
开发者ID:etsy,项目名称:arbiter,代码行数:48,代码来源:OozieWorkflowGenerator.java

示例4: metric

import org.xembly.Directives; //导入方法依赖的package包/类
/**
 * Metric to Xembly.
 * @param file The XML file with metric report
 * @return Xembly
 * @throws FileNotFoundException If fails
 */
private static Iterable<Directive> metric(final Path file)
    throws FileNotFoundException {
    final String name = file.getFileName()
        .toString().replaceAll("\\.xml$", "");
    final XML xml = new XMLDocument(file.toFile());
    final List<Double> values = new Sorted<>(
        new org.cactoos.list.Mapped<>(
            Double::parseDouble,
            xml.xpath("//class[@element='true' and @value!='NaN']/@value")
        )
    );
    final double green = (double) xml.nodes(
        "//*[@element='true' and @color='green']"
    ).size();
    final double yellow = (double) xml.nodes(
        "//*[@element='true' and @color='yellow']"
    ).size();
    final double red = (double) xml.nodes(
        "//*[@element='true' and @color='red']"
    ).size();
    double all = green + yellow + red;
    if (all == 0.0d) {
        all = 1.0d;
    }
    final double score = 10.0d
        * (green + yellow * 0.25d + red * 0.05d) / all;
    final Directives dirs = new Directives()
        .add("metric")
        .attr("name", name)
        .add("html").set(String.format("%s.html", name)).up()
        .add("xml").set(String.format("%s.xml", name)).up()
        .add("elements").set(values.size()).up()
        .add("classes").set(xml.nodes("//class").size()).up()
        .add("green").set((int) green).up()
        .add("yellow").set((int) yellow).up()
        .add("red").set((int) red).up()
        .add("score").set(score).up()
        .add("reverse")
        .set(
            Boolean.toString(
                Double.parseDouble(xml.xpath("/metric/colors/@high").get(0))
                > Double.parseDouble(
                    xml.xpath("/metric/colors/@low").get(0)
                )
            )
        )
        .up();
    if (!values.isEmpty()) {
        dirs.add("min").set(values.get(0)).up()
            .add("max").set(values.get(values.size() - 1)).up();
    }
    final Iterator<XML> bars = xml.nodes("/metric/bars").iterator();
    if (bars.hasNext()) {
        dirs.add("bars").append(Directives.copyOf(bars.next().node())).up();
    }
    final Iterator<XML> stats = xml.nodes("/metric/statistics").iterator();
    if (stats.hasNext()) {
        final XML stat = stats.next();
        dirs.add("defects").set(stat.xpath("defects/text()").get(0)).up()
            .add("sigma").set(stat.xpath("sigma/text()").get(0)).up()
            .add("mean").set(stat.xpath("mean/text()").get(0)).up();
    }
    return dirs.up();
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:71,代码来源:Index.java


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