Java Code Examples for java.util.TreeMap#toString()
The following examples show how to use
java.util.TreeMap#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowMetadata.java From xpra-client with GNU General Public License v3.0 | 6 votes |
@Override public String toString() { TreeMap<String, Object> m = new TreeMap<>(); for(Entry<String, Object> e : meta.entrySet()) { if(e.getValue() instanceof List) { @SuppressWarnings("unchecked") List<Object> list = new ArrayList<>((List<Object>) e.getValue()); for(int i = 0; i < list.size(); ++i) { if(list.get(i) instanceof byte[]) { list.set(i, asString(list.get(i))); } } m.put(e.getKey(), list); } else if(e.getValue() instanceof byte[]) { m.put(e.getKey(), asString(e.getValue())); } else { m.put(e.getKey(), e.getValue()); } } return m.toString(); }
Example 2
Source File: DisambiguatePropertiesTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** Sorts the map and converts to a string for comparison purposes. */ private <T> String mapToString(Multimap<String, Collection<T>> map) { TreeMap<String, String> retMap = Maps.newTreeMap(); for (String key : map.keySet()) { TreeSet<String> treeSet = Sets.newTreeSet(); for (Collection<T> collection : map.get(key)) { Set<String> subSet = Sets.newTreeSet(); for (T type : collection) { subSet.add(type.toString()); } treeSet.add(subSet.toString()); } retMap.put(key, treeSet.toString()); } return retMap.toString(); }
Example 3
Source File: TreeMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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))); } }
Example 4
Source File: RuntimeConfiguration.java From BUbiNG with Apache License 2.0 | 5 votes |
@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(); }
Example 5
Source File: TreeMapTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * 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))); } }
Example 6
Source File: RexProgramTest.java From calcite with Apache License 2.0 | 5 votes |
/** Converts a map to a string, sorting on the string representation of its * keys. */ private static String getString(ImmutableMap<RexNode, RexNode> map) { final TreeMap<String, RexNode> map2 = new TreeMap<>(); for (Map.Entry<RexNode, RexNode> entry : map.entrySet()) { map2.put(entry.getKey().toString(), entry.getValue()); } return map2.toString(); }
Example 7
Source File: Importer.java From jelectrum with MIT License | 5 votes |
public String getThreadStatusReport() { TreeMap<String, Integer> status_map = new TreeMap<String, Integer>(); for(StatusContext t : save_thread_list) { String status = t.getStatus(); if (!status_map.containsKey(status)) { status_map.put(status, 0); } status_map.put(status, status_map.get(status) + 1); } return status_map.toString(); }
Example 8
Source File: MetadataParser.java From Android-Keyboard with Apache License 2.0 | 4 votes |
/** * 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)); }
Example 9
Source File: MetadataParser.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 4 votes |
/** * 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)); }
Example 10
Source File: MetadataParser.java From Indic-Keyboard with Apache License 2.0 | 4 votes |
/** * 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)); }