当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesConfiguration.getKeys方法代码示例

本文整理汇总了Java中org.apache.commons.configuration2.PropertiesConfiguration.getKeys方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesConfiguration.getKeys方法的具体用法?Java PropertiesConfiguration.getKeys怎么用?Java PropertiesConfiguration.getKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.configuration2.PropertiesConfiguration的用法示例。


在下文中一共展示了PropertiesConfiguration.getKeys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildFromConfig

import org.apache.commons.configuration2.PropertiesConfiguration; //导入方法依赖的package包/类
/**
 * Builds the Configuration object from the properties file (apache commons
 * properties file format). <br>
 * The values provided in the config file will be overwritten environment
 * variables (if present)
 * 
 * List of the properties <br>
 * loginsight.host = host name <br>
 * loginsight.port = port number <br>
 * loginsight.user = User name <br>
 * loginsight.password = password <br>
 * loginsight.ingestion.agentId = agentId <br>
 * loginsight.connection.scheme = http protocol scheme <br>
 * loginsight.ingestion.port = Ingestion port number <br>
 * 
 * @param configFileName
 *            Name of the config file to read
 * @return Newly created Configuration object
 */
public static Configuration buildFromConfig(String configFileName) {
	try {
		List<FileLocationStrategy> subs = Arrays.asList(new ProvidedURLLocationStrategy(),
				new FileSystemLocationStrategy(), new ClasspathLocationStrategy());
		FileLocationStrategy strategy = new CombinedLocationStrategy(subs);

		FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<PropertiesConfiguration>(
				PropertiesConfiguration.class).configure(
						new Parameters().fileBased().setLocationStrategy(strategy).setFileName(configFileName));
		PropertiesConfiguration propConfig = builder.getConfiguration();
		Map<String, String> propMap = new HashMap<String, String>();
		Iterator<String> keys = propConfig.getKeys();
		keys.forEachRemaining(key -> {
			logger.info(key + ":" + propConfig.getString(key));
			propMap.put(key, propConfig.getString(key));
		});
		Configuration config = Configuration.buildConfig(propMap);
		config.loadFromEnv();
		return config;
	} catch (ConfigurationException e1) {
		throw new RuntimeException("Unable to load config", e1);
	}
}
 
开发者ID:vmware,项目名称:loginsight-java-api,代码行数:43,代码来源:Configuration.java

示例2: getNeoTypeToManualFiles

import org.apache.commons.configuration2.PropertiesConfiguration; //导入方法依赖的package包/类
private Multimap<String, String> getNeoTypeToManualFiles(PropertiesConfiguration config) {
	Multimap<String,String> result = HashMultimap.create();
	Iterator<String> keys = config.getKeys("manualUpload");
	while (keys.hasNext()) {
		String key = keys.next();
		String propertyValue = config.getString(key);
		if (StringUtils.isNotEmpty(propertyValue)) {
			String[] split = propertyValue.split(COMMA);
			for (String s : split) {
				result.put(StringUtils.remove(key, "manualUpload."), s);
			}
		}
	}
	return result;
}
 
开发者ID:phenopolis,项目名称:pheno4j,代码行数:16,代码来源:ImportCommandGenerator.java

示例3: mergeExtraOptions

import org.apache.commons.configuration2.PropertiesConfiguration; //导入方法依赖的package包/类
private static void mergeExtraOptions(PropertiesConfiguration baseOptions, PropertiesConfiguration extraOptions) {
  if (isNull(extraOptions) || extraOptions.size() == 0) {
    return;
  }
  trace("loadOptions: have to merge extra Options");
  Iterator<String> allKeys = extraOptions.getKeys();
  while (allKeys.hasNext()) {
    String key = allKeys.next();
    if ("sxversion".equals(key)) {
      baseOptions.setProperty("sxversion_saved", extraOptions.getProperty(key));
      continue;
    }
    if ("sxbuild".equals(key)) {
      baseOptions.setProperty("sxbuild_saved", extraOptions.getProperty(key));
      continue;
    }
    Object value = baseOptions.getProperty(key);
    if (isNull(value)) {
      baseOptions.addProperty(key, extraOptions.getProperty(key));
      trace("Option added: %s", key);
    } else {
      Object extraValue = extraOptions.getProperty(key);
      if (!value.getClass().getName().equals(extraValue.getClass().getName()) ||
              !value.toString().equals(extraValue.toString())) {
        baseOptions.setProperty(key, extraValue);
        trace("Option changed: %s = %s", key, extraValue);
      }
    }
  }
}
 
开发者ID:RaiMan,项目名称:SikuliX2,代码行数:31,代码来源:SX.java

示例4: toConfiguration

import org.apache.commons.configuration2.PropertiesConfiguration; //导入方法依赖的package包/类
public FilePropertiesConfiguration toConfiguration(String defaultsFile)
		throws ConfigurationException, IOException
{
	int i = 1;
	FilePropertiesConfiguration jnlpConf = new FilePropertiesConfiguration();

	List jars = getJars(_doc);
	for (Iterator it = jars.listIterator(); it.hasNext();)
	{
		jnlpConf.setProperty("wrapper.java.classpath." + i++, it.next());
	}

	jnlpConf.setProperty("wrapper.base", getCodebase(_doc));

	jnlpConf.setProperty("wrapper.java.app.mainclass", getMainClass(_doc));

	i = 1;
	for (Iterator it = getArguments(_doc).listIterator(); it.hasNext();)
	{
		jnlpConf.setProperty("wrapper.app.parameter." + i++, it.next());
	}
	i = 1;
	List props = getResourceProperties(_doc);
	for (Iterator it = props.listIterator(); it.hasNext();)
	{
		jnlpConf.setProperty("wrapper.java.additional." + i++, it.next());
	}

	i = 1;
	List resources = getResources(_doc);
	for (Iterator it = resources.listIterator(); it.hasNext();)
	{
		jnlpConf.setProperty("wrapper.resource." + i++, it.next());
	}

	if (defaultsFile == null || "".equals(defaultsFile))
		return jnlpConf;

	// jnlpConf.addProperty("include", defaultsFile);

	if (defaultsFile != null)
	{
		PropertiesConfiguration defaultsConf = new PropertiesConfiguration();
		FileObject fo = VFSUtils.resolveFile(".", defaultsFile);
		InputStreamReader in = new InputStreamReader(fo.getContent().getInputStream());
		defaultsConf.read(in);
		in.close();
		for (Iterator it = defaultsConf.getKeys(); it.hasNext();)
		{
			String key = (String) it.next();
			if (jnlpConf.containsKey(key))
				System.out.println("configuration conflict: " + key);
			else
				jnlpConf.addProperty(key, defaultsConf.getProperty(key));
		}
	}

	return jnlpConf;

}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:61,代码来源:JnlpSupport.java


注:本文中的org.apache.commons.configuration2.PropertiesConfiguration.getKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。