private static AlgorithmConfig getAlgorithmConfig() { AlgorithmConfig config = new AlgorithmConfig(); XMLConfiguration xmlConfig = config.getXMLConfiguration(); xmlConfig.setProperty("iterations", "2000"); xmlConfig.setProperty("construction.insertion[@name]", "bestInsertion"); xmlConfig.setProperty("strategy.memory", 1); String searchStrategy = "strategy.searchStrategies.searchStrategy"; xmlConfig.setProperty(searchStrategy + "(0)[@name]", "random_best"); xmlConfig.setProperty(searchStrategy + "(0).selector[@name]", "selectBest"); xmlConfig.setProperty(searchStrategy + "(0).acceptor[@name]", "acceptNewRemoveWorst"); xmlConfig.setProperty(searchStrategy + "(0).modules.module(0)[@name]", "ruin_and_recreate"); xmlConfig.setProperty(searchStrategy + "(0).modules.module(0).ruin[@name]", "randomRuin"); xmlConfig.setProperty(searchStrategy + "(0).modules.module(0).ruin.share", "0.3"); xmlConfig.setProperty(searchStrategy + "(0).modules.module(0).insertion[@name]", "bestInsertion"); xmlConfig.setProperty(searchStrategy + "(0).probability", "0.5"); xmlConfig.setProperty(searchStrategy + "(1)[@name]", "radial_best"); xmlConfig.setProperty(searchStrategy + "(1).selector[@name]", "selectBest"); xmlConfig.setProperty(searchStrategy + "(1).acceptor[@name]", "acceptNewRemoveWorst"); xmlConfig.setProperty(searchStrategy + "(1).modules.module(0)[@name]", "ruin_and_recreate"); xmlConfig.setProperty(searchStrategy + "(1).modules.module(0).ruin[@name]", "radialRuin"); xmlConfig.setProperty(searchStrategy + "(1).modules.module(0).ruin.share", "0.15"); xmlConfig.setProperty(searchStrategy + "(1).modules.module(0).insertion[@name]", "bestInsertion"); xmlConfig.setProperty(searchStrategy + "(1).probability", "0.5"); return config; }
private void writeProblemType(XMLConfiguration xmlConfig) { xmlConfig.setProperty("problemType.fleetSize", vrp.getFleetSize()); }
int counter = 0; for (Vehicle vehicle : vrp.getVehicles()) { xmlConfig.setProperty(vehiclePathString + "(" + counter + ").id", vehicle.getId()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").typeId", vehicle.getType().getTypeId()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").startLocation.id", vehicle.getStartLocation().getId()); if (vehicle.getStartLocation().getCoordinate() != null) { xmlConfig.setProperty(vehiclePathString + "(" + counter + ").startLocation.coord[@x]", vehicle.getStartLocation().getCoordinate().getX()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").startLocation.coord[@y]", vehicle.getStartLocation().getCoordinate().getY()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").startLocation.index", vehicle.getStartLocation().getIndex()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").endLocation.id", vehicle.getEndLocation().getId()); if (vehicle.getEndLocation().getCoordinate() != null) { xmlConfig.setProperty(vehiclePathString + "(" + counter + ").endLocation.coord[@x]", vehicle.getEndLocation().getCoordinate().getX()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").endLocation.coord[@y]", vehicle.getEndLocation().getCoordinate().getY()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").endLocation.index", vehicle.getEndLocation().getId()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").timeSchedule.start", vehicle.getEarliestDeparture()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").timeSchedule.end", vehicle.getLatestArrival()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").breaks.duration", vehicle.getBreak().getServiceDuration()); for(TimeWindow tw : tws) { xmlConfig.setProperty(vehiclePathString + "(" + counter + ").breaks.timeWindows.timeWindow(" + index + ").start", tw.getStart()); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").breaks.timeWindows.timeWindow(" + index + ").end", tw.getEnd()); ++index; xmlConfig.setProperty(vehiclePathString + "(" + counter + ").returnToDepot", vehicle.isReturnToDepot());
private void upgradeFrom2_2_0(XMLConfiguration config) { try { if ( ! config.getBoolean(OptionsParamCheckForUpdates.CHECK_ON_START, false)) { /* * Check-for-updates on start set to false - force another prompt to ask the user, * as this option can have been unset incorrectly before. * And we want to encourage users to use this ;) */ config.setProperty(OptionsParamCheckForUpdates.DAY_LAST_CHECKED, ""); } } catch (Exception e) { // At one stage this was an integer, which will cause an exception to be thrown config.setProperty(OptionsParamCheckForUpdates.DAY_LAST_CHECKED, ""); } // Clear the block list - addons were incorrectly added to this if an update failed config.setProperty(AddOnLoader.ADDONS_BLOCK_LIST, ""); }
private static void loadValuesFromUser(Map<ConfigProperty, String> initialValues) { if (!initialValues.isEmpty()) { for (Entry<ConfigProperty, String> eachConfig : initialValues.entrySet()) { xmlConfig.setProperty(eachConfig.getKey().getName(), eachConfig.getValue()); } } }
private void copyProperty(XMLConfiguration fromConfig, XMLConfiguration toConfig, String key) { toConfig.setProperty(key, fromConfig.getProperty(key)); }
private void writeProblemType(XMLConfiguration xmlConfig) { xmlConfig.setProperty("problemType.fleetSize", vrp.getFleetSize()); }
public static void main(String[] args) throws ConfigurationException { XMLConfiguration config = new XMLConfiguration("change.xml"); config.setProperty("steps.step(1).step2", "stu"); StringWriter s = new StringWriter(); config.save(s); System.out.println(s.toString()); }
private void upgradeFrom2_4_3(XMLConfiguration config) { List<Object[]> oldData = new ArrayList<>(); // Convert extensions' options to not use extensions' names as XML element names for (Iterator<String> it = config.getKeys("ext"); it.hasNext();) { String key = it.next(); Object[] data = new Object[2]; data[0] = key.substring(4); data[1] = config.getBoolean(key); oldData.add(data); } config.clearTree("ext"); for (int i = 0, size = oldData.size(); i < size; ++i) { String elementBaseKey = "extensions.extension(" + i + ")."; Object[] data = oldData.get(i); config.setProperty(elementBaseKey + "name", data[0]); config.setProperty(elementBaseKey + "enabled", data[1]); } }
/** * Sets a SeLion configuration value. This is useful when you want to override or set a setting. * * @param configProperty * The configuration element to set * @param configPropertyValue * The value of the configuration element * @throws IllegalArgumentException * If problems occur during the set */ public static synchronized void setConfigProperty(ConfigProperty configProperty, Object configPropertyValue) { checkArgument(configProperty != null, "Config property cannot be null."); checkArgument(configPropertyValue != null, "Config property value cannot be null."); getConfig().setProperty(configProperty.getName(), configPropertyValue); }
XMLConfiguration config = new XMLConfiguration(dnsXmlPath); config.load(); config.setProperty("newProperty", "valueNewProperty"); config.save();
private static void loadValuesFromEnvironment() { final String PREFIX = "SELION_"; for (ConfigProperty configProps : ConfigProperty.values()) { String envValue = System.getenv(PREFIX + configProps.name()); if (StringUtils.isNotBlank(envValue)) { xmlConfig.setProperty(configProps.getName(), envValue); } // Now load system properties variables (if defined). String sysValue = System.getProperty(PREFIX + configProps.name()); if (StringUtils.isNotBlank(sysValue)) { xmlConfig.setProperty(configProps.getName(), sysValue); } } }
private void upgradeFrom2_0_0(XMLConfiguration config) { String forcedBrowseFile = config.getString("bruteforce.defaultFile", ""); if (!"".equals(forcedBrowseFile)) { String absolutePath = ""; // Try the 'local' dir first File f = new File(DIRBUSTER_CUSTOM_DIR + File.separator + forcedBrowseFile); if (!f.exists()) { f = new File(DIRBUSTER_DIR + File.separator + forcedBrowseFile); } if (f.exists()) { absolutePath = f.getAbsolutePath(); } config.setProperty("bruteforce.defaultFile", absolutePath); } // Remove the manual request editor configurations that were incorrectly created. config.clearTree("nullrequest"); config.clearTree("nullresponse"); }
public static void setJuddiProperty(String key, Object val) throws ConfigurationException{ if (instance==null) { instance = new AppConfig(); } propConfig.setProperty(key, val); propConfig.save(); }
public static void setJuddiProperty(String key, Object val) throws ConfigurationException{ if (instance==null) { instance = new AppConfig(); } propConfig.setProperty(key, val); propConfig.save(); }
/** * Update a property in loaded original configuration * @param property AndesConfiguration property. * @param value New value to be set * @return the set value */ public String updateProperty(AndesConfiguration property, String value) { configuration.setProperty(property.get().getKeyInFile(),value); return value; }
private static void upgradeFrom2_5_0(XMLConfiguration config) { String oldConfigKey = "proxy.modifyAcceptEncoding"; config.setProperty("proxy.removeUnsupportedEncodings", config.getBoolean(oldConfigKey, true)); config.clearProperty(oldConfigKey); // Convert passive scanners options to new structure Set<String> classnames = new HashSet<>(); for (Iterator<String> it = config.getKeys(); it.hasNext();) { String key = it.next(); if (!key.startsWith("pscans.org")) { continue; } classnames.add(key.substring(7, key.lastIndexOf('.'))); } List<Object[]> oldData = new ArrayList<>(); for (String classname : classnames) { Object[] data = new Object[3]; data[0] = classname; data[1] = config.getBoolean("pscans." + classname + ".enabled", true); data[2] = config.getString("pscans." + classname + ".level", ""); oldData.add(data); } config.clearTree("pscans.org"); for (int i = 0, size = oldData.size(); i < size; ++i) { String elementBaseKey = "pscans.pscanner(" + i + ")."; Object[] data = oldData.get(i); config.setProperty(elementBaseKey + "classname", data[0]); config.setProperty(elementBaseKey + "enabled", data[1]); config.setProperty(elementBaseKey + "level", data[2]); } }
private static void loadInitialValues() { for (ConfigProperty configProps : ConfigProperty.values()) { xmlConfig.setProperty(configProps.getName(), configProps.getDefaultValue()); } }
XMLConfiguration config = new XMLConfiguration("games.xml"); String gameName = config.getString("game1.name"); List<Object> playerNames = config.getList("game1.players.player.name"); // ... config.setProperty("game1.name", "Space Invaders"); // update game name config.addProperty("game1.players.player(-1).name", "ted"); // add new players config.addProperty("game1.players.player(-1).name", "carol"); config.clearTree("game1.players.player(1)"); // remove a player // Or with XPath config.setExpressionEngine(new XPathExpressionEngine()); config.addProperty("game1/players player/name", "ted"); config.addProperty("game1/players player/name", "carol"); config.clearTree("game1/players/player[2]");
xmlConfig.setProperty(ConfigProperty.SELENIUM_HOST.getName(), "localhost");