Package com.dd.plist
Class NSDictionary
java.lang.Object
com.dd.plist.NSObject
com.dd.plist.NSDictionary
The NSDictionary class is a collection of NSObject instances that are identified by strings.
It represents a hash map where the keys are strings and the values NSObject instances.
The implementation is based on a linked hash map, so that the order of the elements in the dictionary is preserved.
You can access the keys through the function allKeys().
Access to the objects stored for each key is given through the function objectForKey(String key).
- See Also:
-
Nested Class Summary
-
Field Summary
FieldsFields inherited from class com.dd.plist.NSObject
ASCII_LINE_LENGTH, NEWLINE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]allKeys()Gets a list of all keys used in this NSDictionary.(package private) voidAssigns IDs to all the objects in this NSObject subtree.voidclear()Removes all key-value pairs from this dictionary.clone()Creates and returns a deep copy of this instance.intbooleancontainsKey(Object key) booleancontainsKey(String key) Checks whether a given key is contained in this dictionary.booleancontainsValue(boolean val) Checks whether a given value is contained in this dictionary.booleancontainsValue(byte[] val) Checks whether a given value is contained in this dictionary.booleancontainsValue(double val) Checks whether a given value is contained in this dictionary.booleancontainsValue(long val) Checks whether a given value is contained in this dictionary.booleancontainsValue(NSObject val) Checks whether a given value is contained in this dictionary.booleancontainsValue(Object value) booleancontainsValue(String val) Checks whether a given value is contained in this dictionary.booleancontainsValue(Date val) Checks whether a given value is contained in this dictionary.intcount()Counts the number of contained key-value pairs.entrySet()booleanGets the hash map which stores the keys and values of this dictionary.inthashCode()booleanisEmpty()keySet()objectForKey(String key) Gets the NSObject stored for the given key.Puts a new key-value pair into this dictionary.Puts a new key-value pair into this dictionary.voidRemoves a key-value pair from this dictionary.intsize()protected voidtoASCII(StringBuilder ascii, int level) Generates the ASCII representation of this object.protected voidtoASCIIGnuStep(StringBuilder ascii, int level) Generates the ASCII representation of this object in the GnuStep format.Generates a valid ASCII property list which has this NSDictionary as its root object.(package private) voidGenerates the binary representation of the object.Generates a valid ASCII property list in GnuStep format which has this NSDictionary as its root object.Converts this NSObject into an equivalent object of the Java Runtime Environment.(package private) voidtoXML(StringBuilder xml, int level) Generates the XML representation of the object (without XML headers or enclosing plist-tags).values()Methods inherited from class com.dd.plist.NSObject
fromJavaObject, indent, toJavaObject, toXMLPropertyListMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
dict
-
-
Constructor Details
-
NSDictionary
public NSDictionary()Creates a new NSDictionary instance.
-
-
Method Details
-
getHashMap
Gets the hash map which stores the keys and values of this dictionary. Changes to the hash map are directly reflected in this dictionary.- Returns:
- The hash map which is used by this dictionary to store its contents.
-
objectForKey
Gets the NSObject stored for the given key.- Parameters:
key- The key.- Returns:
- The object.
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<String,NSObject>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,NSObject>
-
get
-
putAll
-
put
Puts a new key-value pair into this dictionary. If the value is null, no operation will be performed on the dictionary. -
put
Puts a new key-value pair into this dictionary. If key or value are null, no operation will be performed on the dictionary.- Parameters:
key- The key.obj- The value. Supported object types are numbers, byte-arrays, dates, strings and arrays or sets of those.- Returns:
- The value previously associated to the given key, or null, if no value was associated to it.
-
remove
Removes a key-value pair from this dictionary.- Parameters:
key- The key- Returns:
- the value previously associated to the given key.
-
remove
-
clear
public void clear()Removes all key-value pairs from this dictionary. -
keySet
-
values
-
entrySet
-
containsKey
Checks whether a given key is contained in this dictionary.- Parameters:
key- The key that will be searched for.- Returns:
- Whether the key is contained in this dictionary.
-
containsValue
Checks whether a given value is contained in this dictionary.- Parameters:
val- The value that will be searched for.- Returns:
- Whether the key is contained in this dictionary.
-
containsValue
Checks whether a given value is contained in this dictionary.- Parameters:
val- The value that will be searched for.- Returns:
- Whether the key is contained in this dictionary.
-
containsValue
public boolean containsValue(long val) Checks whether a given value is contained in this dictionary.- Parameters:
val- The value that will be searched for.- Returns:
- Whether the key is contained in this dictionary.
-
containsValue
public boolean containsValue(double val) Checks whether a given value is contained in this dictionary.- Parameters:
val- The value that will be searched for.- Returns:
- Whether the key is contained in this dictionary.
-
containsValue
public boolean containsValue(boolean val) Checks whether a given value is contained in this dictionary.- Parameters:
val- The value that will be searched for.- Returns:
- Whether the key is contained in this dictionary.
-
containsValue
Checks whether a given value is contained in this dictionary.- Parameters:
val- The value that will be searched for.- Returns:
- Whether the key is contained in this dictionary.
-
containsValue
public boolean containsValue(byte[] val) Checks whether a given value is contained in this dictionary.- Parameters:
val- The value that will be searched for.- Returns:
- Whether the key is contained in this dictionary.
-
count
public int count()Counts the number of contained key-value pairs.- Returns:
- The size of this NSDictionary.
-
equals
-
allKeys
Gets a list of all keys used in this NSDictionary.- Returns:
- The list of all keys used in this NSDictionary.
-
hashCode
public int hashCode() -
clone
Description copied from class:NSObjectCreates and returns a deep copy of this instance. -
toJavaObject
Description copied from class:NSObjectConverts this NSObject into an equivalent object of the Java Runtime Environment.NSArrayobjects are converted to arrays.NSDictionaryobjects are converted to objects extending theMapclass.NSSetobjects are converted to objects extending theSetclass.NSNumberobjects are converted to primitive number values (int, long, double or boolean).NSStringobjects are converted toStringobjects.NSDataobjects are converted to byte arrays.NSDateobjects are converted toDateobjects.UIDobjects are converted to byte arrays.
- Specified by:
toJavaObjectin classNSObject- Returns:
- A native java object representing this NSObject's value.
-
compareTo
- Specified by:
compareToin interfaceComparable<NSObject>
-
toXML
Description copied from class:NSObjectGenerates the XML representation of the object (without XML headers or enclosing plist-tags).- Specified by:
toXMLin classNSObject- Parameters:
xml- TheStringBuilderonto which the XML representation is appended.level- The indentation level of the object.
-
assignIDs
Description copied from class:NSObjectAssigns IDs to all the objects in this NSObject subtree. -
toBinary
Description copied from class:NSObjectGenerates the binary representation of the object.- Specified by:
toBinaryin classNSObject- Parameters:
out- The output stream to serialize the object to.- Throws:
IOException- If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
-
toASCIIPropertyList
Generates a valid ASCII property list which has this NSDictionary as its root object. The generated property list complies with the format as described in Property List Programming Guide - Old-Style ASCII Property Lists.- Returns:
- ASCII representation of this object.
-
toGnuStepASCIIPropertyList
Generates a valid ASCII property list in GnuStep format which has this NSDictionary as its root object. The generated property list complies with the format as described in GnuStep - NSPropertyListSerialization class documentation- Returns:
- GnuStep ASCII representation of this object.
-
toASCII
Description copied from class:NSObjectGenerates the ASCII representation of this object. The generated ASCII representation does not end with a newline. Complies with the Old-Style ASCII Property Lists definition.- Specified by:
toASCIIin classNSObject- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-
toASCIIGnuStep
Description copied from class:NSObjectGenerates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.- Specified by:
toASCIIGnuStepin classNSObject- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-