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