75 _predicates = predicates;
133 count = [subp count],
136 for (; i < count; i++)
138 var p = [subp objectAtIndex:i],
139 sp = [p predicateWithSubstitutionVariables:variables];
151 count = [_predicates count],
155 return @"TRUEPREDICATE";
157 for (; i < count; i++)
159 var subpredicate = [_predicates objectAtIndex:i],
160 precedence = [subpredicate predicateFormat];
162 if ([subpredicate isKindOfClass:[
CPCompoundPredicate class]] && [[subpredicate subpredicates] count]> 1 && [subpredicate compoundPredicateType] != _type)
165 if (precedence != nil)
166 [args addObject:precedence];
175 var count = [args count];
176 for (var j = 1; j < count; j++)
177 result +=
" AND " + [args objectAtIndex:j];
181 var count = [args count];
182 for (var j = 1; j < count; j++)
183 result +=
" OR " + [args objectAtIndex:j];
190 - (BOOL)evaluateWithObject:(
id)object
195 - (BOOL)evaluateWithObject:(
id)object substitutionVariables:(
CPDictionary)variables
198 count = [_predicates count],
204 for (; i < count; i++)
206 var predicate = [_predicates objectAtIndex:i];
210 case CPNotPredicateType:
return ![predicate evaluateWithObject:object substitutionVariables:variables];
213 result = [predicate evaluateWithObject:object substitutionVariables:variables];
215 result = result && [predicate evaluateWithObject:object substitutionVariables:variables];
220 case CPOrPredicateType:
if ([predicate evaluateWithObject:
object substitutionVariables:variables])
231 if (
self === anObject)
234 if (anObject.isa !==
self.isa || _type !== [anObject compoundPredicateType] || ![_predicates isEqualToArray:[anObject subpredicates]])
249 _predicates = [coder decodeObjectForKey:@"CPCompoundPredicateSubpredicates"];
250 _type = [coder decodeIntForKey:@"CPCompoundPredicateType"];
258 [coder encodeObject:_predicates forKey:@"CPCompoundPredicateSubpredicates"];
259 [coder encodeInt:_type forKey:@"CPCompoundPredicateType"];