List of usage examples for org.apache.commons.configuration HierarchicalConfiguration getString
public String getString(String key)
From source file:com.norconex.importer.handler.tagger.impl.ForceSingleValueTagger.java
@Override protected void loadHandlerFromXML(XMLConfiguration xml) throws IOException { List<HierarchicalConfiguration> nodes = xml.configurationsAt("singleValue"); for (HierarchicalConfiguration node : nodes) { String name = node.getString("[@field]"); String action = node.getString("[@action]"); addSingleValueField(name, action); }//from w w w. j a v a 2s. com }
From source file:com.epam.cme.mdp3.core.cfg.Configuration.java
/** * Loads and parse CME MDP Configuration. * * @param uri URI to CME MDP Configuration (config.xml, usually available on CME FTP) * @throws ConfigurationException if failed to parse configuration file * @throws MalformedURLException if URI to Configuration is malformed *//*from ww w . ja va2 s . co m*/ private void load(final URI uri) throws ConfigurationException, MalformedURLException { // todo: if to implement the same via standard JAXB then dep to apache commons configuration will be not required final XMLConfiguration configuration = new XMLConfiguration(); configuration.setDelimiterParsingDisabled(true); configuration.load(uri.toURL()); for (final HierarchicalConfiguration channelCfg : configuration.configurationsAt("channel")) { final ChannelCfg channel = new ChannelCfg(channelCfg.getString("[@id]"), channelCfg.getString("[@label]")); for (final HierarchicalConfiguration connCfg : channelCfg.configurationsAt("connections.connection")) { final String id = connCfg.getString("[@id]"); final FeedType type = FeedType.valueOf(connCfg.getString("type[@feed-type]")); final TransportProtocol protocol = TransportProtocol .valueOf(connCfg.getString("protocol").substring(0, 3)); final Feed feed = Feed.valueOf(connCfg.getString("feed")); final String ip = connCfg.getString("ip"); final int port = connCfg.getInt("port"); final List<String> hostIPs = Arrays.asList(connCfg.getStringArray("host-ip")); final ConnectionCfg connection = new ConnectionCfg(feed, id, type, protocol, ip, hostIPs, port); channel.addConnection(connection); connCfgs.put(connection.getId(), connection); } channelCfgs.put(channel.getId(), channel); } }
From source file:com.norconex.importer.handler.transformer.impl.ReduceConsecutivesTransformer.java
@Override protected void loadHandlerFromXML(XMLConfiguration xml) throws IOException { setCaseSensitive(xml.getBoolean("[@caseSensitive]", false)); List<HierarchicalConfiguration> nodes = xml.configurationsAt("reduce"); for (HierarchicalConfiguration node : nodes) { String text = node.getString(""); text = text.replaceAll("\\\\s", " "); text = text.replaceAll("\\\\t", "\t"); text = text.replaceAll("\\\\n", "\n"); text = text.replaceAll("\\\\r", "\r"); addReductions(text);/*from w w w . j a va 2s.co m*/ } }
From source file:fr.openfarm.jmx.utils.ProxyConfig.java
@Override public void afterPropertiesSet() throws Exception { log.info("set Up Proxy Configuration"); jmxAccess = new HashMap<String, JmxLoginPass>(); String fileName = System.getProperty("configFilePath"); if (System.getProperty("configFilePath") != null) { try {/*w ww .java 2s . c o m*/ XMLConfiguration xmlConfiguration = new XMLConfiguration(fileName); SubnodeConfiguration accessList = xmlConfiguration.configurationAt("accessList"); List<HierarchicalConfiguration> loginPassConfs = accessList.configurationsAt("accessConf"); for (HierarchicalConfiguration loginPassConf : loginPassConfs) { JmxLoginPass jmxLoginPass = new JmxLoginPass(); jmxLoginPass.setLogin(loginPassConf.getString("login")); jmxLoginPass.setPassword(loginPassConf.getString("password")); jmxAccess.put(loginPassConf.getString("key"), jmxLoginPass); } } catch (Exception e) { log.error("Error while reading conf file : " + fileName, e); } } else { log.info("no configuration given to the jvm by param -DconfigFilePath"); } }
From source file:com.eyeq.pivot4j.ui.condition.NotCondition.java
/** * @see com.eyeq.pivot4j.state.Configurable#restoreSettings(org.apache.commons.configuration.HierarchicalConfiguration) */// w w w. j ava 2 s. com @Override public void restoreSettings(HierarchicalConfiguration configuration) { this.subCondition = null; try { HierarchicalConfiguration subConfig = configuration.configurationAt("condition"); String name = subConfig.getString("[@name]"); if (name != null) { this.subCondition = getConditionFactory().createCondition(name); this.subCondition.restoreSettings(subConfig); } } catch (IllegalArgumentException e) { } }
From source file:com.norconex.importer.handler.AbstractImporterHandler.java
@Override public final void loadFromXML(Reader in) throws IOException { XMLConfiguration xml = ConfigurationUtil.newXMLConfiguration(in); List<HierarchicalConfiguration> nodes = xml.configurationsAt("restrictTo"); for (HierarchicalConfiguration node : nodes) { addRestriction(node.getString("[@field]"), node.getString("", null), node.getBoolean("[@caseSensitive]", false)); }/*from ww w . j a v a2 s .c o m*/ loadHandlerFromXML(xml); }
From source file:com.vangent.hieos.empi.codes.CodesConfig.java
/** * /*from www. j a v a2 s . c o m*/ * @param hc */ private void loadCodeSetMapping(HierarchicalConfiguration hc) { String codedType = hc.getString(CODED_TYPE_ATTRIBUTE); String codeSystem = hc.getString(CODE_SYSTEM_ATTRIBUTE); CodeSystem codeSystemObj = this.getCodeSystemByName(codeSystem); this.codeSystemsByType.put(codedType, codeSystemObj); }
From source file:com.vmware.qe.framework.datadriven.impl.filter.DataFilterBasedOnProperty.java
/** * filters test based on given filterKey/filterValue. If the any of the filter key/value pairs * found from data object, then returns true. * /* www. j ava 2s. co m*/ * @param data test data * @return true if test is selected after applying filter, false otherwise */ private boolean checkAgainstFilterProperties(HierarchicalConfiguration data, HierarchicalConfiguration context) { boolean included = true; String filterKeys[] = null; String filterValues[] = null; if (context.containsKey(ARG_FILTER_KEY) && !context.getString(ARG_FILTER_KEY).trim().equals("")) { filterKeys = context.getStringArray(ARG_FILTER_KEY); filterValues = context.getStringArray(ARG_FILTER_VALUE); } else if (DDConfig.getSingleton().getData().containsKey(ARG_FILTER_KEY) && !DDConfig.getSingleton().getData().getString(ARG_FILTER_KEY).trim().equals("")) { filterKeys = DDConfig.getSingleton().getData().getStringArray(ARG_FILTER_KEY); filterValues = DDConfig.getSingleton().getData().getStringArray(ARG_FILTER_VALUE); } if (filterKeys != null && filterValues != null) { included = false; for (int index = 0; index < filterKeys.length; index++) { String filterKey = filterKeys[index]; String filterValue = null; if (index >= filterValues.length) { filterValue = ""; } else { filterValue = filterValues[index]; } if (data.containsKey(filterKey) && data.getString(filterKey, "").equals(filterValue)) { included = true; break; } } } return included; }
From source file:edu.uw.sig.frames2owl.util.BatchFromIncludeConverter.java
private void runBatch() { // read general configuration parameters HierarchicalConfiguration conv = batchFromIncludeConfig.configurationAt("conv"); // run converter for primary String framesPath = conv.getString("frames-path"); String owlPath = conv.getString("owl-path"); String owlURI = conv.getString("owl-uri"); String configPath = conv.getString("conf-path"); //System.err.println("will create run using args: "+ framesPath+" "+owlPath+" "+owlURI); Converter mainConv = new Converter(framesPath, owlPath, owlURI, configPath); mainConv.run();//from w w w .j ava 2 s . c om // reuse frame2ProjectMap Map<FrameID, String> frame2ProjectMap = mainConv.getFrame2ProjectMap(); // get all of the included ont configs List<HierarchicalConfiguration> inclConfs = conv.configurationsAt("include"); Map<String, HierarchicalConfiguration> name2ConfMap = new HashMap<String, HierarchicalConfiguration>(); for (HierarchicalConfiguration inclConf : inclConfs) { String name = inclConf.getString("[@name]"); if (name == null || name.equals("")) { System.err.println("Include configuration with no name attribute"); continue; } name2ConfMap.put(name, inclConf); } // create and run converter for each included ont Collection<URI> includedProjURIs = mainConv.getIncludedProjects(); for (URI includedProjURI : includedProjURIs) { String ontName = getOntNameFromURI(includedProjURI); HierarchicalConfiguration include = name2ConfMap.get(ontName); if (include == null) { System.err.println("Included ontology with no corresponding batch config entry"); continue; } System.err.println(include); //TODO you are here! String includeFramesPath = includedProjURI.getPath(); String includeOwlPath = include.getString("owl-path"); String includeOwlURI = include.getString("owl-uri"); String includeConfigPath = include.getString("conf-path"); Converter importConv = new Converter(includeFramesPath, includeOwlPath, includeOwlURI, includeConfigPath, frame2ProjectMap); importConv.run(); } /* for(HierarchicalConfiguration conv : convs) { // get arguments for run // i.e. resource/cho.pprj results/test.owl http://si.uw.edu/ont/fma.owl String framesPath = conv.getString("frames-path"); String owlPath = conv.getString("owl-path"); String owlURI = conv.getString("owl-uri"); String configPath = conv.getString("conf-path"); //System.err.println("will create run using args: "+ framesPath+" "+owlPath+" "+owlURI); Converter currConv = new Converter(framesPath, owlPath, owlURI, configPath); currConv.run(); } */ }
From source file:com.vangent.hieos.empi.codes.CodesConfig.java
/** * * @param hc/* ww w .j a v a 2 s .c om*/ */ private void loadCodeSet(HierarchicalConfiguration hc) { String codeSystem = hc.getString(CODE_SYSTEM_ATTRIBUTE); String codeSystemName = hc.getString(CODE_SYSTEM_NAME_ATTRIBUTE); String codeSystemVersion = hc.getString(CODE_SYSTEM_VERSION_ATTRIBUTE); CodeSystem codeSystemObj = new CodeSystem(); codeSystemObj.setCodeSystem(codeSystem); codeSystemObj.setCodeSystemName(codeSystemName); codeSystemObj.setCodeSystemVersion(codeSystemVersion); this.codeSystemsByName.put(codeSystem, codeSystemObj); // Now, get list of codes. List hcCodes = hc.configurationsAt(CODE); for (Iterator it = hcCodes.iterator(); it.hasNext();) { HierarchicalConfiguration hcCode = (HierarchicalConfiguration) it.next(); String code = hcCode.getString(VALUE_ATTRIBUTE); String displayName = hcCode.getString(DISPLAY_NAME_ATTRIBUTE); codeSystemObj.addCode(code, displayName); } }