2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "EOQualifier+GCS.h"
25 @implementation EOQualifier(GCS)
27 - (void)_appendAndQualifier:(EOAndQualifier *)_q
28 toString:(NSMutableString *)_ms
30 // TODO: move to EOQualifier category
35 if ((count = [qs count]) == 0)
38 for (i = 0; i < count; i++) {
39 if (i != 0) [_ms appendString:@" AND "];
40 if (count > 1) [_ms appendString:@"("];
41 [[qs objectAtIndex:i] _gcsAppendToString:_ms];
42 if (count > 1) [_ms appendString:@")"];
45 - (void)_appendKeyValueQualifier:(EOKeyValueQualifier *)_q
46 toString:(NSMutableString *)_ms
50 [_ms appendString:[_q key]];
52 if ((val = [_q value])) {
53 SEL op = [_q selector];
55 if ([val isNotNull]) {
56 if (sel_eq(op, EOQualifierOperatorEqual))
57 [_ms appendString:@" = "];
58 else if (sel_eq(op, EOQualifierOperatorNotEqual))
59 [_ms appendString:@" != "];
60 else if (sel_eq(op, EOQualifierOperatorLessThan))
61 [_ms appendString:@" < "];
62 else if (sel_eq(op, EOQualifierOperatorGreaterThan))
63 [_ms appendString:@" > "];
64 else if (sel_eq(op, EOQualifierOperatorLessThanOrEqualTo))
65 [_ms appendString:@" <= "];
66 else if (sel_eq(op, EOQualifierOperatorGreaterThanOrEqualTo))
67 [_ms appendString:@" >= "];
68 else if (sel_eq(op, EOQualifierOperatorLike))
69 [_ms appendString:@" LIKE "];
71 [self logWithFormat:@"ERROR(%s): unsupported operation for null: %@",
72 __PRETTY_FUNCTION__, NSStringFromSelector(op)];
75 if ([val isKindOfClass:[NSNumber class]])
76 [_ms appendString:[val stringValue]];
77 else if ([val isKindOfClass:[NSString class]]) {
78 [_ms appendString:@"'"];
79 [_ms appendString:val];
80 [_ms appendString:@"'"];
83 [self logWithFormat:@"ERROR(%s): unsupported value class: %@",
84 __PRETTY_FUNCTION__, NSStringFromClass([val class])];
88 if (sel_eq(op, EOQualifierOperatorEqual))
89 [_ms appendString:@" IS NULL"];
90 else if (sel_eq(op, EOQualifierOperatorEqual))
91 [_ms appendString:@" IS NOT NULL"];
93 [self logWithFormat:@"ERROR(%s): invalid operation for null: %@",
94 __PRETTY_FUNCTION__, NSStringFromSelector(op)];
99 [_ms appendString:@" IS NULL"];
102 - (void)_appendQualifier:(EOQualifier *)_q toString:(NSMutableString *)_ms {
103 if (_q == nil) return;
105 if ([_q isKindOfClass:[EOAndQualifier class]])
106 [self _appendAndQualifier:(id)_q toString:_ms];
107 else if ([_q isKindOfClass:[EOKeyValueQualifier class]])
108 [self _appendKeyValueQualifier:(id)_q toString:_ms];
110 NSLog(@"ERROR: unknown qualifier: %@", _q);
113 - (void)_gcsAppendToString:(NSMutableString *)_ms {
114 [self _appendQualifier:self toString:_ms];
117 @end /* EOQualifier(GCS) */