WebObjects 5.4.2

com.webobjects.foundation
Class NSKeyValueCoding.DefaultImplementation

java.lang.Object
  extended by com.webobjects.foundation.NSKeyValueCoding.DefaultImplementation
Enclosing interface:
NSKeyValueCoding

public static class NSKeyValueCoding.DefaultImplementation
extends Object

The NSKeyValueCoding.DefaultImplementation class provides the WebObjects default implementations of the NSKeyValueCoding and NSKeyValueCoding.ErrorHandling interfaces.

See Also:
NSKeyValueCoding.ErrorHandling, NSKeyValueCoding

Method Summary
static Object handleQueryWithUnboundKey(Object object, String key)
          Invoked from valueForKey when it finds no property binding for key.
static void handleTakeValueForUnboundKey(Object object, Object value, String key)
          Throws an NSKeyValueCoding.UnknownKeyException with object as the exception's object and key as the exception's key.
static void takeValueForKey(Object object, Object value, String key)
          Sets object's property identified by key to value, or invokes handleTakeValueForUnboundKey.
static void unableToSetNullForKey(Object object, String key)
          Invoked from takeValueForKey when it is given a null value for a scalar property (such as an int or a float).
static Object valueForKey(Object object, String key)
          Retrieves the value associated with the property named key on object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

valueForKey

public static Object valueForKey(Object object,
                                 String key)
Retrieves the value associated with the property named key on object.

The default implementation searches first for a method and (if canAccessFieldsDirectly is true) for instance variables matching key. For example, for key "foo" the search order is as follows: (a) method "getFoo"; (b) method "foo"; (c) method "isFoo"; (d) method "_getFoo"; (e) method "_foo"; (f) method "_isFoo"; (g) field "_foo"; (h) field "_isFoo"; (i) field "foo"; (j) field "isFoo". If an unknown key is encountered and the object implements the NSKeyValueCoding.ErrorHandling interface, handleQueryWithUnboundKey is invoked, otherwise a NSKeyValueCoding.UnknownKeyException is raised.

Parameters:
object - the object to operate upon
key - identifies the property to retrieve
Returns:
object's value for the property identified by key, or invokes handleQueryWithUnboundKey
See Also:
NSKeyValueCoding.valueForKey(java.lang.String)

takeValueForKey

public static void takeValueForKey(Object object,
                                   Object value,
                                   String key)
Sets object's property identified by key to value, or invokes handleTakeValueForUnboundKey.

The default implementation searches for a method or instance variable fitting a pattern for the key. For example, for key "foo" the search order is as follows: (a) method "setFoo"; (b) method "_setFoo"; (c) field "_foo"; (d) field "_isFoo"; (e) field "foo"; (f) field "isFoo". If an unknown key is encountered and the object implements the NSKeyValueCoding.ErrorHandling interface, handleTakeValueForUnboundKey is invoked, otherwise a NSKeyValueCoding.UnknownKeyException is raised.

Parameters:
object - object whose property is set to value
value - key is set to this value
key - identifies the property of an object
See Also:
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)

handleQueryWithUnboundKey

public static Object handleQueryWithUnboundKey(Object object,
                                               String key)
Invoked from valueForKey when it finds no property binding for key. The default implementation raises an NSKeyValueCoding.UnknownKeyException.

Parameters:
object - the object involved in the error
key - the key which generated the bad query
Returns:
custom implementations may return any Object instead of throwing an UnknownKeyException
Throws:
an - NSKeyValueCoding.UnknownKeyException with object as the exception's object and key as the exception's key
See Also:
NSKeyValueCoding.valueForKey(java.lang.String), NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.UnknownKeyException

handleTakeValueForUnboundKey

public static void handleTakeValueForUnboundKey(Object object,
                                                Object value,
                                                String key)
Throws an NSKeyValueCoding.UnknownKeyException with object as the exception's object and key as the exception's key. Invoked from takeValueForKey when it finds no property binding for key. The default implementation raises an NSKeyValueCoding.UnknownKeyException

Parameters:
object - the object involved in the error
value - the value which could not be set
key - the key which generated the error
Throws:
NSKeyValueCoding.UnknownKeyException - when it finds no property binding for key
See Also:
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), NSKeyValueCoding.ErrorHandling

unableToSetNullForKey

public static void unableToSetNullForKey(Object object,
                                         String key)
Invoked from takeValueForKey when it is given a null value for a scalar property (such as an int or a float). The default implementation raises an IllegalArgumentException.

Parameters:
object - the object whose value is to be set
key - the key which generated the error
Throws:
IllegalArgumentException - when it is given a null value for a scalar property
See Also:
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), NSKeyValueCoding.ErrorHandling

Last updated June 2008

Copyright © 2000-2008 Apple Inc.