當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeMap.toString方法代碼示例

本文整理匯總了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)));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TreeMapTest.java

示例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();
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:16,代碼來源:RuntimeConfiguration.java

示例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));
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:47,代碼來源:MetadataParser.java


注:本文中的java.util.TreeMap.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。