]> err.no Git - sope/blob - sope-core/EOControl/EOQualifierVariable.m
Xcode project
[sope] / sope-core / EOControl / EOQualifierVariable.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "EOQualifier.h"
24 #include "common.h"
25
26 @implementation EOQualifierVariable
27
28 + (id)variableWithKey:(NSString *)_key {
29   return [[[self alloc] initWithKey:_key] autorelease];
30 }
31
32 - (id)initWithKey:(NSString *)_key {
33   self->varKey = [_key copyWithZone:[self zone]];
34   return self;
35 }
36 - (id)init {
37   return [self initWithKey:nil];
38 }
39
40 - (void)dealloc {
41   [self->varKey release];
42   [super dealloc];
43 }
44
45 /* accessors */
46
47 - (NSString *)key {
48   return self->varKey;
49 }
50
51 /* NSCoding */
52
53 - (void)encodeWithCoder:(NSCoder *)_coder {
54   [_coder encodeObject:self->varKey];
55 }
56 - (id)initWithCoder:(NSCoder *)_coder {
57   self->varKey = [[_coder decodeObject] copyWithZone:[self zone]];
58   return self;
59 }
60
61 /* Comparing */
62
63 - (BOOL)isEqual:(id)_obj {
64   if ([_obj isKindOfClass:[self class]])
65     return [self isEqualToQualifierVariable:(EOQualifierVariable *)_obj];
66   
67   return NO;
68 }
69
70 - (BOOL)isEqualToQualifierVariable:(EOQualifierVariable *)_obj {
71   return [self->varKey isEqual:[_obj key]];
72 }
73
74 /* description */
75
76 - (NSString *)qualifierDescription {
77   return [@"$" stringByAppendingString:[self key]];
78 }
79
80 - (NSString *)description {
81   return [NSString stringWithFormat:@"<%@[0x%08X]: variable=%@>",
82                      NSStringFromClass([self class]), self,
83                      [self key]];
84 }
85
86 @end /* EOQualifierVariable */