Package org.xembly

Examples of org.xembly.Directives


    private MkRepoCommit commit(
        @NotNull(message = "json can't be NULL") final JsonObject json
    ) throws IOException {
        final String sha = fakeSha();
        // @checkstyle MultipleStringLiterals (40 lines)
        final Directives commit = new Directives().xpath(this.commitXpath())
            .add("commit")
            .add("sha").set(sha).up()
            .add("url").set("http://localhost/4").up()
            .add("html_url").set("http://localhost/5").up()
            .add("message").set(json.getString("message")).up();
        if (json.containsKey("committer")) {
            final JsonObject committer = json.getJsonObject("committer");
            commit.add("committer")
                .add("email").set(committer.getString("email")).up()
                .add("name").set(committer.getString("name")).up();
        }
        if (json.containsKey("author")) {
            final JsonObject author = json.getJsonObject("author");
            commit.add("author")
                .add("email").set(author.getString("email")).up()
                .add("name").set(author.getString("name")).up();
        }
        this.storage.apply(commit);
        return new MkRepoCommit(this.storage, this.repo(), sha);
View Full Code Here


    )
        throws IOException {
        this.storage = stg;
        this.self = login;
        this.storage.apply(
            new Directives().xpath("/github").addIf("orgs")
        );
    }
View Full Code Here

    public Organization get(
        @NotNull(message = "login is never NULl") final String login
    ) {
        try {
            this.storage.apply(
                new Directives().xpath(
                    String.format("/github/orgs[not(org[login='%s'])]", login)
                ).add("org").add("login").set(login)
            );
        } catch (final IOException ex) {
            throw new IllegalStateException(ex);
View Full Code Here

        @NotNull(message = "login can't be NULL") final String login
    ) throws IOException {
        this.storage = stg;
        this.self = login;
        this.storage.apply(
            new Directives().xpath("/github").addIf("gists")
        );
    }
View Full Code Here

            number = Integer.toString(
                1 + this.storage.xml().xpath(
                    String.format("%s/gist/id/text()", this.xpath())
                ).size()
            );
            final Directives dirs = new Directives().xpath(this.xpath())
                .add("gist")
                .add("id").set(number).up()
                .add("public").set(String.valueOf(visible)).up()
                .add("files");
            for (final Map.Entry<String, String> file : files.entrySet()) {
                dirs.add("file")
                    .add("filename").set(file.getKey()).up()
                    .add("raw_content").set(file.getValue()).up().up();
            }
            this.storage.apply(dirs);
        } finally {
View Full Code Here

    @Override
    public void remove(@NotNull(message = "identifier should not be NULL")
        final String identifier
    ) throws IOException {
        this.storage.apply(
            new Directives().xpath(
                String.format("%s/gist[id='%s']", this.xpath(), identifier)
            ).remove()
        );
    }
View Full Code Here

        @NotNull(message = "login can't be NULL") final String login
    ) throws IOException {
        this.storage = stg;
        this.self = login;
        this.storage.apply(
            new Directives().xpath(this.userXpath()).addIf("emails")
        );
    }
View Full Code Here

    public Iterable<String> add(
        @NotNull(message = "emails can't be NULL") final Iterable<String> emails
    ) throws IOException {
        this.storage.lock();
        try {
            final Directives directives = new Directives().xpath(this.xpath());
            for (final String email : emails) {
                directives.add("email").set(email).up();
            }
            this.storage.apply(directives);
        } finally {
            this.storage.unlock();
        }
View Full Code Here

    @Override
    public void remove(
        @NotNull(message = "emails should not be NULL")
        final Iterable<String> emails
    ) throws IOException {
        final Directives directives = new Directives();
        for (final String email : emails) {
            directives.xpath(
                String.format("%s/email[.='%s']", this.xpath(), email)
            ).remove();
        }
        this.storage.apply(directives);
    }
View Full Code Here

        @NotNull(message = "content should nto be NULL") final String content
    )
        throws IOException {
        this.storage.apply(
            // @checkstyle MultipleStringLiterals (3 lines)
            new Directives().xpath(this.xpath()).xpath(
                String.format("files[not(file[filename='%s'])]", file)
            ).add("file").add("filename").set(file).up().add("raw_content")
        );
        this.storage.apply(
            new Directives().xpath(this.xpath()).xpath(
                String.format(
                    "files/file[filename='%s']/raw_content",
                    file
                )
            ).set(content)
View Full Code Here

TOP

Related Classes of org.xembly.Directives

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.