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

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

Introduction

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

Prototype

Charset UTF8_CHARSET

To view the source code for org.eclipse.jgit.util RawParseUtils UTF8_CHARSET.

Click Source Link

Document

UTF-8 charset constant.

Usage

From source file:com.gitblit.manager.RepositoryManager.java

License:Apache License

protected void configureJGit() {
    // Configure JGit
    WindowCacheConfig cfg = new WindowCacheConfig();

    cfg.setPackedGitWindowSize(//from   w w w.  j av a  2  s .c  om
            settings.getFilesize(Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
    cfg.setPackedGitLimit(settings.getFilesize(Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
    cfg.setDeltaBaseCacheLimit(
            settings.getFilesize(Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
    cfg.setPackedGitOpenFiles(settings.getInteger(Keys.git.packedGitOpenFiles, cfg.getPackedGitOpenFiles()));
    cfg.setPackedGitMMAP(settings.getBoolean(Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));

    try {
        cfg.install();
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitWindowSize,
                cfg.getPackedGitWindowSize()));
        logger.debug(
                MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.deltaBaseCacheLimit,
                cfg.getDeltaBaseCacheLimit()));
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitOpenFiles,
                cfg.getPackedGitOpenFiles()));
        logger.debug(MessageFormat.format("{0} = {1}", Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));
    } catch (IllegalArgumentException e) {
        logger.error("Failed to configure JGit parameters!", e);
    }

    try {
        // issue-486/ticket-151: UTF-9 & UTF-18
        // issue-560/ticket-237: 'UTF8'
        Field field = RawParseUtils.class.getDeclaredField("encodingAliases");
        field.setAccessible(true);
        Map<String, Charset> encodingAliases = (Map<String, Charset>) field.get(null);
        encodingAliases.put("'utf8'", RawParseUtils.UTF8_CHARSET);
        encodingAliases.put("utf-9", RawParseUtils.UTF8_CHARSET);
        encodingAliases.put("utf-18", RawParseUtils.UTF8_CHARSET);
        logger.info("Alias 'UTF8', UTF-9 & UTF-18 encodings as UTF-8 in JGit");
    } catch (Throwable t) {
        logger.error("Failed to inject UTF-9 & UTF-18 encoding aliases into JGit", t);
    }
}