summaryrefslogtreecommitdiffstats
path: root/Frameworks/LiBackend/LiFilter.m
blob: 74e2f4a1b9e7d1ac019599c88805211530261468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
//  LiFilter.m
//  LiFrameworks
//
//  Created by Brian Cully on Sat Aug 23 2003.
//  Copyright (c) 2003 Brian Cully. All rights reserved.
//

#import "LiFilter.h"

@implementation LiFilter
+ (LiFilter *)filterWithAttribute: (NSString *)anAttribute
                  compareSelector: (SEL)aSelector
                            value: (id)aValue
{
    LiFilter *tmpFilter;

    tmpFilter = [[self alloc] initWithAttribute: anAttribute
                                compareSelector: aSelector
                                          value: aValue];
    return [tmpFilter autorelease];
}

- (id)init
{
    NSException *exception;

    exception = [NSException exceptionWithName: @"LiNoInitException"
                                        reason: @"[LiFilter init] not supported"
                                      userInfo: nil];
    [exception raise];
    
    return nil;
}

- (void)dealloc
{
    [self setAttribute: nil];
    [self setCompareSelector: nil];
    [self setValue: nil];

    [super dealloc];
}

- (id)initWithAttribute: (NSString *)anAttribute
        compareSelector: (SEL)aSelector
                  value: (id)aValue
{
    self = [super init];

    [self setAttribute: anAttribute];
    [self setCompareSelector: aSelector];
    [self setValue: aValue];

    return self;
}
@synthesize theCompareSelector;
@synthesize theAttribute;
@synthesize theValue;
@end

@implementation LiFilter (Accessors)
- (NSString *)attribute
{
    return theAttribute;
}

- (void)setAttribute: (NSString *)anAttribute
{
    [anAttribute retain];
    [theAttribute release];
    theAttribute = anAttribute;
}

- (SEL)compareSelector
{
    return NSSelectorFromString(theCompareSelector);
}

- (void)setCompareSelector: (SEL)aSelector
{
    [theCompareSelector release];
    theCompareSelector = [NSStringFromSelector(aSelector) retain];
}

- (id)value
{
    return theValue;
}

- (void)setValue: (id)aValue
{
    [aValue retain];
    [theValue release];
    theValue = aValue;
}
@end

@implementation LiFilter (CommonAccessors)
- (NSString *)description
{
    NSString *desc;
    
    desc = [NSString stringWithFormat: @"{\n\tattribute: %@\n\tselector: %@\n\tvalue: %@\n}",
        theAttribute, theCompareSelector, [theValue description]];
    return desc;
}
@end