本文整理汇总了Java中java.util.TreeMap.toString方法的典型用法代码示例。如果您正苦于以下问题:Java TreeMap.toString方法的具体用法?Java TreeMap.toString怎么用?Java TreeMap.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.TreeMap
的用法示例。
在下文中一共展示了TreeMap.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testToString
import java.util.TreeMap; //导入方法依赖的package包/类
/**
* toString contains toString of elements
*/
public void testToString() {
TreeMap map = map5();
String s = map.toString();
for (int i = 1; i <= 5; ++i) {
assertTrue(s.contains(String.valueOf(i)));
}
}
示例2: toString
import java.util.TreeMap; //导入方法依赖的package包/类
@Override
public String toString() {
final Class<?> thisClass = getClass();
final TreeMap<String,Object> values = new TreeMap<>();
for (final Field f : thisClass.getDeclaredFields()) {
if (ReadWriteLock.class.isAssignableFrom(f.getClass())) continue;
if ((f.getModifiers() & Modifier.STATIC) != 0) continue;
try {
values.put(f.getName(), f.get(this));
} catch (final IllegalAccessException e) {
values.put(f.getName(), "<THIS SHOULD NOT HAPPEN>");
}
}
return values.toString();
}
示例3: parseOneWordList
import java.util.TreeMap; //导入方法依赖的package包/类
/**
* Parse one JSON-formatted word list metadata.
* @param reader the reader containing the data.
* @return a WordListMetadata object from the parsed data.
* @throws IOException if the underlying reader throws IOException during reading.
*/
private static WordListMetadata parseOneWordList(final JsonReader reader)
throws IOException, BadFormatException {
final TreeMap<String, String> arguments = new TreeMap<>();
reader.beginObject();
while (reader.hasNext()) {
final String name = reader.nextName();
if (!TextUtils.isEmpty(name)) {
arguments.put(name, reader.nextString());
}
}
reader.endObject();
if (TextUtils.isEmpty(arguments.get(ID_FIELD_NAME))
|| TextUtils.isEmpty(arguments.get(LOCALE_FIELD_NAME))
|| TextUtils.isEmpty(arguments.get(DESCRIPTION_FIELD_NAME))
|| TextUtils.isEmpty(arguments.get(UPDATE_FIELD_NAME))
|| TextUtils.isEmpty(arguments.get(FILESIZE_FIELD_NAME))
|| TextUtils.isEmpty(arguments.get(CHECKSUM_FIELD_NAME))
|| TextUtils.isEmpty(arguments.get(REMOTE_FILENAME_FIELD_NAME))
|| TextUtils.isEmpty(arguments.get(VERSION_FIELD_NAME))
|| TextUtils.isEmpty(arguments.get(FORMATVERSION_FIELD_NAME))) {
throw new BadFormatException(arguments.toString());
}
// TODO: need to find out whether it's bulk or update
// The null argument is the local file name, which is not known at this time and will
// be decided later.
return new WordListMetadata(
arguments.get(ID_FIELD_NAME),
MetadataDbHelper.TYPE_BULK,
arguments.get(DESCRIPTION_FIELD_NAME),
Long.parseLong(arguments.get(UPDATE_FIELD_NAME)),
Long.parseLong(arguments.get(FILESIZE_FIELD_NAME)),
arguments.get(RAW_CHECKSUM_FIELD_NAME),
arguments.get(CHECKSUM_FIELD_NAME),
MetadataDbHelper.DICTIONARY_RETRY_THRESHOLD /* retryCount */,
null,
arguments.get(REMOTE_FILENAME_FIELD_NAME),
Integer.parseInt(arguments.get(VERSION_FIELD_NAME)),
Integer.parseInt(arguments.get(FORMATVERSION_FIELD_NAME)),
0, arguments.get(LOCALE_FIELD_NAME));
}