@Override public String stringForKey(final String key) { final NSObject value = dict.objectForKey(key); if(null == value) { return null; } return value.toString(); }
@Override public NSDictionary objectForKey(final String key) { final NSObject value = dict.objectForKey(key); if(null == value) { return null; } if(value instanceof NSDictionary) { return (NSDictionary) value; } log.warn(String.format("Unexpected value type for serialized key %s", key)); return null; }
@Override public String getValue(final String property) { if(null == dictionary) { return null; } final NSObject value = dictionary.objectForKey(property); if(null == value) { log.warn(String.format("No value for key %s in dictionary %s", property, dictionary)); return null; } return value.toString(); }
@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 public <T> List<T> listForKey(final String key) { final NSObject value = dict.objectForKey(key); if(null == value) { return null; } if(value instanceof NSArray) { final NSArray array = (NSArray) value; final List<T> list = new ArrayList<T>(); for(int i = 0; i < array.count(); i++) { final NSObject next = array.objectAtIndex(i); if(next instanceof NSDictionary) { list.add((T) next); } else if(next instanceof NSString) { list.add((T) next.toString()); } else { log.warn(String.format("Ignore content of type %s", next)); } } return list; } log.warn(String.format("Unexpected value type for serialized key %s", key)); return null; }
@Override void toXML(StringBuilder xml, int level) { this.indent(xml, level); xml.append("<dict>"); xml.append(NSObject.NEWLINE); for (String key : this.dict.keySet()) { NSObject val = this.objectForKey(key); this.indent(xml, level + 1); xml.append("<key>"); //According to http://www.w3.org/TR/REC-xml/#syntax node values must not //contain the characters < or &. Also the > character should be escaped. if (key.contains("&") || key.contains("<") || key.contains(">")) { xml.append("<![CDATA["); xml.append(key.replaceAll("]]>", "]]]]><![CDATA[>")); xml.append("]]>"); } else { xml.append(key); } xml.append("</key>"); xml.append(NSObject.NEWLINE); val.toXML(xml, level + 1); xml.append(NSObject.NEWLINE); } this.indent(xml, level); xml.append("</dict>"); }
obj.put("version", rootDict.objectForKey(IPA_BUNDLE_VERSION_KEY).toString()); obj.put("name", rootDict.objectForKey(IPA_BUNDLE_NAME_KEY).toString()); obj.put("package", rootDict.objectForKey(IPA_BUNDLE_IDENTIFIER_KEY).toString()); plist = obj.toJSONString(); } catch (Exception e) {
@Override protected void toASCIIGnuStep(StringBuilder ascii, int level) { this.indent(ascii, level); ascii.append(ASCIIPropertyListParser.DICTIONARY_BEGIN_TOKEN); ascii.append(NEWLINE); String[] keys = this.dict.keySet().toArray(new String[this.dict.size()]); 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.toASCIIGnuStep(ascii, level + 2); } else { ascii.append(' '); val.toASCIIGnuStep(ascii, 0); } ascii.append(ASCIIPropertyListParser.DICTIONARY_ITEM_DELIMITER_TOKEN); ascii.append(NEWLINE); } this.indent(ascii, level); ascii.append(ASCIIPropertyListParser.DICTIONARY_END_TOKEN); } }
throw new InvalidLicenseException(); final NSData signature = (NSData) dictionary.objectForKey("Signature"); if(null == signature) { log.warn(String.format("Missing key 'Signature' in dictionary %s", dictionary)); continue; values.append(dictionary.objectForKey(key).toString());
@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); }