本文整理汇总了Java中org.ini4j.Ini.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java Ini.keySet方法的具体用法?Java Ini.keySet怎么用?Java Ini.keySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ini4j.Ini
的用法示例。
在下文中一共展示了Ini.keySet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSubsetOf
import org.ini4j.Ini; //导入方法依赖的package包/类
private void isSubsetOf(String sourceIniPath, String expectedIniPath) throws IOException {
Ini goldenIni = new Ini(new FileInputStream(expectedIniPath));
Ini sourceIni = new Ini(new FileInputStream(sourceIniPath));
for(String key : goldenIni.keySet()) {
if(!sourceIni.containsKey(key) && goldenIni.get(key).size() > 0) {
fail("missing section " + key + " in file " + sourceIniPath);
}
Section goldenSection = goldenIni.get(key);
Section sourceSection = sourceIni.get(key);
for(String name : goldenSection.childrenNames()) {
if(!sourceSection.containsKey(name)) {
fail("missing name " + name + " in file " + sourceIniPath + " section [" + name + "]");
}
assertEquals(goldenSection.get(name), sourceSection.get(name));
}
}
}
示例2: sample01
import org.ini4j.Ini; //导入方法依赖的package包/类
void sample01(Ini ini)
{
Ini.Section section = ini.get("happy");
//
// read some values
//
String age = section.get("age");
String weight = section.get("weight");
String homeDir = section.get("homeDir");
//
// .. or just use java.util.Map interface...
//
Map<String, String> map = ini.get("happy");
age = map.get("age");
weight = map.get("weight");
homeDir = map.get("homeDir");
// get all section names
Set<String> sectionNames = ini.keySet();
//}
Helper.assertEquals(DwarfsData.happy, section.as(Dwarf.class));
}
示例3: getTransifexConfig
import org.ini4j.Ini; //导入方法依赖的package包/类
public static TransifexConfig getTransifexConfig(String path) throws IOException {
Map<String, String> languageMap = new HashMap<>();
Map<String, TransifexResource> resourceMap = new HashMap<>();
Path localResourcesPath = Settings.getLocalResourcesPath();
Reader reader = localResourcesPath != null ? Files.newBufferedReader(localResourcesPath.resolve(path), StandardCharsets.UTF_8) : new InputStreamReader(Settings.class.getResourceAsStream(Settings.CONFIG_PATH + path), StandardCharsets.UTF_8);
Ini ini = new Ini(reader);
for (String sectionName : ini.keySet()) {
if (sectionName.equals("main")) {
languageMap.putAll(getLanguageMap(ini.get(sectionName).get("lang_map")));
} else {
resourceMap.putAll(getResourceMap(sectionName, ini.get(sectionName)));
}
}
return new TransifexConfig(languageMap, resourceMap);
}
示例4: createFromReaders
import org.ini4j.Ini; //导入方法依赖的package包/类
@VisibleForTesting
static Map<String, Map<String, String>> createFromReaders(Iterable<Reader> readers)
throws IOException {
Preconditions.checkNotNull(readers);
Ini ini = new Ini();
for (Reader reader : readers) {
// The data contained by reader need to be processed twice (first during validation, then
// when merging into ini), so read the data into a string that can be used as the source of
// two StringReaders.
try (Reader r = reader) {
String iniString = CharStreams.toString(r);
validateReader(new StringReader(iniString));
ini.load(new StringReader(iniString));
}
}
Map<String, Map<String, String>> sectionsToEntries = Maps.newHashMap();
for (String sectionName : ini.keySet()) {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
Section section = ini.get(sectionName);
for (String propertyName : section.keySet()) {
String propertyValue = section.get(propertyName);
builder.put(propertyName, propertyValue);
}
ImmutableMap<String, String> sectionToEntries = builder.build();
sectionsToEntries.put(sectionName, sectionToEntries);
}
return sectionsToEntries;
}
示例5: validateReader
import org.ini4j.Ini; //导入方法依赖的package包/类
private static void validateReader(Reader reader) throws IOException {
// Verify that within each ini file, no section has the same key specified more than once.
Ini ini = new Ini();
ini.load(reader);
for (String sectionName : ini.keySet()) {
Section section = ini.get(sectionName);
for (String propertyName : section.keySet()) {
if (section.getAll(propertyName).size() > 1) {
throw new HumanReadableException("Duplicate definition for %s in [%s].",
propertyName,
sectionName);
}
}
}
}
示例6: validateIni
import org.ini4j.Ini; //导入方法依赖的package包/类
private static void validateIni(Ini ini) {
// Verify that no section has the same key specified more than once.
for (String sectionName : ini.keySet()) {
Profile.Section section = ini.get(sectionName);
for (String propertyName : section.keySet()) {
if (section.getAll(propertyName).size() > 1) {
throw new HumanReadableException(
"Duplicate definition for %s in the [%s] section of your .buckconfig or "
+ ".buckconfig.local.",
propertyName, sectionName);
}
}
}
}
示例7: getNames
import org.ini4j.Ini; //导入方法依赖的package包/类
/**
* @return list of data source names
*/
public ImmutableList<String> getNames() {
ImmutableList.Builder<String> builder = new ImmutableList.Builder<String>();
for (Ini ini : inis)
for (String name : ini.keySet())
if (ini.get(name).get("type") != null)
builder.add(name);
return builder.build();
}