Top Description Fields Constructors Methods
com.dd.plist

public Class NSDictionary

extends NSObject
implements Map<String, NSObject>
Class Inheritance
All Implemented Interfaces
java.util.Map
Imports
java.io.IOException, java.util.*, java.util.stream.Collectors

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).

Author
Daniel Dreibrodt
See Also
Foundation NSDictionary documentation, java.util.LinkedHashMap

Field Summary

Modifier and TypeField and Description
private final HashMap<String, NSObject>
Inherited from com.dd.plist.NSObject:
ASCII_LINE_LENGTHNEWLINE

Constructor Summary

AccessConstructor and Description
public
NSDictionary()

Creates a new NSDictionary instance.

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

The list of all keys used in this NSDictionary.
allKeys
()

Gets a list of all keys used in this NSDictionary.

pack-priv void
assignIDs(BinaryPropertyListWriter out)

Overrides com.dd.plist.NSObject.assignIDs.

Assigns IDs to all the objects in this NSObject subtree.

public void
clear()

Implements java.util.Map.clear.

Removes all key-value pairs from this dictionary.

public NSDictionary
clone()

Implements abstract com.dd.plist.NSObject.clone.

Creates and returns a deep copy of this instance.

public int
compareTo(NSObject o)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public boolean
containsKey(Object key)

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.

public boolean

Returns:

Whether the key is contained in this dictionary.
containsKey
(String
The key that will be searched for.
key
)

Checks whether a given key is contained in this dictionary.

public boolean
containsValue(Object value)

Implements java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.

public boolean

Returns:

Whether the key is contained in this dictionary.
containsValue
(NSObject
The value that will be searched for.
val
)

Checks whether a given value is contained in this dictionary.

public boolean

Returns:

Whether the key is contained in this dictionary.
containsValue
(String
The value that will be searched for.
val
)

Checks whether a given value is contained in this dictionary.

public boolean

Returns:

Whether the key is contained in this dictionary.
containsValue
(long
The value that will be searched for.
val
)

Checks whether a given value is contained in this dictionary.

public boolean

Returns:

Whether the key is contained in this dictionary.
containsValue
(double
The value that will be searched for.
val
)

Checks whether a given value is contained in this dictionary.

public boolean

Returns:

Whether the key is contained in this dictionary.
containsValue
(boolean
The value that will be searched for.
val
)

Checks whether a given value is contained in this dictionary.

public boolean

Returns:

Whether the key is contained in this dictionary.
containsValue
(Date
The value that will be searched for.
val
)

Checks whether a given value is contained in this dictionary.

public boolean

Returns:

Whether the key is contained in this dictionary.
containsValue
(byte[]
The value that will be searched for.
val
)

Checks whether a given value is contained in this dictionary.

public int

Returns:

The size of this NSDictionary.
count
()

Counts the number of contained key-value pairs.

public Set<Map.Entry<String, NSObject>>
entrySet()

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Implements java.util.Map.equals.

Compares the specified object with this map for equality.

public NSObject
get(Object key)

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

public HashMap<String, NSObject>

Returns:

The hash map which is used by this dictionary to store its contents.
getHashMap
()

Gets the hash map which stores the keys and values of this dictionary.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.

public boolean
isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.

public Set<String>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.

public NSObject

Returns:

The object.
objectForKey
(String
The key.
key
)

Gets the NSObject stored for the given key.

public NSObject

Returns:

The value previously associated to the given key, or null, if no value was associated to it.
put
(String
The key.
key
,
NSObject
The value.
obj
)

Implements java.util.Map.put.

Puts a new key-value pair into this dictionary.

public NSObject

Returns:

The value previously associated to the given key, or null, if no value was associated to it.
put
(String
The key.
key
,
Object
The value. Supported object types are numbers, byte-arrays, dates, strings and arrays or sets of those.
obj
)

Implements java.util.Map.put.

Puts a new key-value pair into this dictionary.

public void
putAll(Map<? extends String, ? extends NSObject> values)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).

public NSObject

Returns:

the value previously associated to the given key.
remove
(String
The key
key
)

Removes a key-value pair from this dictionary.

public NSObject
remove(Object key)

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).

public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.

protected void
toASCII(StringBuilder ascii, int level)

Implements abstract com.dd.plist.NSObject.toASCII.

Generates the ASCII representation of this object.

protected void
toASCIIGnuStep(StringBuilder ascii, int level)

Implements abstract com.dd.plist.NSObject.toASCIIGnuStep.

Generates the ASCII representation of this object in the GnuStep format.

public String

Returns:

ASCII representation of this object.
toASCIIPropertyList
()

Generates a valid ASCII property list which has this NSDictionary as its root object.

pack-priv void
toBinary(BinaryPropertyListWriter out)

Implements abstract com.dd.plist.NSObject.toBinary.

Generates the binary representation of the object.

public String

Returns:

GnuStep ASCII representation of this object.
toGnuStepASCIIPropertyList
()

Generates a valid ASCII property list in GnuStep format which has this NSDictionary as its root object.

public Object
toJavaObject()

Implements abstract com.dd.plist.NSObject.toJavaObject.

Converts this NSObject into an equivalent object of the Java Runtime Environment.

pack-priv void
toXML(StringBuilder xml, int level)

Implements abstract com.dd.plist.NSObject.toXML.

Generates the XML representation of the object (without XML headers or enclosing plist-tags).

public Collection<NSObject>
values()

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.

Inherited from com.dd.plist.NSObject:
fromJavaObjectgetLocationInformationindentsetLocationInformationtoJavaObjecttoXMLPropertyList

Field Detail

dictback to summary
private final HashMap<String, NSObject> dict

Constructor Detail

NSDictionaryback to summary
public NSDictionary()

Creates a new NSDictionary instance.

Method Detail

allKeysback to summary
public String[] allKeys()

Gets a list of all keys used in this NSDictionary.

Returns:String[]

The list of all keys used in this NSDictionary.

assignIDsback to summary
pack-priv void assignIDs(BinaryPropertyListWriter out)

Overrides com.dd.plist.NSObject.assignIDs.

Doc from com.dd.plist.NSObject.assignIDs.

Assigns IDs to all the objects in this NSObject subtree.

Annotations
@Override
clearback to summary
public void clear()

Implements java.util.Map.clear.

Removes all key-value pairs from this dictionary.

See Also
java.util.Map#clear()
cloneback to summary
public NSDictionary clone()

Implements abstract com.dd.plist.NSObject.clone.

Doc from com.dd.plist.NSObject.clone.

Creates and returns a deep copy of this instance.

Annotations
@Override
compareToback to summary
public int compareTo(NSObject o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Annotations
@Override
containsKeyback to summary
public boolean containsKey(Object key)

Implements java.util.Map.containsKey.

Doc from java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that Objects.equals(key, k). (There can be at most one such mapping.)

containsKeyback to summary
public boolean containsKey(String key)

Checks whether a given key is contained in this dictionary.

Parameters
key:String

The key that will be searched for.

Returns:boolean

Whether the key is contained in this dictionary.

containsValueback to summary
public boolean containsValue(Object value)

Implements java.util.Map.containsValue.

Doc from java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that Objects.equals(value, v). This operation will probably require time linear in the map size for most implementations of the Map interface.

containsValueback to summary
public boolean containsValue(NSObject val)

Checks whether a given value is contained in this dictionary.

Parameters
val:NSObject

The value that will be searched for.

Returns:boolean

Whether the key is contained in this dictionary.

containsValueback to summary
public boolean containsValue(String val)

Checks whether a given value is contained in this dictionary.

Parameters
val:String

The value that will be searched for.

Returns:boolean

Whether the key is contained in this dictionary.

containsValueback to summary
public boolean containsValue(long val)

Checks whether a given value is contained in this dictionary.

Parameters
val:long

The value that will be searched for.

Returns:boolean

Whether the key is contained in this dictionary.

containsValueback to summary
public boolean containsValue(double val)

Checks whether a given value is contained in this dictionary.

Parameters
val:double

The value that will be searched for.

Returns:boolean

Whether the key is contained in this dictionary.

containsValueback to summary
public boolean containsValue(boolean val)

Checks whether a given value is contained in this dictionary.

Parameters
val:boolean

The value that will be searched for.

Returns:boolean

Whether the key is contained in this dictionary.

containsValueback to summary
public boolean containsValue(Date val)

Checks whether a given value is contained in this dictionary.

Parameters
val:Date

The value that will be searched for.

Returns:boolean

Whether the key is contained in this dictionary.

containsValueback to summary
public boolean containsValue(byte[] val)

Checks whether a given value is contained in this dictionary.

Parameters
val:byte[]

The value that will be searched for.

Returns:boolean

Whether the key is contained in this dictionary.

countback to summary
public int count()

Counts the number of contained key-value pairs.

Returns:int

The size of this NSDictionary.

entrySetback to summary
public Set<Map.Entry<String, NSObject>> entrySet()

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Implements java.util.Map.equals.

Doc from java.util.Map.equals.

Compares the specified object with this map for equality. Returns true if the given object is also a map and the two maps represent the same mappings. More formally, two maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface.

Annotations
@Override
getback to summary
public NSObject get(Object key)

Implements java.util.Map.get.

Doc from java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

getHashMapback to summary
public HashMap<String, NSObject> 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:HashMap<String, NSObject>

The hash map which is used by this dictionary to store its contents.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.hashCode.

Doc from java.util.Map.hashCode.

Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hash codes of each entry in the map's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two maps m1 and m2, as required by the general contract of Object#hashCode.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements java.util.Map.isEmpty.

Doc from java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.

keySetback to summary
public Set<String> keySet()

Implements java.util.Map.keySet.

Doc from java.util.Map.keySet.

Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

objectForKeyback to summary
public NSObject objectForKey(String key)

Gets the NSObject stored for the given key.

Parameters
key:String

The key.

Returns:NSObject

The object.

putback to summary
public NSObject put(String key, NSObject obj)

Implements java.util.Map.put.

Puts a new key-value pair into this dictionary. If the value is null, no operation will be performed on the dictionary.

Parameters
key:String

The key.

obj:NSObject

The value.

Returns:NSObject

The value previously associated to the given key, or null, if no value was associated to it.

putback to summary
public NSObject put(String key, Object obj)

Implements java.util.Map.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:String

The key.

obj:Object

The value. Supported object types are numbers, byte-arrays, dates, strings and arrays or sets of those.

Returns:NSObject

The value previously associated to the given key, or null, if no value was associated to it.

putAllback to summary
public void putAll(Map<? extends String, ? extends NSObject> values)

Implements java.util.Map.putAll.

Doc from java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress. If the specified map has a defined encounter order, processing of its mappings generally occurs in that order.

removeback to summary
public NSObject remove(String key)

Removes a key-value pair from this dictionary.

Parameters
key:String

The key

Returns:NSObject

the value previously associated to the given key.

removeback to summary
public NSObject remove(Object key)

Implements java.util.Map.remove.

Doc from java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

sizeback to summary
public int size()

Implements java.util.Map.size.

Doc from java.util.Map.size.

Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

toASCIIback to summary
protected void toASCII(StringBuilder ascii, int level)

Implements abstract com.dd.plist.NSObject.toASCII.

Doc from com.dd.plist.NSObject.toASCII.

Generates 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.

Annotations
@Override
toASCIIGnuStepback to summary
protected void toASCIIGnuStep(StringBuilder ascii, int level)

Implements abstract com.dd.plist.NSObject.toASCIIGnuStep.

Doc from com.dd.plist.NSObject.toASCIIGnuStep.

Generates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.

Annotations
@Override
toASCIIPropertyListback to summary
public String 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:String

ASCII representation of this object.

toBinaryback to summary
pack-priv void toBinary(BinaryPropertyListWriter out) throws IOException

Implements abstract com.dd.plist.NSObject.toBinary.

Doc from com.dd.plist.NSObject.toBinary.

Generates the binary representation of the object.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
toGnuStepASCIIPropertyListback to summary
public String 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:String

GnuStep ASCII representation of this object.

toJavaObjectback to summary
public Object toJavaObject()

Implements abstract com.dd.plist.NSObject.toJavaObject.

Doc from com.dd.plist.NSObject.toJavaObject.

Converts this NSObject into an equivalent object of the Java Runtime Environment.

Annotations
@Override
toXMLback to summary
pack-priv void toXML(StringBuilder xml, int level)

Implements abstract com.dd.plist.NSObject.toXML.

Doc from com.dd.plist.NSObject.toXML.

Generates the XML representation of the object (without XML headers or enclosing plist-tags).

Annotations
@Override
valuesback to summary
public Collection<NSObject> values()

Implements java.util.Map.values.

Doc from java.util.Map.values.

Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.