Java 类org.apache.commons.configuration.HierarchicalINIConfiguration 实例源码

项目:ipst    文件:EurostagImpactAnalysis.java   
private void writeWp43Configs(List<Contingency> contingencies, Path workingDir) throws IOException, ConfigurationException {
    Path baseWp43ConfigFile = PlatformConfig.defaultConfig().getConfigDir().resolve(WP43_CONFIGS_FILE_NAME);

    // generate one variant of the base config for all the contingency
    // this allow to add extra variables for some indexes
    HierarchicalINIConfiguration configuration = new HierarchicalINIConfiguration(baseWp43ConfigFile.toFile());
    SubnodeConfiguration node = configuration.getSection("smallsignal");
    node.setProperty("f_instant", parameters.getFaultEventInstant());
    for (int i = 0; i < contingencies.size(); i++) {
        Contingency contingency = contingencies.get(i);
        if (contingency.getElements().isEmpty()) {
            throw new AssertionError("Empty contingency " + contingency.getId());
        }
        Iterator<ContingencyElement> it = contingency.getElements().iterator();
        // compute the maximum fault duration
        double maxDuration = getFaultDuration(contingency, it.next());
        while (it.hasNext()) {
            maxDuration = Math.max(maxDuration, getFaultDuration(contingency, it.next()));
        }
        node.setProperty("f_duration", maxDuration);
        Path wp43Config = workingDir.resolve(WP43_CONFIGS_PER_FAULT_FILE_NAME.replace(Command.EXECUTION_NUMBER_PATTERN, Integer.toString(i)));
        try (Writer writer = Files.newBufferedWriter(wp43Config, StandardCharsets.UTF_8)) {
            configuration.save(writer);
        }
    }
}
项目:yfiton    文件:Yfiton.java   
protected Yfiton(Notifier notifier, HierarchicalINIConfiguration configuration, boolean displayStackTraces) throws ConversionException {
    this.configurationParameters = loadPreferences(configuration, notifier);
    this.displayStackTraces = displayStackTraces;

    configurationFilePath = configuration.getFile().getAbsolutePath();

    if (log.isTraceEnabled()) {
        if (!Files.exists(Paths.get(configurationFilePath))) {
            log.trace("No configuration file detected in '{}'", configurationFilePath);
        } else {
            log.trace("Configuration loaded from '{}': {}", configurationFilePath, configurationParameters);
        }
    }

    this.notifier = notifier;
    this.supportedParameters = AnnotationProcessor.analyze(ImmutableSet.of(notifier));
}
项目:yfiton    文件:YfitonBuilder.java   
public Yfiton build() throws ConversionException, ConfigurationException {
    Notifier notifier = this.notifier;

    if (notifier == null) {
        notifier = resolve(this.notifierKey);
    }

    if (configurationFile == null) {
        try {
            configurationFile = Configuration.getNotifierConfigurationFilePath(notifier.getKey());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    HierarchicalINIConfiguration hierarchicalConfiguration =
            new HierarchicalINIConfiguration(configurationFile.toFile());

    return new Yfiton(notifier, hierarchicalConfiguration, displayStackTraces);
}
项目:yfiton    文件:SlackNotifier.java   
@Override
protected void storeAccessTokenData(AccessTokenData accessTokenData, HierarchicalINIConfiguration configuration) throws NotificationException {
    String teamId = accessTokenData.get("teamId");
    configuration.setProperty(KEY_DEFAULT_TEAM_ID, teamId);

    SubnodeConfiguration section = configuration.getSection(teamId);

    section.setProperty(KEY_ACCESS_TOKEN, accessTokenData.getAccessToken());
    for (Map.Entry<String, String> entry : accessTokenData.getData()) {
        section.setProperty(entry.getKey(), entry.getValue());
    }

    try {
        configuration.save();
    } catch (ConfigurationException e) {
        throw new NotificationException(e);
    }
}
项目:StatsAgg    文件:HierarchicalIniConfigurationWrapper.java   
private void readHierarchicalIniConfigurationFile(File hierarchicalIniFile) {

    if (hierarchicalIniFile == null) {
        return;
    }

    try {
        if (hierarchicalIniFile.exists()) {
            configurationDirectory_ = hierarchicalIniFile.getParent();
            configurationFilename_ = hierarchicalIniFile.getName();

            hierarchicalIniConfiguration_ = new HierarchicalINIConfiguration();
            hierarchicalIniConfiguration_.setDelimiterParsingDisabled(true);
            hierarchicalIniConfiguration_.setAutoSave(false);
            hierarchicalIniConfiguration_.load(hierarchicalIniFile);
        }
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));

        configurationDirectory_ = null;
        configurationFilename_ = null;
        hierarchicalIniConfiguration_ = null;
    }
}
项目:StatsAgg    文件:HierarchicalIniConfigurationWrapper.java   
private void readHierarchicalIniConfigurationFile(InputStream configurationInputStream) {

    if (configurationInputStream == null) {
        return;
    }

    try {
        configurationInputStream_ = configurationInputStream;

        hierarchicalIniConfiguration_ = new HierarchicalINIConfiguration();
        hierarchicalIniConfiguration_.setDelimiterParsingDisabled(true);
        hierarchicalIniConfiguration_.setAutoSave(false);
        hierarchicalIniConfiguration_.load(configurationInputStream, null);
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));

        configurationInputStream_ = null;
        hierarchicalIniConfiguration_ = null;
    }
}
项目:incubator-taverna-language    文件:Bundles.java   
public static URI getReference(Path path) throws IOException {
    if (path == null || isMissing(path))
        return null;
    if (!isReference(path))
        throw new IllegalArgumentException("Not a reference: " + path);
    // Note: Latin1 is chosen here because it would not bail out on
    // "strange" characters. We actually parse the URL as ASCII
    path = withExtension(path, DOT_URL);
    try (BufferedReader r = newBufferedReader(path, LATIN1)) {
        HierarchicalINIConfiguration ini = new HierarchicalINIConfiguration();
        ini.load(r);

        String urlStr = ini.getSection(INI_INTERNET_SHORTCUT).getString(
                INI_URL);

        // String urlStr = ini.get(INI_INTERNET_SHORTCUT, INI_URL);
        if (urlStr == null)
            throw new IOException("Invalid/unsupported URL format: " + path);
        return URI.create(urlStr);
    } catch (ConfigurationException e) {
        throw new IOException("Can't parse reference: " + path, e);
    }
}
项目:yfiton    文件:Yfiton.java   
protected Yfiton(Notifier notifier, HierarchicalINIConfiguration configuration, boolean displayStackTraces) throws ConversionException {
    this.configurationParameters = loadPreferences(configuration, notifier);
    this.displayStackTraces = displayStackTraces;

    configurationFilePath = configuration.getFile().getAbsolutePath();

    if (log.isTraceEnabled()) {
        if (!Files.exists(Paths.get(configurationFilePath))) {
            log.trace("No configuration file detected in '{}'", configurationFilePath);
        } else {
            log.trace("Configuration loaded from '{}': {}", configurationFilePath, configurationParameters);
        }
    }

    this.notifier = notifier;
    this.supportedParameters = AnnotationProcessor.analyze(ImmutableSet.of(notifier));
}
项目:yfiton    文件:YfitonBuilder.java   
public Yfiton build() throws ConversionException, ConfigurationException {
    Notifier notifier = this.notifier;

    if (notifier == null) {
        notifier = resolve(this.notifierKey);
    }

    if (configurationFile == null) {
        try {
            configurationFile = Configuration.getNotifierConfigurationFilePath(notifier.getKey());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    HierarchicalINIConfiguration hierarchicalConfiguration =
            new HierarchicalINIConfiguration(configurationFile.toFile());

    return new Yfiton(notifier, hierarchicalConfiguration, displayStackTraces);
}
项目:yfiton    文件:SlackNotifier.java   
@Override
protected void storeAccessTokenData(AccessTokenData accessTokenData, HierarchicalINIConfiguration configuration) throws NotificationException {
    String teamId = accessTokenData.get("teamId");
    configuration.setProperty(KEY_DEFAULT_TEAM_ID, teamId);

    SubnodeConfiguration section = configuration.getSection(teamId);

    section.setProperty(KEY_ACCESS_TOKEN, accessTokenData.getAccessToken());
    for (Map.Entry<String, String> entry : accessTokenData.getData()) {
        section.setProperty(entry.getKey(), entry.getValue());
    }

    try {
        configuration.save();
    } catch (ConfigurationException e) {
        throw new NotificationException(e);
    }
}
项目:StatsPoller    文件:HierarchicalIniConfigurationWrapper.java   
private void readHierarchicalIniConfigurationFile(File hierarchicalIniFile) {

    if (hierarchicalIniFile == null) {
        return;
    }

    try {
        if (hierarchicalIniFile.exists()) {
            configurationDirectory_ = hierarchicalIniFile.getParent();
            configurationFilename_ = hierarchicalIniFile.getName();

            hierarchicalIniConfiguration_ = new HierarchicalINIConfiguration();
            hierarchicalIniConfiguration_.setDelimiterParsingDisabled(true);
            hierarchicalIniConfiguration_.setAutoSave(false);
            hierarchicalIniConfiguration_.load(hierarchicalIniFile);
        }
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));

        configurationDirectory_ = null;
        configurationFilename_ = null;
        hierarchicalIniConfiguration_ = null;
    }
}
项目:StatsPoller    文件:HierarchicalIniConfigurationWrapper.java   
private void readHierarchicalIniConfigurationFile(InputStream configurationInputStream) {

    if (configurationInputStream == null) {
        return;
    }

    try {
        configurationInputStream_ = configurationInputStream;

        hierarchicalIniConfiguration_ = new HierarchicalINIConfiguration();
        hierarchicalIniConfiguration_.setDelimiterParsingDisabled(true);
        hierarchicalIniConfiguration_.setAutoSave(false);
        hierarchicalIniConfiguration_.load(configurationInputStream, null);
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));

        configurationInputStream_ = null;
        hierarchicalIniConfiguration_ = null;
    }
}
项目:settings4j    文件:ConfigurationToConnectorAdapterTest.java   
@Test
public void testAdapterINIConfigWithSlashDelimiter() throws Exception {
    final Settings4jRepository testSettings = createSimpleSettings4jConfig();

    // start test => create adapter and add to Settings4jRepository
    final HierarchicalINIConfiguration configuration = addINIConfiguration(//
        testSettings, "myIniConfigConnector", "iniConfigWithSlashDelimiter.ini", "/");

    // configure some values
    configuration.setProperty(TEST_VALUE_KEY, "Hello Windows World");
    configuration.save();

    // validate result
    assertThat(testSettings.getSettings().getString(TEST_VALUE_KEY), is("Hello Windows World"));


    final Set<String> sections = configuration.getSections();
    assertThat(sections, hasSize(1));
    // The HierarchicalINIConfiguration implementation uses only the first child elements as sections.
    assertThat(sections.iterator().next(), is("com"));

}
项目:settings4j    文件:ConfigurationToConnectorAdapterTest.java   
@Test
public void testAdapterINIConfigWithDefaultDelimiterAndDotValue() throws Exception {
    final Settings4jRepository testSettings = createSimpleSettings4jConfig();

    // start test => create adapter and add to Settings4jRepository
    final HierarchicalINIConfiguration configuration = addINIConfiguration(//
        testSettings, "myIniConfigConnector", "iniConfigWithDefaultDelimiter.ini", ".");

    // configure some values
    configuration.setProperty(TEST_VALUE_KEY, "Hello Windows World");
    configuration.save();

    // validate result
    assertThat(testSettings.getSettings().getString(TEST_VALUE_KEY), is("Hello Windows World"));


    final Set<String> sections = configuration.getSections();
    assertThat(sections, hasSize(1));
    assertThat(sections.iterator().next(), is("com/myProject/myModule/myTestValue"));

}
项目:settings4j    文件:ConfigurationToConnectorAdapterTest.java   
@Test
public void testAdapterINIConfigWithDefaultDelimiterWithoutDotValue() throws Exception {
    String testValueKey = "com/myProject/myModule/myTestValue";
    final Settings4jRepository testSettings = createSimpleSettings4jConfig();

    // start test => create adapter and add to Settings4jRepository
    final HierarchicalINIConfiguration configuration = addINIConfiguration(//
        testSettings, "myIniConfigConnector", "iniConfigWithDefaultDelimiter.ini", ".");

    // configure some values
    configuration.setProperty(testValueKey, "Hello Windows World");
    configuration.save();

    // validate result
    assertThat(testSettings.getSettings().getString(testValueKey), is("Hello Windows World"));


    final Set<String> sections = configuration.getSections();
    assertThat(sections, hasSize(1));
    assertThat(sections.iterator().next(), is(nullValue())); // Global Config

}
项目:settings4j    文件:ConfigurationToConnectorAdapterTest.java   
private HierarchicalINIConfiguration addINIConfiguration(final Settings4jRepository testSettings,
        final String connectorName, final String fileName, final String propertyDelimiter)
        throws ConfigurationException {
    ConfigurationToConnectorAdapter connector = (ConfigurationToConnectorAdapter) testSettings.getSettings()//
        .getConnector(connectorName);
    if (connector == null) {
        final File iniConfig = new File(TestUtils.getTestFolder(), "helper/configuration/" + fileName);
        iniConfig.delete();
        HierarchicalINIConfiguration configuration = new HierarchicalINIConfiguration(iniConfig);
        final DefaultExpressionEngine expressionEngine = new DefaultExpressionEngine();
        expressionEngine.setPropertyDelimiter(propertyDelimiter);
        configuration.setExpressionEngine(expressionEngine);

        connector = new ConfigurationToConnectorAdapter(connectorName, configuration);

        testSettings.getSettings().addConnector(//
            connector, ConnectorPositions.afterLast(SystemPropertyConnector.class));

    }
    return (HierarchicalINIConfiguration) connector.getConfiguration();
}
项目:zayf    文件:ServerProxyImpl.java   
private void loadZanataUserConfig()
{
   File userConfig = new File(System.getProperty("user.home"), DEFAULT_CONFIG_LOCATION);
   System.out.println("Config file: " + userConfig.getAbsolutePath());
   try
   {
      HierarchicalINIConfiguration config = new HierarchicalINIConfiguration(userConfig);
      SubnodeConfiguration serverConfig = config.getSection("servers");
      DataConfiguration dataConfig = new DataConfiguration(serverConfig);
      servers = getServerList(dataConfig);
   }
   catch (ConfigurationException e)
   {
      System.out.println("Failed to load configuration from " + userConfig.getAbsolutePath());
      e.printStackTrace();
   }
}
项目:ipst    文件:DymolaAdaptersMatParamsWriter.java   
public DymolaAdaptersMatParamsWriter(HierarchicalINIConfiguration configuration)  {
    if (configuration == null) {
        throw new RuntimeException("null config");
    }
    this.configuration = configuration;
    //this below will simply log parameters ..
    for (String section : configuration.getSections()) {
        SubnodeConfiguration node = configuration.getSection(section);
        List<String> paramsSummary = StreamSupport.stream(
                Spliterators.spliteratorUnknownSize(node.getKeys(),
                        Spliterator.ORDERED), false).map(p -> p + "=" + node.getString(p)).collect(Collectors.<String>toList());
        LOGGER.info("index {}: {}", section, paramsSummary);
    }
}
项目:yfiton    文件:OAuthNotifier.java   
protected void storeAccessTokenData(AccessTokenData accessTokenData, HierarchicalINIConfiguration configuration) throws NotificationException {
    configuration.setProperty(KEY_ACCESS_TOKEN, accessTokenData.getAccessToken());

    for (Map.Entry<String, String> entry : accessTokenData.getData()) {
        configuration.setProperty(entry.getKey(), entry.getValue());
    }

    try {
        configuration.save();
    } catch (ConfigurationException e) {
        throw new NotificationException(e);
    }
}
项目:yfiton    文件:Yfiton.java   
private Map<String, Map<String, String>> loadPreferences(HierarchicalINIConfiguration configuration, Notifier notifier) {
    Set<String> sections = configuration.getSections();

    return sections.stream().filter(isEqual(null).negate().and(section -> notifier.getKey().equals(section)))
            .collect(Collectors.toMap(Function.identity(),
                    section -> configuration.getSection(section).
                            getRootNode().getChildren().stream().collect(
                            Collectors.toMap(ConfigurationNode::getName, node -> (String) node.getValue()))));
}
项目:yfiton    文件:Notifier.java   
public Notifier() {
    try {
        configuration = new HierarchicalINIConfiguration(getConfigurationFilePath().toFile());
    } catch (ConfigurationException | IOException e) {
        log.warn(e.getMessage(), e);
    }
}
项目:yfiton    文件:PushbulletNotifier.java   
private String getAccessToken() throws NotificationException {
    HierarchicalINIConfiguration configuration = getConfiguration();

    if (accessToken != null) {
        return accessToken;
    }

    return configuration.getString(KEY_ACCESS_TOKEN);
}
项目:cwlavro    文件:Utilities.java   
public static HierarchicalINIConfiguration parseConfig(String path) {
    try {
        return new HierarchicalINIConfiguration(path);
    } catch (ConfigurationException ex) {
        throw new RuntimeException("Could not read ~/.dockstore/config");
    }
}
项目:StatsAgg    文件:HierarchicalIniConfigurationWrapper.java   
private void readHierarchicalIniConfigurationFile(String filePathAndFilename) {

    if (filePathAndFilename == null) {
        return;
    }

    try {
        File hierarchicalIniConfigurationFile_ = new File(filePathAndFilename);
        boolean doesFileExist = FileIo.doesFileExist(filePathAndFilename);

        if (doesFileExist) {
            configurationDirectory_ = hierarchicalIniConfigurationFile_.getParent();
            configurationFilename_ = hierarchicalIniConfigurationFile_.getName();

            hierarchicalIniConfiguration_ = new HierarchicalINIConfiguration();
            hierarchicalIniConfiguration_.setDelimiterParsingDisabled(true);
            hierarchicalIniConfiguration_.setAutoSave(false);
            hierarchicalIniConfiguration_.load(hierarchicalIniConfigurationFile_);
        }
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));

        configurationDirectory_ = null;
        configurationFilename_ = null;
        hierarchicalIniConfiguration_ = null;
    }
}
项目:StatsAgg    文件:HierarchicalIniConfigurationWrapper.java   
public static void saveHierarchicalIniConfigurationFile(String filePath, String filename, HierarchicalINIConfiguration hierarchicalIniConfiguration) {
    try {
        File hierarchicalIniConfigurationFile = new File(filePath + File.separator + filename);
        hierarchicalIniConfiguration.save(hierarchicalIniConfigurationFile);
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
    }
}
项目:StatsAgg    文件:HierarchicalIniConfigurationWrapper.java   
public static void saveHierarchicalIniConfigurationFile(File hierarchicalIniConfigurationFile, HierarchicalINIConfiguration hierarchicalIniConfiguration) {
    try {
        hierarchicalIniConfiguration.save(hierarchicalIniConfigurationFile);
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
    }
}
项目:StatsAgg    文件:HierarchicalIniConfigurationWrapper.java   
public static String saveHierarchicalIniConfigurationToString(HierarchicalINIConfiguration hierarchicalIniConfiguration) {
    try {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        hierarchicalIniConfiguration.save(byteArrayOutputStream);
        return byteArrayOutputStream.toString();
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
        return null;
    }
}
项目:yfiton    文件:OAuthNotifier.java   
protected void storeAccessTokenData(AccessTokenData accessTokenData, HierarchicalINIConfiguration configuration) throws NotificationException {
    configuration.setProperty(KEY_ACCESS_TOKEN, accessTokenData.getAccessToken());

    for (Map.Entry<String, String> entry : accessTokenData.getData()) {
        configuration.setProperty(entry.getKey(), entry.getValue());
    }

    try {
        configuration.save();
    } catch (ConfigurationException e) {
        throw new NotificationException(e);
    }
}
项目:yfiton    文件:Yfiton.java   
private Map<String, Map<String, String>> loadPreferences(HierarchicalINIConfiguration configuration, Notifier notifier) {
    Set<String> sections = configuration.getSections();

    return sections.stream().filter(isEqual(null).negate().and(section -> notifier.getKey().equals(section)))
            .collect(Collectors.toMap(Function.identity(),
                    section -> configuration.getSection(section).
                            getRootNode().getChildren().stream().collect(
                            Collectors.toMap(ConfigurationNode::getName, node -> (String) node.getValue()))));
}
项目:yfiton    文件:Notifier.java   
public Notifier() {
    try {
        configuration = new HierarchicalINIConfiguration(getConfigurationFilePath().toFile());
    } catch (ConfigurationException | IOException e) {
        log.warn(e.getMessage(), e);
    }
}
项目:yfiton    文件:PushbulletNotifier.java   
private String getAccessToken() throws NotificationException {
    HierarchicalINIConfiguration configuration = getConfiguration();

    if (accessToken != null) {
        return accessToken;
    }

    return configuration.getString(KEY_ACCESS_TOKEN);
}
项目:ANDS-Vocabs-Toolkit    文件:PropertyRewriterTransformProvider.java   
/** Loads the rewrite map into metadataRewriteConf.
 * @return True if loading was successful. */
private boolean loadRewriteMap() {
    File metadataRewriteMap = new File(METADATA_REWRITE_MAP_PATH);
    try {
        metadataRewriteConf = new HierarchicalINIConfiguration(
                metadataRewriteMap);
        return true;
    } catch (ConfigurationException e) {
        logger.error("Toolkit.metadataRewriteMapPath is empty, or file"
                + " can not be loaded", e);
        return false;
    }
}
项目:ANDS-Vocabs-Toolkit    文件:PropertyRewriterTransformProvider.java   
/** Constructor. Initializes the metadata rewrite map.
 * @param aMetadataRewriteConf The rewriting configuration
 * @param aModel The model in which to store triples after
 * rewriting.
 */
ConceptHandler(
        final HierarchicalINIConfiguration aMetadataRewriteConf,
        final Model aModel) {
    metadataRewriteConf = aMetadataRewriteConf;
    model = aModel;
}
项目:ANDS-Vocabs-Toolkit    文件:GetMetadataTransformProvider.java   
/** Loads the rewrite map into metadataRewriteConf. */
private void loadRewriteMap() {
    File metadataRewriteMap = new File(METADATA_REWRITE_MAP_PATH);
    try {
        metadataRewriteConf = new HierarchicalINIConfiguration(
                metadataRewriteMap);
    } catch (ConfigurationException e) {
        logger.error("Toolkit.metadataRewriteMapPath is empty, or file"
                + " can not be loaded", e);
    }
}
项目:StatsPoller    文件:HierarchicalIniConfigurationWrapper.java   
private void readHierarchicalIniConfigurationFile(String filePathAndFilename) {

    if (filePathAndFilename == null) {
        return;
    }

    try {
        File hierarchicalIniConfigurationFile_ = new File(filePathAndFilename);
        boolean doesFileExist = FileIo.doesFileExist(filePathAndFilename);

        if (doesFileExist) {
            configurationDirectory_ = hierarchicalIniConfigurationFile_.getParent();
            configurationFilename_ = hierarchicalIniConfigurationFile_.getName();

            hierarchicalIniConfiguration_ = new HierarchicalINIConfiguration();
            hierarchicalIniConfiguration_.setDelimiterParsingDisabled(true);
            hierarchicalIniConfiguration_.setAutoSave(false);
            hierarchicalIniConfiguration_.load(hierarchicalIniConfigurationFile_);
        }
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));

        configurationDirectory_ = null;
        configurationFilename_ = null;
        hierarchicalIniConfiguration_ = null;
    }
}
项目:StatsPoller    文件:HierarchicalIniConfigurationWrapper.java   
public static void saveHierarchicalIniConfigurationFile(String filePath, String filename, HierarchicalINIConfiguration hierarchicalIniConfiguration) {
    try {
        File hierarchicalIniConfigurationFile = new File(filePath + File.separator + filename);
        hierarchicalIniConfiguration.save(hierarchicalIniConfigurationFile);
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
    }
}
项目:StatsPoller    文件:HierarchicalIniConfigurationWrapper.java   
public static void saveHierarchicalIniConfigurationFile(File hierarchicalIniConfigurationFile, HierarchicalINIConfiguration hierarchicalIniConfiguration) {
    try {
        hierarchicalIniConfiguration.save(hierarchicalIniConfigurationFile);
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
    }
}
项目:StatsPoller    文件:HierarchicalIniConfigurationWrapper.java   
public static String saveHierarchicalIniConfigurationToString(HierarchicalINIConfiguration hierarchicalIniConfiguration) {
    try {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        hierarchicalIniConfiguration.save(byteArrayOutputStream);
        return byteArrayOutputStream.toString();
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
        return null;
    }
}
项目:java-gems    文件:CouchbaseUtils.java   
private HierarchicalINIConfiguration loadIniFile() {
    try {
        HierarchicalINIConfiguration ini = new HierarchicalINIConfiguration(this.iniFile);
        if (ini.isEmpty()) {
            throw new IllegalStateException(CONFIGURATION_ERROR_MSG + " INI file is empty.");
        }
        return ini;
    } catch (Exception ex) {
        throw new IllegalStateException(CONFIGURATION_ERROR_MSG, ex);
    }
}
项目:java-gems    文件:CouchbaseUtils.java   
private CouchbaseClientFactory buildFactory(String key) {
    HierarchicalINIConfiguration ini = this.loadIniFile();
    if (ini.getSections().contains(key)) {
        String bucket = ini.getSection(key).getString(CONFIG_DEFAULT_BUCKET_KEY);
        int opTimeout = ini.getSection(key).getInt(CONFIG_OP_TIMEOUT_KEY);
        List<URI> nodes = new ArrayList<URI>();
        for (String node : ini.getSection(key).getStringArray(CONFIG_NODES_KEY)) {
            nodes.add(URI.create(node));
        }
        return new CouchbaseClientFactory(bucket, nodes, opTimeout, instanceName);
    } else {
        throw new IllegalArgumentException("Section \"" + key + "\" do not exists in file.");
    }
}