net.wotonomy.foundation
Class NSDictionary

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by net.wotonomy.foundation.NSDictionary
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map, NSKeyValueCoding
Direct Known Subclasses:
NSMutableDictionary

public class NSDictionary
extends java.util.HashMap
implements NSKeyValueCoding

A pure java implementation of NSDictionary that implements Map for greater java interoperability.

Version:
$Revision: 893 $
Author:
michael@mpowers.net, cgruber@israfil.net, $Author: cgruber $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.wotonomy.foundation.NSKeyValueCoding
NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.Null, NSKeyValueCoding.Utility
 
Field Summary
static NSDictionary EmptyDictionary
           
 
Fields inherited from interface net.wotonomy.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
NSDictionary()
          Default constructor produces an empty dictionary.
NSDictionary(int initialCapacity)
          Constructor produces an empty dictionary with an initial capacity.
NSDictionary(java.util.Map aMap)
          Produces a dictionary that is a copy of the specified map (or dictionary).
NSDictionary(java.lang.Object[] objects, java.lang.Object[] keys)
          Produces a dictionary containing the specified keys and values.
NSDictionary(java.lang.Object key, java.lang.Object value)
          Produces a dictionary that contains one key referencing one value.
 
Method Summary
 NSArray allKeys()
          Returns an NSArray containing all keys in this dictionary.
 NSArray allKeysForObject(java.lang.Object value)
          Returns an NSArray containing all keys that reference the specified value.
 NSArray allValues()
          Returns an NSArray containing all values in this dictionary.
 int count()
          Returns a count of the key-value pairs in this dictionary.
 java.lang.Object handleQueryWithUnboundKey(java.lang.String aKey)
          Called by valueForKey when the specified key is not found on this object.
 void handleTakeValueForUnboundKey(java.lang.Object aValue, java.lang.String aKey)
          Called by takeValueForKey when the specified key is not found on this object.
 boolean isEqualToDictionary(NSDictionary aDictionary)
          Returns whether the specified dictionary has the same or equivalent key-value pairs as this dictionary.
 java.util.Enumeration keyEnumerator()
          Returns an enumeration over the keys in this dictionary.
 java.util.Enumeration objectEnumerator()
          Returns an enumeration over the values in this dictionary.
 java.lang.Object objectForKey(java.lang.Object aKey)
          Returns the value for the specified key, or null if the key is not found.
 NSArray objectsForKeys(NSArray anArray, java.lang.Object aMarker)
          Returns an array of objects for the specified array of keys.
 java.lang.Object storedValueForKey(java.lang.String aKey)
          Returns the value for the private field that corresponds to the specified property.
 void takeStoredValueForKey(java.lang.Object aValue, java.lang.String aKey)
          Sets the the private field that corresponds to the specified property to the specified value.
 void takeValueForKey(java.lang.Object aValue, java.lang.String aKey)
          Sets the property to the specified value.
 java.lang.String toString()
           
 void unableToSetNullForKey(java.lang.String aKey)
          Called by takeValueForKey when the type of the specified key is not allowed to be null, as is the case with primitive types.
 java.lang.Object validateTakeValueForKeyPath(java.lang.Object aValue, java.lang.String aKey)
           
 java.lang.Object valueForKey(java.lang.String aKey)
          Returns the value for the specified property.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

EmptyDictionary

public static final NSDictionary EmptyDictionary
Constructor Detail

NSDictionary

public NSDictionary()
Default constructor produces an empty dictionary.


NSDictionary

public NSDictionary(int initialCapacity)
Constructor produces an empty dictionary with an initial capacity.


NSDictionary

public NSDictionary(java.lang.Object key,
                    java.lang.Object value)
Produces a dictionary that contains one key referencing one value.


NSDictionary

public NSDictionary(java.lang.Object[] objects,
                    java.lang.Object[] keys)
Produces a dictionary containing the specified keys and values. An IllegalArgumentException is thrown if the arrays are not of the same length.


NSDictionary

public NSDictionary(java.util.Map aMap)
Produces a dictionary that is a copy of the specified map (or dictionary).

Method Detail

count

public int count()
Returns a count of the key-value pairs in this dictionary.


allKeys

public NSArray allKeys()
Returns an NSArray containing all keys in this dictionary.


allKeysForObject

public NSArray allKeysForObject(java.lang.Object value)
Returns an NSArray containing all keys that reference the specified value.


allValues

public NSArray allValues()
Returns an NSArray containing all values in this dictionary.


isEqualToDictionary

public boolean isEqualToDictionary(NSDictionary aDictionary)
Returns whether the specified dictionary has the same or equivalent key-value pairs as this dictionary.


objectsForKeys

public NSArray objectsForKeys(NSArray anArray,
                              java.lang.Object aMarker)
Returns an array of objects for the specified array of keys. If a key isn't found, the marker parameter will be placed in the corresponding index(es) in the returned array.


keyEnumerator

public java.util.Enumeration keyEnumerator()
Returns an enumeration over the keys in this dictionary.


objectEnumerator

public java.util.Enumeration objectEnumerator()
Returns an enumeration over the values in this dictionary.


objectForKey

public java.lang.Object objectForKey(java.lang.Object aKey)
Returns the value for the specified key, or null if the key is not found.


valueForKey

public java.lang.Object valueForKey(java.lang.String aKey)
Description copied from interface: NSKeyValueCoding
Returns the value for the specified property. If the property does not exist, this method should call handleQueryWithUnboundKey.

Specified by:
valueForKey in interface NSKeyValueCoding

takeValueForKey

public void takeValueForKey(java.lang.Object aValue,
                            java.lang.String aKey)
Description copied from interface: NSKeyValueCoding
Sets the property to the specified value. If the property does not exist, this method should call handleTakeValueForUnboundKey. If the property is of a type that cannot allow null (e.g. primitive types) and aValue is null, this method should call unableToSetNullForKey.

Specified by:
takeValueForKey in interface NSKeyValueCoding

storedValueForKey

public java.lang.Object storedValueForKey(java.lang.String aKey)
Description copied from interface: NSKeyValueCoding
Returns the value for the private field that corresponds to the specified property.

Specified by:
storedValueForKey in interface NSKeyValueCoding

takeStoredValueForKey

public void takeStoredValueForKey(java.lang.Object aValue,
                                  java.lang.String aKey)
Description copied from interface: NSKeyValueCoding
Sets the the private field that corresponds to the specified property to the specified value.

Specified by:
takeStoredValueForKey in interface NSKeyValueCoding

handleQueryWithUnboundKey

public java.lang.Object handleQueryWithUnboundKey(java.lang.String aKey)
Description copied from interface: NSKeyValueCoding
Called by valueForKey when the specified key is not found on this object. Implementing classes should handle the specified value or otherwise throw an exception.

Specified by:
handleQueryWithUnboundKey in interface NSKeyValueCoding

handleTakeValueForUnboundKey

public void handleTakeValueForUnboundKey(java.lang.Object aValue,
                                         java.lang.String aKey)
Description copied from interface: NSKeyValueCoding
Called by takeValueForKey when the specified key is not found on this object. Implementing classes should handle the specified value or otherwise throw an exception.

Specified by:
handleTakeValueForUnboundKey in interface NSKeyValueCoding

unableToSetNullForKey

public void unableToSetNullForKey(java.lang.String aKey)
Description copied from interface: NSKeyValueCoding
Called by takeValueForKey when the type of the specified key is not allowed to be null, as is the case with primitive types. Implementing classes should handle this case appropriately or otherwise throw an exception.

Specified by:
unableToSetNullForKey in interface NSKeyValueCoding

validateTakeValueForKeyPath

public java.lang.Object validateTakeValueForKeyPath(java.lang.Object aValue,
                                                    java.lang.String aKey)

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractMap


Copyright © 2006 null. All Rights Reserved.