Example usage for org.eclipse.jgit.lib StoredConfig getInt

List of usage examples for org.eclipse.jgit.lib StoredConfig getInt

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib StoredConfig getInt.

Prototype

public int getInt(final String section, String subsection, final String name, final int defaultValue) 

Source Link

Document

Obtain an integer value from the configuration.

Usage

From source file:com.microsoft.gittf.core.config.ChangesetCommitMap.java

License:Open Source License

private static void copyConfigurationEntries(StoredConfig source, FileBasedConfig target) {
    Set<String> downloadedChangesetEntries = source.getNames(ConfigurationConstants.CONFIGURATION_SECTION,
            ConfigurationConstants.COMMIT_SUBSECTION);

    for (String changesetEntry : downloadedChangesetEntries) {
        String commitHash = source.getString(ConfigurationConstants.CONFIGURATION_SECTION,
                ConfigurationConstants.COMMIT_SUBSECTION, changesetEntry);

        target.setString(ConfigurationConstants.CONFIGURATION_SECTION, ConfigurationConstants.COMMIT_SUBSECTION,
                changesetEntry, commitHash);
    }/*from www.j av a2 s  .c o m*/

    Set<String> createdCommitEntries = source.getNames(ConfigurationConstants.CONFIGURATION_SECTION,
            ConfigurationConstants.CHANGESET_SUBSECTION);

    for (String commitEntry : createdCommitEntries) {
        int changesetId = source.getInt(ConfigurationConstants.CONFIGURATION_SECTION,
                ConfigurationConstants.CHANGESET_SUBSECTION, commitEntry, -1);

        target.setInt(ConfigurationConstants.CONFIGURATION_SECTION, ConfigurationConstants.CHANGESET_SUBSECTION,
                commitEntry, changesetId);
    }

    source.unsetSection(ConfigurationConstants.CONFIGURATION_SECTION,
            ConfigurationConstants.CHANGESET_SUBSECTION);
    source.unsetSection(ConfigurationConstants.CONFIGURATION_SECTION, ConfigurationConstants.COMMIT_SUBSECTION);

    try {
        target.save();
        source.save();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}