@Override public void setStringForKey(final String value, final String key) { dict.put(key, value); }
public void putAll(Map<? extends String, ? extends NSObject> values) { for (Object object : values.entrySet()) { @SuppressWarnings("unchecked") Map.Entry<String, NSObject> entry = (Map.Entry<String, NSObject>) object; this.put(entry.getKey(), entry.getValue()); } }
/** * Puts a new key-value pair into this dictionary. * If key or value are null, no operation will be performed on the dictionary. * * @param key The key. * @param obj The value. Supported object types are numbers, byte-arrays, dates, strings and arrays or sets of those. * @return The value previously associated to the given key, * or null, if no value was associated to it. */ public NSObject put(String key, Object obj) { return this.put(key, NSObject.fromJavaObject(obj)); }
static byte[] createPList(Map<String, ? extends Object> properties) throws IOException { ByteArrayOutputStream plistOutputStream = new ByteArrayOutputStream(); NSDictionary root = new NSDictionary(); for (Map.Entry<String, ? extends Object> property : properties.entrySet()) { root.put(property.getKey(), property.getValue()); } PropertyListParser.saveAsBinary(root, plistOutputStream); return plistOutputStream.toByteArray(); }
private static NSDictionary fromMap(Map<?, ?> map) { NSDictionary result = new NSDictionary(); for (Map.Entry entry : map.entrySet()) { if (!(entry.getKey() instanceof String)) { throw new IllegalArgumentException("Maps need a String key for mapping to NSDictionary."); } result.put((String) entry.getKey(), fromJavaObject(entry.getValue())); } return result; }
public byte[] encoded() { try { NSDictionary dict = new NSDictionary(); dict.put("escrowedKeys", new NSData(escrowedKeys)); dict.put("deviceUuid", new NSString(deviceUuid.toString())); dict.put("deviceHardWareId", new NSString(deviceHardWareId)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PropertyListParser.saveAsBinary(dict, baos); return baos.toByteArray(); } catch (IOException ex) { throw new IllegalStateException(ex); } }
@Override public void setObjectForKey(final Serializable value, final String key) { dict.put(key, value.<NSDictionary>serialize(SerializerFactory.get())); }
result.put(name, fromJavaObject(method.invoke(object))); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Could not access getter " + method.getName()); result.put(field.getName(), fromJavaObject(field.get(object))); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Could not access field " + field.getName());
@Override public <T extends Serializable> void setListForKey(final List<T> value, final String key) { final NSArray list = new NSArray(value.size()); int i = 0; for(Serializable serializable : value) { list.setValue(i, serializable.<NSDictionary>serialize(SerializerFactory.get())); i++; } dict.put(key, list); }
public static NSObject toNsObject(JsonObject o) { NSDictionary dict = new NSDictionary(); o.forEach((k,v) -> { if(v.isObject()) { dict.put(k, toNsObject(v.asObject())); } else if(v.isArray()) { dict.put(k, toNsObject(v.asArray())); } else { dict.put(k, toNsObject(v.asPrimitive())); } }); return dict; }
dict.put(keyString, parseObject(val));
dict.put(keyString, object); this.skipWhitespacesAndComments(); this.read(DICTIONARY_ITEM_DELIMITER_TOKEN);
NSObject val = this.parseObject(valRef); assert key != null; //Encountering a null object at this point would either be a fundamental error in the parser or an error in the property list dict.put(key.toString(), val);