@Override public Map<String, String> mapForKey(final String key) { final NSObject value = dict.objectForKey(key); if(null == value) { return null; } if(value instanceof NSDictionary) { final NSDictionary dict = (NSDictionary) value; final Map<String, String> map = new HashMap<>(); for(String k : dict.allKeys()) { map.put(k, dict.objectForKey(k).toString()); } return map; } log.warn(String.format("Unexpected value type for serialized key %s", key)); return null; }
@Override protected void toASCII(StringBuilder ascii, int level) { this.indent(ascii, level); ascii.append(ASCIIPropertyListParser.DICTIONARY_BEGIN_TOKEN); ascii.append(NEWLINE); String[] keys = this.allKeys(); for (String key : keys) { NSObject val = this.objectForKey(key); this.indent(ascii, level + 1); ascii.append('"'); ascii.append(NSString.escapeStringForASCII(key)); ascii.append("\" ="); Class<?> objClass = val.getClass(); if (objClass.equals(NSDictionary.class) || objClass.equals(NSArray.class) || objClass.equals(NSData.class)) { ascii.append(NEWLINE); val.toASCII(ascii, level + 2); } else { ascii.append(' '); val.toASCII(ascii, 0); } ascii.append(ASCIIPropertyListParser.DICTIONARY_ITEM_DELIMITER_TOKEN); ascii.append(NEWLINE); } this.indent(ascii, level); ascii.append(ASCIIPropertyListParser.DICTIONARY_END_TOKEN); }