• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Xembler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.xembly.Xembler的典型用法代码示例。如果您正苦于以下问题:Java Xembler类的具体用法?Java Xembler怎么用?Java Xembler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: acceptsAndRenders

import org.xembly.Xembler; //导入依赖的package包/类
@Test
public void acceptsAndRenders() throws Exception {
    final Path output = Files.createTempDirectory("").resolve("x2");
    final Path input = Paths.get(".");
    new App(input, output).analyze();
    final Mistakes mistakes = new Mistakes();
    mistakes.add(output);
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new Xembler(
                new Directives().add("metrics").append(
                    new Joined<Directive>(mistakes.worst())
                )
            ).xmlQuietly()
        ),
        XhtmlMatchers.hasXPath("/metrics/metric[@id='LCOM']/avg")
    );
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:19,代码来源:MistakesTest.java


示例2: acceptsAndRenders

import org.xembly.Xembler; //导入依赖的package包/类
@Test
public void acceptsAndRenders() throws Exception {
    final Path output = Files.createTempDirectory("").resolve("x2");
    final Path input = Paths.get(".");
    new App(input, output).analyze();
    final Results results = new Results();
    results.add("org.takes:takes", output);
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new Xembler(
                new Directives().add("repos").append(
                    new Joined<Directive>(results.recent())
                )
            ).xmlQuietly()
        ),
        XhtmlMatchers.hasXPath("/repos")
    );
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:19,代码来源:ResultsTest.java


示例3: text

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * Render text via XPath.
 * @param pattern Pattern to use
 * @return Plain text
 */
public String text(final CharSequence pattern) {
    final XML xml = new XMLDocument(
        new Xembler(this.dirs).domQuietly()
    );
    final Pattern ptn = Pattern.compile("\\{([^}]+)}");
    final Matcher mtr = ptn.matcher(pattern);
    final StringBuffer out = new StringBuffer(pattern.length());
    while (mtr.find()) {
        mtr.appendReplacement(
            out, xml.xpath(mtr.group(1)).get(0).replace("$", "\\$")
        );
    }
    mtr.appendTail(out);
    return out.toString();
}
 
开发者ID:yegor256,项目名称:wring,代码行数:21,代码来源:XePrint.java


示例4: addsAndRemovePipes

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * DyPipes can add and remove pipes.
 * @throws Exception If some problem inside
 */
@Test
public void addsAndRemovePipes() throws Exception {
    final User user = new DyUser(new Dynamo(), "jeffrey");
    final Pipes pipes = user.pipes();
    pipes.add("{\"name\": \"hello\"}");
    final Pipe pipe = pipes.iterate().iterator().next();
    MatcherAssert.assertThat(
        new Xembler(pipe.asXembly()).xml(),
        XhtmlMatchers.hasXPaths(
            "/pipe/json",
            "/pipe/id"
        )
    );
    pipe.delete();
}
 
开发者ID:yegor256,项目名称:wring,代码行数:20,代码来源:DyPipesITCase.java


示例5: appendsToExistingEvents

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * DyEvents can append text to.
 * @throws Exception If some problem inside
 */
@Test
public void appendsToExistingEvents() throws Exception {
    final User user = new DyUser(new Dynamo(), "peter");
    final Events events = user.events();
    final String title = "a simple title";
    events.post(title, "\n\tfirst body");
    events.post(title, "\n\u0000\u00fdin between");
    events.post(title, "second body\n\n");
    MatcherAssert.assertThat(
        new Xembler(events.iterate().iterator().next().asXembly()).xml(),
        XhtmlMatchers.hasXPaths(
            "/event/text[contains(.,'first')]",
            "/event/text[contains(.,'second body')]",
            "/event/text[not(contains(.,'first body\n'))]"
        )
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:22,代码来源:DyEventsITCase.java


示例6: upvotes

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * DyEvent can up-vote.
 * @throws Exception If some problem inside
 */
@Test
public void upvotes() throws Exception {
    final User user = new DyUser(new Dynamo(), "nick");
    final Events events = user.events();
    events.post("hey you", "some text [test](http://a.com/$t)!");
    final Event event = events.iterate().iterator().next();
    event.vote(Tv.FIFTEEN);
    MatcherAssert.assertThat(
        new Xembler(events.iterate().iterator().next().asXembly()).xml(),
        XhtmlMatchers.hasXPaths(
            "/event[title='hey you']",
            "/event[rank=16]"
        )
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:20,代码来源:DyEventITCase.java


示例7: render

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * Render source as XML.
 * @param dom DOM node to build upon
 * @param src Source
 * @return XML
 * @throws IOException If fails
 */
private static InputStream render(final Node dom,
    final XeSource src) throws IOException {
    final Node copy = cloneNode(dom);
    final ByteArrayOutputStream baos =
        new ByteArrayOutputStream();
    final Node node = new Xembler(src.toXembly()).applyQuietly(copy);
    try {
        TransformerFactory.newInstance().newTransformer().transform(
            new DOMSource(node),
            new StreamResult(
                new Utf8OutputStreamWriter(baos)
            )
        );
    } catch (final TransformerException ex) {
        throw new IllegalStateException(ex);
    }
    return new ByteArrayInputStream(baos.toByteArray());
}
 
开发者ID:yegor256,项目名称:takes,代码行数:26,代码来源:RsXembly.java


示例8: exec

import org.xembly.Xembler; //导入依赖的package包/类
@Override
public void exec(final Agent agent) throws IOException {
    final XML before = new StrictXML(
        Deck.UPGRADE.transform(
            new XMLDocument(new File(this.path))
        ),
        Deck.SCHEMA
    );
    final XML after = new XMLDocument(
        new Xembler(agent.exec(before)).applyQuietly(before.node())
    );
    FileUtils.write(
        new File(this.path),
        new StrictXML(
            after,
            Deck.SCHEMA
        ).toString(),
        CharEncoding.UTF_8
    );
    Logger.info(
        this, "deck saved to %s (%d bytes):\n%s", this.path,
        new File(this.path).length(), after
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:25,代码来源:FkDeck.java


示例9: checksState

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * CheckState can check state.
 * @throws IOException If fails
 */
@Test
public void checksState() throws IOException {
    final Agent agent = new CheckState(
        new Script.Fake("\n\n hey\nALIVE")
    );
    final XML deck = new XMLDocument(
        Joiner.on(' ').join(
            "<deck><containers><container state='unknown'>",
            "<name>abcd1234</name><host>127.0.0.1</host>",
            "<http>80</http>",
            "</container></containers></deck>"
        )
    );
    MatcherAssert.assertThat(
        new XMLDocument(
            new Xembler(agent.exec(deck)).applyQuietly(deck.node())
        ),
        XhtmlMatchers.hasXPaths(
            "/deck/containers/container[@state='alive']"
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:27,代码来源:CheckStateTest.java


示例10: buildsImage

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * BuildImage can build image.
 * @throws IOException If fails
 */
@Test
public void buildsImage() throws IOException {
    final Agent agent = new BuildImage(
        new Script.Fake("\n\n hey\nALIVE")
    );
    final XML deck = new XMLDocument(
        Joiner.on(' ').join(
            "<deck name='test/test'>",
            "<repo><name>abcd1234</name><uri>http://</uri>",
            "</repo></deck>"
        )
    );
    MatcherAssert.assertThat(
        new XMLDocument(
            new Xembler(agent.exec(deck)).applyQuietly(deck.node())
        ),
        XhtmlMatchers.hasXPaths(
            "/deck[not(repo)]",
            "/deck/images/image[@type='blue']"
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:27,代码来源:BuildImageTest.java


示例11: updatesNginx

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * UpdateNginx can update nginx.
 * @throws IOException If fails
 */
@Test
public void updatesNginx() throws IOException {
    final Agent agent = new UpdateNginx(
        new Script.Fake("")
    );
    final XML deck = new XMLDocument(
        Joiner.on(' ').join(
            "<deck name='test/test'><containers>",
            " <container type='green' state='alive'><http>80</http>",
            "  <host>localhost</host><name>aaaaaaaa</name>",
            "  <image>ffffffff</image>",
            " </container></containers>",
            "<domains><domain>test.thindeck.com</domain></domains></deck>"
        )
    );
    MatcherAssert.assertThat(
        new XMLDocument(
            new Xembler(agent.exec(deck)).applyQuietly(deck.node())
        ),
        XhtmlMatchers.hasXPaths("/deck")
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:27,代码来源:UpdateNginxTest.java


示例12: wipesRepo

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * WipeRepo can wire a repo.
 * @throws IOException If fails
 */
@Test
public void wipesRepo() throws IOException {
    final Agent agent = new WipeRepo();
    final XML deck = new XMLDocument(
        Joiner.on(' ').join(
            "<deck name='test/test'><repo added='2013-01-01T12:59:59'>",
            "<name>abcdef59</name><uri>#</uri></repo></deck>"
        )
    );
    MatcherAssert.assertThat(
        new XMLDocument(
            new Xembler(agent.exec(deck)).applyQuietly(deck.node())
        ),
        XhtmlMatchers.hasXPaths("/deck[not(repo)]")
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:21,代码来源:WipeRepoTest.java


示例13: manipulatesWithTypesAndUseCases

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeOntology can do manipulations.
 * @throws Exception When necessary
 */
@Test
public void manipulatesWithTypesAndUseCases() throws Exception {
    final XeOntology onto = new XeOntology();
    final Type type = onto.type("First");
    type.explain("first text");
    type.parent("Root");
    type.slot("one").assign("Emp");
    onto.type("Second").explain("second text");
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(onto).xml()),
        XhtmlMatchers.hasXPaths(
            "/spec",
            "/spec/types/type[name='First']",
            "/spec/types/type[name='Second']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:22,代码来源:XeOntologyTest.java


示例14: manipulatesWithType

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeType can do type manipulations.
 * @throws Exception When necessary
 */
@Test
public void manipulatesWithType() throws Exception {
    final Directives dirs = new Directives().add("t");
    final Type type = new XeType(dirs, "/t");
    type.explain("first text");
    type.explain("second text");
    type.parent("Root");
    type.slot("'one").assign("Emp");
    type.mention(2);
    type.mention(1);
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(dirs).xml()),
        XhtmlMatchers.hasXPaths(
            "/t/info",
            "/t/info[informal='first text']",
            "/t/info[informal='second text']",
            "/t/parents[type='Root']",
            "/t/mentioned[where='2']",
            "/t/mentioned[where='1']",
            "/t/slots/slot[type='Emp']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:28,代码来源:XeTypeTest.java


示例15: manipulatesWithProperty

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeSlot can do slot manipulations.
 * @throws Exception When necessary
 */
@Test
public void manipulatesWithProperty() throws Exception {
    final Directives dirs = new Directives().add("p");
    final Slot slot = new XeSlot(dirs, "/p");
    slot.explain("first text");
    slot.explain("second text");
    slot.assign("Employee");
    slot.mention(2);
    slot.mention(1);
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(dirs).xml()),
        XhtmlMatchers.hasXPaths(
            "/p/info",
            "/p/info[informal='first text']",
            "/p/info[informal='second text']",
            "/p[type='Employee']",
            "/p/mentioned[where='2']",
            "/p/mentioned[where='1']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:26,代码来源:XeSlotTest.java


示例16: manipulatesWithMethod

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeMethod can do type manipulations.
 * @throws Exception When necessary
 */
@Test
public void manipulatesWithMethod() throws Exception {
    final Directives dirs = new Directives().add("m");
    final Method method = new XeMethod(dirs, "/m");
    method.sign("\"informal one\"");
    method.binding("emp", "Employee");
    method.binding("one", "One");
    method.result("emp1");
    method.object("myself");
    method.mention(2);
    method.mention(1);
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(dirs).xml()),
        XhtmlMatchers.hasXPaths(
            "/m[signature='\"informal one\"']",
            "/m[result='emp1']",
            "/m[object='myself']",
            "/m/bindings/binding[name='emp' and type='Employee']",
            "/m/bindings/binding[name='one' and type='One']",
            "/m/mentioned[where='2']",
            "/m/mentioned[where='1']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:29,代码来源:XeMethodTest.java


示例17: setsAttributes

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeMethod can set attributes.
 * @throws Exception When necessary
 */
@Test
public void setsAttributes() throws Exception {
    final Directives dirs = new Directives().add("x");
    final Method method = new XeMethod(dirs, "/x");
    final String name = "attr-1";
    method.attribute(name, "");
    method.attribute(name, "ffa7ed");
    method.attribute("another", "123456");
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(dirs).xml()),
        XhtmlMatchers.hasXPaths(
            "/x/attributes[count(attribute)=2]",
            "/x/attributes[attribute='attr-1' and attribute='another']",
            "/x/attributes/attribute[.='attr-1' and @seal='ffa7ed']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:22,代码来源:XeMethodTest.java


示例18: createsNfr

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeMethod can create NFR.
 * @throws Exception When necessary
 */
@Test
public void createsNfr() throws Exception {
    final Directives dirs = new Directives().add("xx");
    final Method method = new XeMethod(dirs, "/xx");
    final String name = "PERF";
    method.nfr(name).explain("how are you?");
    method.nfr(name).explain("very good");
    method.nfr("UX");
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(dirs).xml()),
        XhtmlMatchers.hasXPaths(
            "/xx/nfrs[count(nfr)=2]",
            "/xx/nfrs/nfr[id='PERF']",
            "/xx/nfrs/nfr[id='UX']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:22,代码来源:XeMethodTest.java


示例19: avoidsDuplicateBindings

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeFlow can avoid duplicate bindings.
 * @throws Exception When necessary
 */
@Test
public void avoidsDuplicateBindings() throws Exception {
    final Directives dirs = new Directives().add("f1");
    final Flow flow = new XeFlow(dirs, "/f1");
    for (int idx = 0; idx < Tv.FIVE; ++idx) {
        flow.binding("a", "alpha");
    }
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(dirs).xml()),
        XhtmlMatchers.hasXPaths(
            "/f1/bindings[count(binding)=1]",
            "/f1/bindings/binding[name='a' and type='alpha']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:20,代码来源:XeFlowTest.java


示例20: modifiesDom

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * Xembler can modify DOM.
 * @throws Exception If some problem inside
 */
@Test
@SuppressWarnings("PMD.InsufficientStringBufferDeclaration")
public void modifiesDom() throws Exception {
    final StringBuilder program = new StringBuilder(Tv.THOUSAND)
        .append("ADD 'root';");
    for (int idx = 0; idx < Tv.FIFTY * Tv.THOUSAND; ++idx) {
        program.append(
            "XPATH '/root'; ADDIF 'node';ADD 'temp'; REMOVE;SET '"
        ).append(idx).append("';");
    }
    final Directives dirs = new Directives(program.toString());
    final Document dom = DocumentBuilderFactory.newInstance()
        .newDocumentBuilder().newDocument();
    new Xembler(dirs).apply(dom);
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(dom),
        XhtmlMatchers.hasXPath("/root/node[.='49999']")
    );
}
 
开发者ID:yegor256,项目名称:xembly,代码行数:24,代码来源:XemblerProf.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MessageListenerConcurrently类代码示例发布时间:2022-05-21
下一篇:
Java RelTraitSet类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap