Example usage for org.eclipse.jgit.lib Constants CHARSET

List of usage examples for org.eclipse.jgit.lib Constants CHARSET

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants CHARSET.

Prototype

Charset CHARSET

To view the source code for org.eclipse.jgit.lib Constants CHARSET.

Click Source Link

Document

Native character encoding for commit messages, file names...

Usage

From source file:org.eclipse.ptp.internal.rdt.sync.git.core.SyncFileTreeIterator.java

License:Open Source License

@Override
protected boolean isEntryIgnored(int pLen) throws IOException {
    int pOff = pathOffset;
    if (0 < pOff)
        pOff--;//from w  ww . j a  va 2 s. c  om
    String p = RawParseUtils.decode(Constants.CHARSET, path, pOff, pLen);
    return filter.shouldIgnore(p, FileMode.TREE.equals(mode));
}

From source file:org.ms123.common.git.FileHolder.java

License:Open Source License

public static byte[] encode(final String str) {
    final ByteBuffer bb = Constants.CHARSET.encode(str);
    final int len = bb.limit();
    if (bb.hasArray() && bb.arrayOffset() == 0) {
        final byte[] arr = bb.array();
        if (arr.length == len)
            return arr;
    }/*w  w  w.  j a  va2 s  . c o m*/
    final byte[] arr = new byte[len];
    bb.get(arr);
    return arr;
}

From source file:org.webcat.core.git.http.InfoRefsRequestHandler.java

License:Open Source License

/**
 * Looks up the requested repository and appends its info/refs to the
 * response./* www  .  ja va2  s.  co  m*/
 *
 * @param request the request
 * @param response the response
 * @throws Exception if an error occurs
 */
public void handleRequest(WORequest request, WOResponse response) throws Exception {
    response.setHeader("text/plain", "Content-Type");

    NSMutableDataOutputStream outputStream = new NSMutableDataOutputStream();

    Repository repo = RepositoryRequestUtils.repositoryFromRequest(request);
    //RevWalk walk = new RevWalk(repo);

    //try
    //{
    //final RevFlag ADVERTISED = walk.newFlag("ADVERTISED");

    final OutputStreamWriter out = new OutputStreamWriter(outputStream, Constants.CHARSET);

    final RefAdvertiser adv = new RefAdvertiser() {
        protected void writeOne(CharSequence line) throws IOException {
            out.append(line.toString().replace(' ', '\t'));
        }

        protected void end() {
            // Do nothing.
        }
    };

    adv.init(repo);
    //adv.init(walk, ADVERTISED);
    adv.setDerefTags(true);

    Map<String, Ref> refs = repo.getAllRefs();
    refs.remove(Constants.HEAD);
    adv.send(refs);
    //}
    //finally
    //{
    //walk.release();
    //}

    outputStream.close();
    response.appendContentData(outputStream.data());
}