|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.foundation.NSValidation.DefaultImplementation
The methods in the NSValidation.DefaultImplementation class are just like the methods defined by the NSValidation interface, except they are static methods and they take an additional argument, which is the object on which the default implementation should operate.
For example, suppose an Employee class implements
NSValidation using NSValidation.DefaultImplementation. Employee's
validateValueForKey
method would then look like this:
public Object validateValueForKey(Object value,String key){ return NSValidation.DefaultImplementation.validateValueForKey(this,value,key)}
The NSValidation.DefaultImplementation methods search for property-specific
methods of the form validateKey
and invoke them if they exist. Thus an
NSValidation class should implement a validate method for each property
that has associated validation logic. For example, a validateAge
method
could check that the value a user enters as an age is within acceptable
limits and throw an NSValidation.ValidationException if it finds an
unacceptable value.
Because custom validation logic was implemented in the validateKey
methods, implementing it from scratch in NSValidation methods is rarely needed.
Rather, the default implementation provided by
NSValidation.DefaultImplementation is generally sufficient.
Note: Always use the default implementation of NSValidation provided by the foundation package. The default implementations have significant performance optimizations. To benefit from them, implement NSValidation on a custom class as shown above by using the methods in NSValidation.DefaultImplementation or, if your class inherits from an WebObjects class that implements NSValidation, don't override the inherited implementation. Using a custom implementation incurs significant performance penalties.
NSValidation.validateValueForKey(java.lang.Object, java.lang.String)
,
NSValidation.validateTakeValueForKeyPath(java.lang.Object, java.lang.String)
Method Summary | |
static Object |
validateTakeValueForKeyPath(Object object,
Object value,
String keyPath)
Confirms that value is legal for an objects's property, which is
named by keyPath , and assigns the value to the property
if it's legal (and if value is different from the current
value). |
static Object |
validateValueForKey(Object object,
Object value,
String key)
Confirms that value is legal for the NSValidation's property,
which is named by key , and returns the validated value if it's
legal, or throws an NSValidation.ValidationException if it isn't. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static Object validateTakeValueForKeyPath(Object object, Object value, String keyPath) throws NSValidation.ValidationException
value
is legal for an objects's property, which is
named by keyPath
, and assigns the value to the property
if it's legal (and if value
is different from the current
value).object
- object on the destination showed by the keypathvalue
- value corresponding to the keypathkeyPath
- relative path of the methodNSValidation.ValidationException
- value
isn't
legal to NSValidationNSValidation.validateTakeValueForKeyPath(java.lang.Object, java.lang.String)
public static Object validateValueForKey(Object object, Object value, String key) throws NSValidation.ValidationException
value
is legal for the NSValidation's property,
which is named by key
, and returns the validated value if it's
legal, or throws an NSValidation.ValidationException if it isn't.object
- object on the destination showed by the keypathvalue
- value corresponding to the keypathkey
- property of object
NSValidation.ValidationException
- value
isn't
legal to NSValidationNSValidation.validateValueForKey(java.lang.Object, java.lang.String)
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |