List of usage examples for org.apache.commons.configuration XMLConfiguration XMLConfiguration
public XMLConfiguration(URL url) throws ConfigurationException
XMLConfiguration
. From source file:com.litt.core.security.license.gui.ConfigPanel.java
/** * @throws FileNotFoundException// w w w . j a v a 2s. co m * @throws ParseException */ private void loadLicense(File licenseFile) throws FileNotFoundException, ConfigurationException { XMLConfiguration config = new XMLConfiguration(licenseFile); String licenseId = config.getString("licenseId"); String licenseType = config.getString("licenseType"); String productName = config.getString("productName"); String companyName = config.getString("companyName"); String customerName = config.getString("customerName"); String version = config.getString("version"); Date createDate = Utility.parseDate(config.getString("createDate")); Date expiredDate = Utility.parseDate(config.getString("expiredDate")); textField_licenseId.setText(licenseId); int typeCount = comboBox_licenseType.getItemCount(); for (int i = 0; i < typeCount; i++) { if (((MapComboBoxModel) comboBox_licenseType.getItemAt(i)).getValue().equals(licenseType)) { comboBox_licenseType.setSelectedIndex(i); break; } } textField_productName.setText(productName); textField_companyName.setText(companyName); textField_customerName.setText(customerName); textField_version.setText(version); datePicker_expiredDate.getInnerTextField().setText(FormatDateTime.formatDate(expiredDate)); }
From source file:io.datalayer.conf.XmlConfigurationTest.java
@Test public void testAutoSave() throws Exception { conf.setFile(testSaveConf);/*from w w w. ja v a2s.c om*/ assertFalse(conf.isAutoSave()); conf.setAutoSave(true); assertTrue(conf.isAutoSave()); conf.setProperty("autosave", "ok"); // reload the configuration XMLConfiguration conf2 = new XMLConfiguration(conf.getFile()); assertEquals("'autosave' property", "ok", conf2.getString("autosave")); conf.clearTree("clear"); conf2 = new XMLConfiguration(conf.getFile()); Configuration sub = conf2.subset("clear"); assertTrue(sub.isEmpty()); }
From source file:io.datalayer.conf.XmlConfigurationTest.java
/** * Tests saving a configuration after cloning to ensure that the clone and * the original are completely detached. *//*from w w w .j a va 2 s . c o m*/ @Test public void testCloneWithSave() throws ConfigurationException { XMLConfiguration c = (XMLConfiguration) conf.clone(); c.addProperty("test.newProperty", Boolean.TRUE); conf.addProperty("test.orgProperty", Boolean.TRUE); c.save(testSaveConf); XMLConfiguration c2 = new XMLConfiguration(testSaveConf); assertTrue("New property after clone() was not saved", c2.getBoolean("test.newProperty")); assertFalse("Property of original config was saved", c2.containsKey("test.orgProperty")); }
From source file:io.datalayer.conf.XmlConfigurationTest.java
/** * Tests whether a DTD can be accessed.// w w w . ja v a2s .com */ @Test public void testDtd() throws ConfigurationException { conf = new XMLConfiguration("testDtd.xml"); assertEquals("value1", conf.getString("entry(0)")); assertEquals("test2", conf.getString("entry(1)[@key]")); }
From source file:at.ac.tuwien.auto.iotsys.gateway.connectors.knx.KNXDeviceLoaderETSImpl.java
@Override public void setConfiguration(XMLConfiguration connectorsConfig) { this.connectorsConfig = connectorsConfig; if (connectorsConfig == null) { try {//from w ww . ja va 2 s . c o m log.info("Loading XML configuration from " + DEVICE_CONFIGURATION_LOCATION); this.connectorsConfig = new XMLConfiguration(DEVICE_CONFIGURATION_LOCATION); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage(), e); } } }
From source file:io.datalayer.conf.XmlConfigurationTest.java
/** * Tests handling of empty elements./*from ww w . j a v a 2s . com*/ */ @Test public void testEmptyElements() throws ConfigurationException { assertTrue(conf.containsKey("empty")); assertEquals("", conf.getString("empty")); conf.addProperty("empty2", ""); conf.setProperty("empty", "no more empty"); conf.save(testSaveConf); conf = new XMLConfiguration(testSaveConf); assertEquals("no more empty", conf.getString("empty")); assertEquals("", conf.getProperty("empty2")); }
From source file:at.nhmwien.schema_mapping_tool.ProcessMappingWindow.java
private void loadSettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadSettingsButtonActionPerformed JFileChooser fc = new JFileChooser(); fc.setAcceptAllFileFilterUsed(false); FileNameExtensionFilter fnef = new FileNameExtensionFilter("SMT Processing Settings (*.sps)", "sps"); fc.addChoosableFileFilter(fnef);/* w ww .ja v a 2 s.c o m*/ // Let the user chose a settings file if (fc.showDialog(this, "Load Processing Settings") == JFileChooser.APPROVE_OPTION) { try { this.settings = new XMLConfiguration(fc.getSelectedFile()); // Update the interface to show all saved settings this.inputFileFormatComboBox .setSelectedItem(this.settings.getProperty("config.input-file-processor")); this.outputFileFormatComboBox .setSelectedItem(this.settings.getProperty("config.output-file-processor")); this.ifEncodingComboBox.setSelectedItem( Charset.forName((String) this.settings.getProperty("config.input-file-encoding"))); this.ofEncodingComboBox.setSelectedItem( Charset.forName((String) this.settings.getProperty("config.output-file-encoding"))); this.inputIDPrefixTextField.setText((String) this.settings.getProperty("config.input-id-prefix")); this.countThresholdTextField.setText((String) this.settings.getProperty("config.count-threshold")); MappingsHandler.Self() .setInputOrder((ArrayList<String>) this.settings.getProperty("config.input-field-order")); MappingsHandler.Self() .setOutputOrder((ArrayList<String>) this.settings.getProperty("config.output-field-order")); // Now load the processor specific settings FileProcessor fp = this.inputOptionsPanel.getProcessor(); String options[] = fp.getAvailableOptions(); for (String option : options) { if (this.settings.containsKey("config.inputProcessor.options." + option)) fp.setOption(option, this.settings.getProperty("config.inputProcessor.options." + option)); } fp = this.outputOptionsPanel.getProcessor(); options = fp.getAvailableOptions(); for (String option : options) { if (this.settings.containsKey("config.outputProcessor.options." + option)) fp.setOption(option, this.settings.getProperty("config.outputProcessor.options." + option)); } // Update options from processor for display this.inputOptionsPanel.loadOptions(); this.outputOptionsPanel.loadOptions(); /*Iterator it = this.settings.getKeys("config.inputProcessor.options"); while( it.hasNext() ) { System.out.println( it.next().toString() ); }*/ //this.settings.get } catch (Exception e) { e.printStackTrace(); } } }
From source file:edu.hawaii.soest.hioos.storx.StorXDispatcher.java
private boolean parseConfiguration() { boolean failed = true; try {/* www. ja v a 2 s .c om*/ // create an XML Configuration object from the sensor XML file File xmlConfigFile = new File(this.xmlConfigurationFile); this.xmlConfiguration = new XMLConfiguration(xmlConfigFile); failed = false; } catch (NullPointerException npe) { logger.info("There was an error reading the XML configuration file. " + "The error message was: " + npe.getMessage()); } catch (ConfigurationException ce) { logger.info("There was an error creating the XML configuration. " + "The error message was: " + ce.getMessage()); } return !failed; }
From source file:io.datalayer.conf.XmlConfigurationTest.java
/** * Tests the copy constructor.// w w w. ja v a 2 s . c o m */ @Test public void testInitCopy() throws ConfigurationException { XMLConfiguration copy = new XMLConfiguration(conf); assertEquals("value", copy.getProperty("element")); assertNull("Document was copied, too", copy.getDocument()); ConfigurationNode root = copy.getRootNode(); for (ConfigurationNode node : root.getChildren()) { assertNull("Reference was not cleared", node.getReference()); } removeTestFile(); copy.setFile(testSaveConf); copy.save(); copy.clear(); checkSavedConfig(copy); }
From source file:com.sonicle.webtop.core.app.ServiceManager.java
private ArrayList<ServiceManifest> parseDescriptor(final URL descriptorUri) throws ConfigurationException { ArrayList<ServiceManifest> manifests = new ArrayList(); ServiceManifest manifest = null;// ww w. jav a2 s.c om logger.trace("Parsing descriptor [{}]", descriptorUri.toString()); XMLConfiguration config = new XMLConfiguration(descriptorUri); List<HierarchicalConfiguration> elServices = config.configurationsAt("service"); for (HierarchicalConfiguration elService : elServices) { try { manifest = new ServiceManifest(elService); manifests.add(manifest); } catch (Exception ex) { logger.warn("Service descriptor for '{}' version {} skipped. Cause: {}", elService.getString("shortName"), elService.getString("version"), ex.getMessage()); } } return manifests; }