List of usage examples for org.apache.commons.configuration Configuration containsKey
boolean containsKey(String key);
From source file:es.udc.gii.common.eaf.plugin.parameter.jade.JADECRAdaptiveParameter.java
@Override public void configure(Configuration conf) { if (conf.containsKey("c")) { this.c = conf.getDouble("c"); } else {/*from www . jav a2 s .c o m*/ ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".c", this.c); w.warn(); } if (conf.containsKey("std_cr")) { this.std_cr = conf.getDouble("std_cr"); } else { ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".std_cr", this.std_cr); w.warn(); } if (conf.containsKey("mu")) { this.mu_cr = conf.getDouble("mu"); } else { ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".mu_cr", this.mu_cr); w.warn(); } }
From source file:es.udc.gii.common.eaf.plugin.parameter.jade.JADEFAdaptiveParameter.java
@Override public void configure(Configuration conf) { if (conf.containsKey("c")) { this.c = conf.getDouble("c"); } else {//from w w w . j a v a 2 s .c om ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".c", this.c); w.warn(); } if (conf.containsKey("std_f")) { this.std_f = conf.getDouble("std_f"); } else { ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".std_f", this.std_f); w.warn(); } if (conf.containsKey("mu")) { this.mu_f = conf.getDouble("mu"); } else { ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".mu_f", this.mu_f); w.warn(); } }
From source file:net.krotscheck.jersey2.configuration.Jersey2ToolkitConfigTest.java
/** * Assert that an unreadable file does not throw an error. * * @throws java.io.IOException File operation errors. *///from www . jav a 2 s. co m @Test public void testUnreadableFile() throws IOException { // Get the prop file and store the old permissions. File propFile = ResourceUtil.getFileForResource("jersey2-toolkit.properties"); Set<PosixFilePermission> oldPerms = Files.getPosixFilePermissions(propFile.toPath()); // Apply writeonly permission set. Set<PosixFilePermission> writeonly = new HashSet<>(); writeonly.add(PosixFilePermission.OWNER_WRITE); writeonly.add(PosixFilePermission.GROUP_WRITE); Files.setPosixFilePermissions(propFile.toPath(), writeonly); // Add something to check System.setProperty("property3", "override3"); // If this throws an error, we've got a problem. Configuration config = new Jersey2ToolkitConfig(); Assert.assertFalse(config.containsKey("property1")); Assert.assertFalse(config.containsKey("property2")); Assert.assertTrue(config.containsKey("property3")); // Apply the correct permissions again Files.setPosixFilePermissions(propFile.toPath(), oldPerms); }
From source file:net.krotscheck.jersey2.configuration.Jersey2ToolkitConfigTest.java
/** * Assert that a missing file does not throw an error. * * @throws java.io.IOException File operation errors. */// ww w.j av a 2 s . c o m @Test public void testMissingFile() throws IOException { // Move the properties file out of the way. File propFile = ResourceUtil.getFileForResource("jersey2-toolkit.properties"); File newPropFile = ResourceUtil.getFileForResource("jersey2-toolkit-mv.properties"); FileUtils.moveFile(propFile, newPropFile); Assert.assertFalse(propFile.exists()); Assert.assertTrue(newPropFile.exists()); // Add something to check System.setProperty("property3", "override3"); // If this throws an error, we've got a problem. Configuration config = new Jersey2ToolkitConfig(); Assert.assertFalse(config.containsKey("property1")); Assert.assertFalse(config.containsKey("property2")); Assert.assertTrue(config.containsKey("property3")); System.clearProperty("property3"); // Move the file back. FileUtils.moveFile(newPropFile, propFile); Assert.assertTrue(propFile.exists()); Assert.assertFalse(newPropFile.exists()); }
From source file:es.bsc.demiurge.monitoring.ganglia.Ganglia.java
public Ganglia() { //read the configuration variables to create the testing VM from the config.properties file Configuration config = Config.INSTANCE.getConfiguration(); if (!config.containsKey(GANGLIA_COLLECTOR_IP) && !config.containsKey(GANGLIA_FRONT_END_PATH) && !config.containsKey(GANGLIA_PORT) && !config.containsKey(GANGLIA_PORT_QUERY)) { throw new RuntimeException("The configuration file " + Config.INSTANCE.getConfigurationFileName() + " must contain the next properties: " + GANGLIA_COLLECTOR_IP + ", " + GANGLIA_FRONT_END_PATH + ", " + GANGLIA_PORT + ", " + GANGLIA_PORT_QUERY); }/* ww w. ja v a2 s . co m*/ this.gangliaCollectorIP = config.getString(GANGLIA_COLLECTOR_IP); this.gangliaPort = config.getInt(GANGLIA_PORT); this.gangliaPortQuery = config.getInt(GANGLIA_PORT_QUERY); this.gangliaFrontEndPath = config.getString(GANGLIA_FRONT_END_PATH); }
From source file:es.udc.gii.common.eaf.algorithm.NSGA2Algorithm.java
@Override public void configure(Configuration conf) { super.configure(conf); try {//w ww .j a va2 s .c o m if (conf.containsKey("ParametersPlugin.Class")) { this.parametersPlugin = ((MultiobjectiveIndividualParametersPlugin) (Class .forName(conf.getString("ParametersPlugin.Class"))).newInstance()); this.parametersPlugin.configure(conf.subset("ParametersPlugin")); } else { this.parametersPlugin = new NSGA2IndividualParametersPlugin(); (new ConfWarning("ParametersPlugin", parametersPlugin.getClass().getCanonicalName())).warn(); } if (conf.containsKey("Ranking.Class")) { this.setRanking((NSGA2Ranking) Class.forName(conf.getString("Ranking.Class")).newInstance()); this.getRanking().configure(conf); } else { this.setRanking(new NSGA2Ranking()); (new ConfWarning("Ranking", "NSGA2Ranking")).warn(); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:es.udc.gii.common.eaf.algorithm.operator.evaluate.LocalSearchOperator.java
@Override public void configure(Configuration conf) { super.configure(conf); try {//from ww w . j a v a2s . com if (conf.containsKey("IndividualImprover.Class")) { this.improver = (IndividualImprover) Class.forName(conf.getString("IndividualImprover.Class")) .newInstance(); this.improver.configure(conf.subset("IndividualImprover")); } if (conf.containsKey("IndividualChooser.Class")) { this.chooser = (IndividualChooser) Class.forName(conf.getString("IndividualChooser.Class")) .newInstance(); this.chooser.configure(conf.subset("IndividualChooser")); } else { this.chooser = new BestIndividual(); } this.evaluateReference = !conf.containsKey("IndividualImprover.DontEvaluateReference"); } catch (Exception ex) { Logger.getLogger(LocalSearchOperator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.mutation.real_code.MichalewiczNonUniformMutation.java
@Override public void configure(Configuration conf) { try {/* w w w .j av a 2s. co m*/ super.configure(conf); if (conf.containsKey("B")) { this.b = conf.getDouble("B"); } if (conf.containsKey("Plugin")) { this.plugin = (StopTestPlugin) Class.forName(conf.getString("Plugin")).newInstance(); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:cz.cas.lib.proarc.common.imports.ImportProfile.java
public Configuration getThumbnailProcessor() { String processor = config.getString(THUMBNAIL_PROCESSOR, "-"); String confId = PROCESSOR + "." + processor; Configuration subset = config.subset(confId); if (!subset.isEmpty() && !subset.containsKey("id")) { subset.addProperty("id", confId); }//from ww w .j a v a 2s . c o m return subset; }
From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.crossover.SBXCrossOver.java
@Override public void configure(Configuration conf) { super.configure(conf); if (conf.containsKey("CrossOverIndex")) { this.crossOverIndex = conf.getInt("CrossOverIndex"); } else {/*from ww w . j a v a2s. c o m*/ ConfWarning w = new ConfWarning("CrossOverIndex", crossOverIndex); w.warn(); } }