WebObjects 5.2.3

com.webobjects.foundation
Class NSValidation.Utility

java.lang.Object
  extended bycom.webobjects.foundation.NSValidation.Utility
Enclosing class:
NSValidation

public static class NSValidation.Utility
extends Object

This class is a convenience that allows you to access the properties of NSValidation objects and non-NSValidation objects using the same code.

Utility's methods are similar to DefaultImplementation's methods in that they are static methods and they take an extra argument -- the object on which the method should operate. However, Utility's methods simply check to see whether the object on which they operate is an NSValidation object and invoke the corresponding NSValidation method on the object if it is. Otherwise, they invoke the corresponding DefaultImplementation method, passing the object on which to operate.

For example, to access an object with the NSValidation API but it is not known if the object is an NSValidation object. To do so, the corresponding Utility API is used , as in the following line of code:

theValue = NSValidation.Utility.validateValueForKey(object,value,key);
The above line of code is simply a shortcut for the following:
if (object instanceof NSValidation) { theValue =((NSValidation)object).validateValueForKey(key); } else { theValue =validateValueForKey.DefaultImplementation.validateValueForKey( object,value,key); }


Method Summary
static Object validateTakeValueForKeyPath(Object object, Object value, String keyPath)
          If object is an NSValidation, invokes validateTakeValueForKeyPath on object; otherwise invokes NSValidation.DefaultImplementation's validateTakeValueForKeyPath method with object as the object on which to operate.
static Object validateValueForKey(Object object, Object value, String key)
          If object is an NSValidation, invokes validateValueForKey on object; otherwise invokes NSValidation.DefaultImplementation's validateValueForKey method with object as the object on which to operate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

validateTakeValueForKeyPath

public static Object validateTakeValueForKeyPath(Object object,
                                                 Object value,
                                                 String keyPath)
                                          throws NSValidation.ValidationException
If object is an NSValidation, invokes validateTakeValueForKeyPath on object; otherwise invokes NSValidation.DefaultImplementation's validateTakeValueForKeyPath method with object as the object on which to operate.

Parameters:
object - object on the destination showed by the keypath
value - value corresponding to the keypath
keyPath - relative path of the method
Returns:
object if all the values associated with it are legal; otherwise, the default object
Throws:
NSValidation.ValidationException - value isn't legal to NSValidation
See Also:
NSValidation.validateTakeValueForKeyPath(java.lang.Object, java.lang.String), NSValidation.DefaultImplementation

validateValueForKey

public static Object validateValueForKey(Object object,
                                         Object value,
                                         String key)
                                  throws NSValidation.ValidationException
If object is an NSValidation, invokes validateValueForKey on object; otherwise invokes NSValidation.DefaultImplementation's validateValueForKey method with object as the object on which to operate.

Parameters:
object - object on the destination showed by the keypath
value - value corresponding to the keypath
key - property of object
Returns:
object if all the values associated with it are legal; otherwise, the default object
Throws:
NSValidation.ValidationException - value isn't legal to NSValidation
See Also:
NSValidation.validateValueForKey(java.lang.Object, java.lang.String), NSValidation.DefaultImplementation

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.