本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
}
}
示例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;
}