本文整理汇总了Java中org.ini4j.Profile.Section.size方法的典型用法代码示例。如果您正苦于以下问题:Java Section.size方法的具体用法?Java Section.size怎么用?Java Section.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ini4j.Profile.Section
的用法示例。
在下文中一共展示了Section.size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseKey
import org.ini4j.Profile.Section; //导入方法依赖的package包/类
private static Object parseKey(Ini ini, Object value)
throws UnsupportedEncodingException {
if (value.getClass() == String.class) {
if (((String) value).startsWith("array_")) {
Section arrSection = ini.get(value);
if (arrSection != null && !arrSection.isEmpty()) {
int arrSectionSize = arrSection.size();
byte[] arr = new byte[arrSectionSize];
Iterator<String> it = arrSection.keySet().iterator();
while (it.hasNext()) {
String v = it.next();
String elIdS = v.substring(2, v.length());
int arrElemInd = Integer.parseInt(elIdS);
arr[arrElemInd] = Byte.parseByte(arrSection.get(v));
}
return arr;
}
return null;
} else if (Boolean.parseBoolean((String) value)) {
return Boolean.parseBoolean((String) value);
} else {
return value;
}
}
return value;
}
示例2: equalTo
import org.ini4j.Profile.Section; //导入方法依赖的package包/类
/**
* Gets a hamcrest matcher that tests whether two Ini objects are equal.
*
* @param expectedValue
* The expected value to core against.
* @return Method safe matcher that will core field equality.
*/
@Factory
public static TypeSafeMatcher<Ini> equalTo(final Ini expectedValue) {
return new TypeSafeMatcher<Ini>() {
@Override
protected boolean matchesSafely(Ini actualValue) {
if (expectedValue.size() != actualValue.size()) {
return false;
}
for (Section expectedSection : expectedValue.values()) {
Section actualSection = actualValue.get(expectedSection.getName());
if (actualSection == null) {
return false;
}
if (expectedSection.size() != actualSection.size()) {
return false;
}
for (Entry<String,String> expectedEntry : expectedSection.entrySet()) {
if (!actualSection.containsKey(expectedEntry.getKey())) {
return false;
}
String actual = actualSection.get(expectedEntry.getKey());
String expected = expectedEntry.getValue();
if ((actual == null && expected != null) || (actual != null && !actual.equals(expected))) {
return false;
}
}
}
return true;
}
@Override
public void describeTo(Description description) {
description.appendValue(expectedValue);
}
};
}