* EOControl/EOClassDescription.h/m

([NSObject-validateTakeValue:forKeyPath:]): Implement.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@25619 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ayers 2007-11-27 20:03:43 +00:00
parent 994267c549
commit 5d02da4a57
4 changed files with 57 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2007-11-27 David Ayers <ayers@fsfe.org>
* EOControl/EOClassDescription.h/m
([NSObject-validateTakeValue:forKeyPath:]): Implement.
2007-11-21 David Ayers <ayers@fsfe.org>
* EOAdaptors/PostgreSQLAdaptor/Makefile.preamble

View file

@ -141,6 +141,7 @@ fromFetchInEditingContext: (EOEditingContext *)editingContext;
- (NSString *)userPresentableDescription;
- (NSException *)validateValue: (id *)valueP forKey: (NSString *)key;
- (id)validateTakeValue:(id)value forKeyPath:(NSString *)path;
- (NSException *)validateForSave;

View file

@ -712,6 +712,51 @@ fromInsertionInEditingContext: (EOEditingContext *)editingContext
return nil;
}
/**
* This method is called to validate and potentially coerce
* VALUE for the receivers key path. This method also assigns
* the value if it is different from the current value.
* This method will raise an EOValidationException
* if validateValue:forKey: returns an exception.
* This method returns new value.
**/
- (id)validateTakeValue:(id)value forKeyPath:(NSString *)path
{
id val = value;
id obj = self;
NSString *lastKey = path;
NSException *e;
/* AYERS: This needs to be verified...
normally we would travers the key path so that each
object has a chance to override this method the
same way we allow this for take value for key.
But for now lets assume that we can take this shortcut.
*/
NSRange r = [path rangeOfString: @"."
options: NSBackwardsSearch];
if (r.length)
{
NSString *keyPath = [aKey substringToIndex: r.location];
lastKey = [aKey substringFromIndex: NSMaxRange(r)];
obj = [self valueForKey: keyPath];
}
e = [obj validateValue:&val forKey:lastKey];
if (e)
{
[e raise];
}
else
{
[obj takeValue:val forKey: lastKey];
}
return val;
}
@end
@implementation EOClassDescription (Deprecated)

6
TODO
View file

@ -1,3 +1,9 @@
EOControl:
validateTakeValue:forKeyPath:
test whether the method propagates
thourgh key path
determine who calls this from within
GDL2
EOAccess:
Headers/Categories:
EOGenericRecord (category)