public AlgorithmConfig() { xmlConfig = new XMLConfiguration(); }
private static int getMaxIterations(XMLConfiguration config) { String maxIterationsString = config.getString("iterations"); if (maxIterationsString == null) maxIterationsString = config.getString("maxIterations"); if (maxIterationsString != null) return (Integer.parseInt(maxIterationsString)); return -1; }
public void read(String filename) { logger.debug("read vrp: {}", filename); XMLConfiguration xmlConfig = createXMLConfiguration(); try { xmlConfig.load(filename); } catch (ConfigurationException e) { throw new RuntimeException(e); } read(xmlConfig); }
private XMLConfiguration createXMLConfiguration() { XMLConfiguration xmlConfig = new XMLConfiguration(); xmlConfig.setAttributeSplittingDisabled(true); xmlConfig.setDelimiterParsingDisabled(true); if (schemaValidation) { final InputStream resource = Resource.getAsInputStream("vrp_xml_schema.xsd"); if (resource != null) { EntityResolver resolver = new EntityResolver() { @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { { InputSource is = new InputSource(resource); return is; } } }; xmlConfig.setEntityResolver(resolver); xmlConfig.setSchemaValidation(true); } else { logger.debug("cannot find schema-xsd file (vrp_xml_schema.xsd). try to read xml without xml-file-validation."); } } return xmlConfig; }
public void read(URL url) { log.debug("read algorithm: " + url); algorithmConfig.getXMLConfiguration().setURL(url); algorithmConfig.getXMLConfiguration().setAttributeSplittingDisabled(true); algorithmConfig.getXMLConfiguration().setDelimiterParsingDisabled(true); if (schemaValidation) { final InputStream resource = Resource.getAsInputStream("algorithm_schema.xsd"); if (resource != null) { EntityResolver resolver = new EntityResolver() { @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { { InputSource is = new InputSource(resource); return is; } } }; algorithmConfig.getXMLConfiguration().setEntityResolver(resolver); algorithmConfig.getXMLConfiguration().setSchemaValidation(true); } else { log.warn("cannot find schema-xsd file (algorithm_xml_schema.xsd). try to read xml without xml-file-validation."); } } try { algorithmConfig.getXMLConfiguration().load(); } catch (ConfigurationException e) { throw new RuntimeException(e); } }
xConfig = new XMLConfiguration(metricsUrl); xConfig.append(getEnvironmentConfiguration()); xConfig.addConfigurationListener(new MetricsConfigListener()); xConfig.setReloadingStrategy(new FileChangedReloadingStrategy()); config = xConfig.interpolatedConfiguration();
private ApplicationDescription parsePlainAppDescription(InputStream stream) throws IOException { XMLConfiguration cfg = new XMLConfiguration(); cfg.setAttributeSplittingDisabled(true); cfg.setDelimiterParsingDisabled(true); try { cfg.load(stream); return loadAppDescription(cfg); } catch (ConfigurationException e) { throw new IOException("Unable to parse " + APP_XML, e); } }
@Override protected void loadHandlerFromXML(XMLConfiguration xml) throws IOException { field = xml.getString("[@field]", field); overwrite = xml.getBoolean("[@overwrite]", overwrite); }
public static XMLConfiguration createDefaultConfigurationSource() { XMLConfiguration xmlConfig = new XMLConfiguration(); xmlConfig.setDelimiterParsingDisabled(true); return xmlConfig; }
@Override protected void loadHandlerFromXML(XMLConfiguration xml) throws IOException { fromField = xml.getString("[@fromField]", fromField); appendHash = xml.getBoolean("[@appendHash]", appendHash); suffix = xml.getString("[@suffix]", suffix); toField = xml.getString("[@toField]", toField); overwrite = xml.getBoolean("[@overwrite]", overwrite); maxLength = xml.getInt("[@maxLength]", maxLength); } @Override
try { XMLConfiguration config = new XMLConfiguration("tables.xml"); // do something with config } catch(ConfigurationException cex) { // something went wrong, e.g. the file was not found } String backColor = config.getString("colors.background"); String textColor = config.getString("colors.text"); String linkNormal = config.getString("colors.link[@normal]"); String defColor = config.getString("colors.default"); int rowsPerPage = config.getInt("rowsPerPage"); List buttons = config.getList("buttons.name");
XMLConfiguration config = new XMLConfiguration(); try { config.load( context.getResources().openRawResource(R.raw.kmlsample)); } catch (ConfigurationException e) { e.printStackTrace(); } catch (NotFoundException e) { e.printStackTrace(); }
private void createXmlConfiguration(DocumentBuilder documentBuilder, String filename) throws ConfigurationException { XMLConfiguration xmlConfig = new XMLConfiguration(); xmlConfig.setDocumentBuilder(documentBuilder); xmlConfig.setDelimiterParsingDisabled(true); xmlConfig.setFileName(filename); xmlConfig.load(); config.addConfiguration(xmlConfig); applyEnvironmentProperties(); resolveFileReferences(); }
public static Map<String, JSONObject> loadRegexAlerts(String config_path) throws ConfigurationException, ParseException { XMLConfiguration alert_rules = new XMLConfiguration(); alert_rules.setDelimiterParsingDisabled(true); alert_rules.load(config_path); //int number_of_rules = alert_rules.getList("rule.pattern").size(); String[] patterns = alert_rules.getStringArray("rule.pattern"); String[] alerts = alert_rules.getStringArray("rule.alert"); JSONParser pr = new JSONParser(); Map<String, JSONObject> rules = new HashMap<String, JSONObject>(); for (int i = 0; i < patterns.length; i++) rules.put(patterns[i], (JSONObject) pr.parse(alerts[i])); return rules; }
private void exportToClipBoard(List<ColumnLayout> columnLayouts) throws ConfigurationException { final XMLConfiguration xmlConfiguration = new XMLConfiguration(); saveColumnLayouts(columnLayouts, xmlConfiguration); final StringWriter writer = new StringWriter(); xmlConfiguration.save(writer); StringSelection stringSelection = new StringSelection(writer.getBuffer().toString()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, null); otrosApplication.getStatusObserver().updateStatus("Column layouts have been exported to clipboard"); }
XMLConfiguration config = new XMLConfiguration(); config.setFileName("config_default.xml"); config.setSchemaValidation(true); // This will throw a ConfigurationException if the XML document does not // conform to its Schema. config.load();
private static void fillLdap() { config.setDelimiterParsingDisabled(true); config.setListDelimiter((char) 1); Config.config.clear(); try { config.load(); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } State.getInstance().setUseLDAP(Config.config.getBoolean("connectionPool[@useLDAP]", false)); State.getInstance().setUseDynamicLDAPDataSource(Config.config.getBoolean("connectionPool[@enableDynamicLdapDataSource]", false)); State.getInstance().setUseLDAPImport(Config.config.getBoolean("connectionPool[@useLDAPImport]", false)); State.getInstance().setLdapServer(Config.config.getString("connectionPool[@ldapServer]")); State.getInstance().setLdapCn(Config.config.getString("connectionPool[@ldapCn]")); State.getInstance().setLdapBase(Config.config.getString("connectionPool[@ldapBase]")); }
private static Configuration getVfsFavoritesConfiguration() { File file = new File(AllPluginables.USER_CONFIGURATION_DIRECTORY + File.separator + "vfsFavorites.xml"); XMLConfiguration configuration = new XMLConfiguration(); configuration.setFile(file); if (file.exists()) { try { configuration.load(); } catch (ConfigurationException e) { LOGGER.error(String.format("Can't load user configuration from %s: %s", file.getAbsolutePath(), e.getMessage())); } } configuration.setAutoSave(true); return configuration; }
Configuration(final String configPath) { try { config = new XMLConfiguration(configPath); FileChangedReloadingStrategy reloadStrategy = new FileChangedReloadingStrategy(); reloadStrategy.setRefreshDelay(config.getLong("refresh", 6000)); config.setReloadingStrategy(reloadStrategy); config.addConfigurationListener(event -> init(config)); init(config); } catch (ConfigurationException | PatternSyntaxException e) { throw new IllegalStateException("SerialKiller not properly configured: " + e.getMessage(), e); } }
/** * @return the configuration */ protected HierarchicalConfiguration createConfiguration() { XMLConfiguration config = new XMLConfiguration(); config.setRootElementName("report"); config.setDelimiterParsingDisabled(true); return config; }