private IImporterHandler[] loadImportHandlers( XMLConfiguration xml, String xmlPath) { List<IImporterHandler> handlers = new ArrayList<>(); ExpressionEngine originalEngine = xml.getExpressionEngine(); xml.setExpressionEngine(new XPathExpressionEngine()); List<HierarchicalConfiguration> xmlHandlers = xml.configurationsAt(xmlPath + "/*"); xml.setExpressionEngine(originalEngine); for (HierarchicalConfiguration xmlHandler : xmlHandlers) { xmlHandler.setExpressionEngine(originalEngine); IImporterHandler handler = XMLConfigurationUtil.newInstance(xmlHandler); if (handler != null) { handlers.add(handler); //TODO throw exception here? } } if (handlers.isEmpty()) { return null; } return handlers.toArray(new IImporterHandler[]{}); }
public ConfigurationEditor(String originalConfigFilePath) throws ConfigurationException { this.originalConfigFilePath = originalConfigFilePath; configuration = new XMLConfiguration(this.originalConfigFilePath); // Support XPath queries. configuration.setExpressionEngine(new XPathExpressionEngine()); configuration.setDelimiterParsingDisabled(true); // If we don't do this, // we can't add a new configuration to the compositeConfiguration by code. }
config.setExpressionEngine(expressionEngine);
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]");
configuration.setFileName(path); configuration.setFileSystem(getFileSystem()); configuration.setExpressionEngine(getExpressionEngine()); ReloadingStrategy strategy = createReloadingStrategy(); if (strategy != null)
configuration.setFileName(path); configuration.setFileSystem(getFileSystem()); configuration.setExpressionEngine(getExpressionEngine()); ReloadingStrategy strategy = createReloadingStrategy(); if (strategy != null)