Example usage for org.eclipse.jgit.util RawParseUtils decode

List of usage examples for org.eclipse.jgit.util RawParseUtils decode

Introduction

In this page you can find the example usage for org.eclipse.jgit.util RawParseUtils decode.

Prototype

public static String decode(final byte[] buffer, final int start, final int end) 

Source Link

Document

Decode a buffer under UTF-8, if possible.

Usage

From source file:com.google.gerrit.acceptance.HttpResponse.java

License:Apache License

public String getEntityContent() throws IOException {
    Preconditions.checkNotNull(response, "Response is not initialized.");
    Preconditions.checkNotNull(response.getEntity(), "Response.Entity is not initialized.");
    ByteBuffer buf = IO.readWholeStream(response.getEntity().getContent(), 1024);
    return RawParseUtils.decode(buf.array(), buf.arrayOffset(), buf.limit()).trim();
}

From source file:com.google.gerrit.sshd.commands.BaseTestPrologCommand.java

License:Apache License

@Override
protected final void run() throws UnloggedFailure {
    try {/*w  w  w  .jav a 2 s. c o m*/
        RevisionResource revision = revisions.parse(
                changes.parse(TopLevelResource.INSTANCE, IdString.fromUrl(changeId)),
                IdString.fromUrl("current"));
        if (useStdin) {
            ByteBuffer buf = IO.readWholeStream(in, 4096);
            input.rule = RawParseUtils.decode(buf.array(), buf.arrayOffset(), buf.limit());
        }
        Object result = createView().apply(revision, input);
        OutputFormat.JSON.newGson().toJson(result, stdout);
        stdout.print('\n');
    } catch (Exception e) {
        throw new UnloggedFailure("Processing of prolog script failed: " + e);
    }
}

From source file:com.google.gitiles.HtmlDiffFormatter.java

License:Open Source License

@Override
public void format(FileHeader hdr, RawText a, RawText b) throws IOException {
    int start = hdr.getStartOffset();
    int end = hdr.getEndOffset();
    if (!hdr.getHunks().isEmpty()) {
        end = hdr.getHunks().get(0).getStartOffset();
    }//  ww w  . ja v a 2  s. c om
    renderHeader(RawParseUtils.decode(hdr.getBuffer(), start, end));

    if (hdr.getPatchType() == PatchType.UNIFIED) {
        getOutputStream().write(DIFF_BEGIN);
        format(hdr.toEditList(), a, b);
        getOutputStream().write(DIFF_END);
    }
}

From source file:org.eclipse.egit.ui.internal.merge.GitMergeEditorInput.java

License:Open Source License

private String readFile(File directory, String fileName) throws IOException {
    byte[] content = IO.readFully(new File(directory, fileName));
    // strip off the last LF
    int end = content.length;
    while (0 < end && content[end - 1] == '\n')
        end--;//w w  w . j  a  v a2s  .  c o  m
    return RawParseUtils.decode(content, 0, end);
}

From source file:org.eclipse.emf.compare.egit.ui.internal.merge.ModelGitMergeEditorInput.java

License:Open Source License

private String readFile(File directory, String fileName) throws IOException {
    byte[] content = IO.readFully(new File(directory, fileName));
    // strip off the last LF
    int end = content.length;
    while (0 < end && content[end - 1] == '\n') {
        end--;//from w  w w  .j a  va 2  s .  c  o  m
    }
    return RawParseUtils.decode(content, 0, end);
}