net.wotonomy.control.internal
Class Surrogate

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

public class Surrogate
extends net.wotonomy.foundation.NSMutableDictionary

A Surrogate is a special object that can be used in a display group when you wish to emulate other objects or modify their behaviors. Because it is a Map, it makes use of Introspector's ability to treat keys in a map as if they were properties to implement the following features.

Author:
michael@mpowers.net
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.wotonomy.foundation.NSKeyValueCoding
net.wotonomy.foundation.NSKeyValueCoding.DefaultImplementation, net.wotonomy.foundation.NSKeyValueCoding.Null, net.wotonomy.foundation.NSKeyValueCoding.Utility
 
Field Summary
protected  java.lang.Object defaultValue
           
protected  java.lang.Object[] delegates
           
 
Fields inherited from class net.wotonomy.foundation.NSDictionary
EmptyDictionary
 
Fields inherited from interface net.wotonomy.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
Surrogate()
          Default constructor with no delegate object and no default value.
Surrogate(java.lang.Object aDefault)
          Constructor specifying a default value.
Surrogate(java.lang.Object[] aDelegateArray)
          Constructor specifying a delegate object.
Surrogate(java.lang.Object[] aDelegateArray, java.lang.Object aDefault)
          Constructor specifying a delegate object and a default value.
 
Method Summary
 java.lang.Object directGet(java.lang.Object aKey)
          Called by get to retrieve a value from the internal map.
 java.lang.Object directPut(java.lang.Object aKey, java.lang.Object aValue)
          Called by put to retrieve a value from the internal map.
 boolean equals(java.lang.Object anObject)
          Overridden to compare by reference.
 java.lang.Object get(java.lang.Object aKey)
          Overridden to consult each delegate before checking the internal list of keys.
 java.lang.Object getDefaultValue()
          Returns the current default value, or null if no default exists.
 java.lang.Object getDelegate()
          Returns the first delegate object, or null if no delegates exist.
 java.lang.Object[] getDelegates()
          Returns the list of delegates in the order in which they are consulted.
 java.lang.Object put(java.lang.Object aKey, java.lang.Object aValue)
          Overridden to attempt to write each delegate, writing to only the first successful delegate, before storing the value in the internal map.
 void setDefaultValue(java.lang.Object aDefault)
          Sets the default value.
 void setDelegate(java.lang.Object aDelegate)
          Sets the delegate object list to contain only the specified object.
 void setDelegates(java.lang.Object[] aDelegateArray)
          Sets the list of delegates in the order in which they will be consulted.
 
Methods inherited from class net.wotonomy.foundation.NSMutableDictionary
addEntriesFromDictionary, removeAllObjects, removeObjectForKey, removeObjectsForKeys, setDictionary, setObjectForKey
 
Methods inherited from class net.wotonomy.foundation.NSDictionary
allKeys, allKeysForObject, allValues, count, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, isEqualToDictionary, keyEnumerator, objectEnumerator, objectForKey, objectsForKeys, storedValueForKey, takeStoredValueForKey, takeValueForKey, toString, unableToSetNullForKey, validateTakeValueForKeyPath, valueForKey
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
hashCode
 

Field Detail

delegates

protected java.lang.Object[] delegates

defaultValue

protected java.lang.Object defaultValue
Constructor Detail

Surrogate

public Surrogate()
Default constructor with no delegate object and no default value.


Surrogate

public Surrogate(java.lang.Object[] aDelegateArray)
Constructor specifying a delegate object.


Surrogate

public Surrogate(java.lang.Object aDefault)
Constructor specifying a default value.


Surrogate

public Surrogate(java.lang.Object[] aDelegateArray,
                 java.lang.Object aDefault)
Constructor specifying a delegate object and a default value.

Method Detail

getDelegate

public java.lang.Object getDelegate()
Returns the first delegate object, or null if no delegates exist.


setDelegate

public void setDelegate(java.lang.Object aDelegate)
Sets the delegate object list to contain only the specified object.


getDelegates

public java.lang.Object[] getDelegates()
Returns the list of delegates in the order in which they are consulted.


setDelegates

public void setDelegates(java.lang.Object[] aDelegateArray)
Sets the list of delegates in the order in which they will be consulted.


getDefaultValue

public java.lang.Object getDefaultValue()
Returns the current default value, or null if no default exists.


setDefaultValue

public void setDefaultValue(java.lang.Object aDefault)
Sets the default value.


directGet

public java.lang.Object directGet(java.lang.Object aKey)
Called by get to retrieve a value from the internal map. This implementation simply calls super.get().


directPut

public java.lang.Object directPut(java.lang.Object aKey,
                                  java.lang.Object aValue)
Called by put to retrieve a value from the internal map. This implementation simply calls super.put().


get

public java.lang.Object get(java.lang.Object aKey)
Overridden to consult each delegate before checking the internal list of keys. No matching key is found, returns the default object, or null if no default object exists.

Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.HashMap

put

public java.lang.Object put(java.lang.Object aKey,
                            java.lang.Object aValue)
Overridden to attempt to write each delegate, writing to only the first successful delegate, before storing the value in the internal map.

Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.HashMap

equals

public boolean equals(java.lang.Object anObject)
Overridden to compare by reference.

Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.util.AbstractMap


Copyright © 2006 null. All Rights Reserved.