List of usage examples for org.apache.commons.configuration PropertiesConfiguration setProperty
public void setProperty(String key, Object value)
From source file:org.lockss.crawljax.TestDefLockssConfigurationBuilder.java
private void createMockConfig(String fileName, int maxStates, int depth, long runtime, String browser, String proxy) throws ConfigurationException { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty(DefLockssConfigurationBuilder.MAX_STATES_PARAM, maxStates); config.setProperty(DefLockssConfigurationBuilder.DEPTH_PARAM, depth); config.setProperty(DefLockssConfigurationBuilder.TIMEOUT_PARAM, runtime); config.setProperty(DefLockssConfigurationBuilder.BROWSER_PARAM, browser); config.setProperty(DefLockssConfigurationBuilder.PROXY_PARAM, proxy); config.save(fileName);/* www. j a v a 2 s . c o m*/ }
From source file:org.lsc.Configuration.java
/** * Set the new properties/*from w w w . jav a 2s. c o m*/ * @param prefix the prefix or null * @param props the news properties * @throws ConfigurationException */ public static void setProperties(String prefix, Properties props) throws ConfigurationException { Enumeration<Object> propsEnum = props.keys(); PropertiesConfiguration conf = Configuration.getConfiguration(); while (propsEnum.hasMoreElements()) { String key = (String) propsEnum.nextElement(); conf.setProperty((prefix != null ? prefix + "." : "") + key, props.getProperty(key)); } conf.save(); }
From source file:org.manalith.ircbot.plugin.missedmessage.MissedMessageRunner.java
public String addMsg(String sender, String receiver, String msg) { StringBuilder result = new StringBuilder(); boolean savedMsg = false; int msglen = msg.length(); try {/* w w w . j a va 2s .c om*/ PropertiesConfiguration prop = new PropertiesConfiguration( getResourcePath() + MissedMessageRunner.filename); Iterator<String> userlist = prop.getKeys(); if (userlist != null) { while (userlist.hasNext()) { String key = userlist.next(); if (key.equals(receiver)) { if (prop.getString(receiver).length() != 0) { result.append(StringUtils.split(receiver, '.')[1]); String str = prop.getString(receiver); result.append("? ? ( "); int availableSpace = 3 - str.split("\\:\\:").length; if (availableSpace != 0) { if (msglen <= 150) { prop.setProperty(receiver, str + "::" + "[:" + sender + "] " + msg); result.append(availableSpace - 1); result.append(" / 3 )"); } else { result.delete(0, result.length()); result.append(" ? 150? ."); } } else { result.append(availableSpace); result.append(" / 3 ) : ??? "); } } else // if key has no value { if (msglen <= 150) { prop.setProperty(receiver, "[:" + sender + "] " + msg); result.append(StringUtils.split(receiver, '.')[1]); result.append("? ? ( 2 / 3 )"); } else { result.delete(0, result.length()); result.append(" ? 150? ."); } } savedMsg = true; prop.save(); break; } } if (!savedMsg) { result.append(receiver.split("\\.")[1] + "? ? ?? ?? ."); } } } catch (ConfigurationException ce) { return ce.getMessage(); } return result.toString(); }
From source file:org.manalith.ircbot.plugin.missedmessage.MissedMessageRunner.java
public String[] getMsg(String newRecv) { String[] msgs = null;/*w w w. ja va 2s . c o m*/ try { // init! PropertiesConfiguration prop = new PropertiesConfiguration( getResourcePath() + MissedMessageRunner.filename); if (isMatchedNickinList(newRecv)) { if (prop.getString(newRecv).length() != 0) { msgs = prop.getString(newRecv).split("\\:\\:"); for (int i = 0; i < msgs.length; i++) msgs[i] = newRecv.split("\\.")[1] + ", " + msgs[i]; prop.setProperty(newRecv, ""); prop.save(); } } } catch (ConfigurationException ce) { msgs = new String[1]; msgs[0] = ce.getMessage(); } return msgs; }
From source file:org.manalith.ircbot.plugin.missedmessage.MissedMessageRunner.java
public void addMsgSlot(String newRecv) { try {/*w ww . jav a2 s. c o m*/ PropertiesConfiguration prop = new PropertiesConfiguration( getResourcePath() + MissedMessageRunner.filename); // if user not found, init msgslot prop.setProperty(newRecv, ""); prop.save(); } catch (ConfigurationException ce) { // ignore exception } }
From source file:org.nekorp.workflow.desktop.control.imp.WorkflowAppPrototipo.java
@Override public void setPreferenciasUsuario(PreferenciasUsuario param) { try {/*from w w w . ja va 2 s .c om*/ PropertiesConfiguration config = new PropertiesConfiguration("app.properties"); config.setProperty("app.service.busqueda.firstId", param.getFirstId()); config.setProperty("app.service.busqueda.filtro.ultimo", param.getUltimoFiltro()); config.save(); } catch (ConfigurationException ex) { WorkflowAppPrototipo.LOGGER.error("error al guardar las preferencias" + ex.getMessage()); } }
From source file:org.onlab.stc.ScenarioStore.java
/** * Saves the states to disk.//from ww w . j a v a2s .c o m */ private void save() { try { PropertiesConfiguration cfg = new PropertiesConfiguration(storeFile); events.forEach(event -> cfg.setProperty("T" + event.time(), event.toString())); cfg.save(); } catch (ConfigurationException e) { print("Unable to store file %s", storeFile); } }
From source file:org.seedstack.seed.security.internal.realms.ConfigurationRealmUnitTest.java
@Test public void readConfiguration_with_users() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty("users.Obiwan", "yodarulez, SEED.JEDI"); conf.setProperty("users.Anakin", "imsodark"); underTest.readConfiguration(conf);/*from w ww.j ava 2s .co m*/ assertThat(users).hasSize(2); assertThat(users).containsOnly(new ConfigurationUser("Obiwan"), new ConfigurationUser("Anakin")); }
From source file:org.settings4j.helper.configuration.ConfigurationToConnectorAdapterTest.java
@Test public void testAdapterPropertiesConfig() throws Exception { final Settings4jRepository testSettings = createSimpleSettings4jConfig(); // start test => create adapter and add to Settings4jRepository final PropertiesConfiguration configuration = addPropertiesConfiguration(// testSettings, "myPropConfigConnector", "propertiesConfig.properties"); // configure some values configuration.setProperty(TEST_VALUE_KEY, "Hello Windows World"); configuration.save();//from w w w. jav a 2 s . co m // validate result assertThat(testSettings.getSettings().getString(TEST_VALUE_KEY), is("Hello Windows World")); assertThat(testSettings.getSettings().getString("unknown/Value"), is(nullValue())); }
From source file:org.silverpeas.settings.file.ModifProperties.java
/** * lance la modification du fichier properties * @throws Exception/*from www . java2 s.co m*/ */ @Override public void executeModification() throws Exception { File file = new File(path); if (file.exists()) { PropertiesConfiguration configuration = new PropertiesConfiguration(file); for (ElementModif em : listeModifications) { if (configuration.containsKey(em.getSearch())) { if (!em.getModif().equals(configuration.getProperty(em.getSearch()))) { if (!isModified) { isModified = true; BackupFile bf = new BackupFile(new File(path)); bf.makeBackup(); } configuration.setProperty(em.getSearch(), em.getModif()); } } else { configuration.setProperty(em.getSearch(), em.getModif()); } } configuration.save(file); } else { throw new Exception("ATTENTION le fichier:" + path + " n'existe pas"); } }