Package chaschev.lang

Examples of chaschev.lang.OpenStringBuilder


            throw Exceptions.runtime(e);
        }
    }

    protected String getHosts() {
        OpenStringBuilder sb = new OpenStringBuilder();
        List<String> numbers = Lists.newArrayList("u-1", "u-2", "u-3");

        for (int i = 0; i < hosts.size(); i++) {
            addQuick(sb, numbers.get(i), Joiner.on(", ").join(hosts.subList(0, i + 1)));
        }

        addQuick(sb, "all", Joiner.on(", ").join(hosts));

        sb.setLength(sb.length() - 1);

        return sb.toString();
    }
View Full Code Here


        @Override
        public VcsLogInfo parse(String script, String s) {
            List<VcsLogInfo.LogEntry> entries = new ArrayList<VcsLogInfo.LogEntry>();

            OpenStringBuilder comment = new OpenStringBuilder(256);

            for (PeekingIterator<String> it = peekingIterator(Splitter.on("\n").trimResults().split(s).iterator()); it.hasNext(); ) {
                String line;

                String revision = null;

                for(line = it.next();it.hasNext();line=it.next()){
                    if(line.startsWith("commit")) {
                        revision = substringAfter(line, " ").trim();
                        Matcher matcher = HASH_REGEX.matcher(revision);
                        if(matcher.matches()){
                            break;
                        }
                    }
                }

                if(revision == null) break;

                while(it.hasNext() && !it.peek().contains("Author: ")) it.next();
                String author = substringAfter(it.next(), "Author: ");
                String stringDate = substringAfter(it.next(), "Date: ").trim();
                DateTime date = DateTime.parse(stringDate, GIT_DATE_FORMAT);

                it.next(); //empty line

                comment.setLength(0);

                while (it.hasNext()) {
                    line = it.peek();
                    String possibleRevision = substringAfter(line, " ");

                    if (HASH_REGEX.matcher(possibleRevision).matches()) {
                        break;
                    }

                    comment.append(it.next()).append("\n");
                }

                comment.trim();

                entries.add(new VcsLogInfo.LogEntry(date, author, comment.toString(), revision));
            }

            return new VcsLogInfo(s, entries);

        }
View Full Code Here

    }

    public static <T extends TaskResult> TaskResult<?> and(Iterable<T> results) {
        TaskResult<?> last = TaskResult.OK;

        OpenStringBuilder sb = new OpenStringBuilder();

        Throwable lastException = null;

        boolean ok = true;

        for (TaskResult<?> result : results) {
            last = result;
            if (!result.ok()) {
                ok = false;

                if (result.exception.isPresent()) {
                    lastException = result.exception.get();
                    sb.append(result.exception.get().toString()).append("\n");
                }
            }
        }

        if (ok) return last;

        Exception ex = new Exception(sb.trim().toString());

        if (lastException != null) {
            ex.setStackTrace(lastException.getStackTrace());
        }
View Full Code Here

    public String firstLineAsText(){
        return lines.isEmpty() ? "<empty>" : lines.get(0).asText(false);
    }

    public String asTextScript() {
        OpenStringBuilder sb = new OpenStringBuilder();

        for (CommandLine<T, CHILD> line : lines) {
            sb.append(line.asText(true)).trim();
            if(sb.charAt(sb.length() - 1) != ';') {
                sb.append(";\n");
            }else{
                sb.append('\n');
            }
        }

        return sb.trim().toString();
    }
View Full Code Here

TOP

Related Classes of chaschev.lang.OpenStringBuilder

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.