| 1 |
masakih |
348 |
// |
| 2 |
|
|
// XspfMRuleRowsBuilder.m |
| 3 |
|
|
// |
| 4 |
|
|
// Created by Hori,Masaki on 10/04/22. |
| 5 |
|
|
// Copyright 2010 masakih. All rights reserved. |
| 6 |
|
|
// |
| 7 |
|
|
|
| 8 |
|
|
#import "XspfMRuleRowsBuilder.h" |
| 9 |
|
|
#import "XspfMRuleRowsBuilder_private.h" |
| 10 |
|
|
|
| 11 |
|
|
|
| 12 |
|
|
@implementation XspfMRuleRowsBuilder |
| 13 |
|
|
@synthesize rowTemplate; |
| 14 |
|
|
|
| 15 |
|
|
+ (id)builderWithPredicate:(NSPredicate *)aPredicate |
| 16 |
|
|
{ |
| 17 |
|
|
return [[[self alloc] initWithPredicate:aPredicate] autorelease]; |
| 18 |
|
|
} |
| 19 |
|
|
- (id)initWithPredicate:(NSPredicate *)aPredicate |
| 20 |
|
|
{ |
| 21 |
|
|
[super init]; |
| 22 |
|
|
[self release]; |
| 23 |
|
|
|
| 24 |
|
|
Class subclasses[] = { |
| 25 |
|
|
[XspfMRuleCompoundPredicateRowsBuilder class], |
| 26 |
|
|
[XspfMRuleStringRowsBuilder class], |
| 27 |
|
|
[XspfMRuleNumberRowsBuilder class], |
| 28 |
|
|
[XspfMRuleDateRowsBuilder class], |
| 29 |
|
|
[XspfMRuleRatingRowsBuilder class], |
| 30 |
|
|
[XspfMRuleLabelRowsBuilder class], |
| 31 |
|
|
Nil, |
| 32 |
|
|
}; |
| 33 |
|
|
|
| 34 |
|
|
NSInteger i = 0; |
| 35 |
|
|
while(subclasses[i]) { |
| 36 |
|
|
if([subclasses[i] canBuildPredicate:aPredicate]) { |
| 37 |
|
|
id obj = [[subclasses[i] alloc] initWithPredicate:aPredicate]; |
| 38 |
|
|
return obj; |
| 39 |
|
|
} |
| 40 |
|
|
i++; |
| 41 |
|
|
} |
| 42 |
|
|
|
| 43 |
|
|
NSLog(@"Could not find corresponded concrete class."); |
| 44 |
|
|
return nil; |
| 45 |
|
|
} |
| 46 |
|
|
- (void)setPredicate:(id)aPredicate |
| 47 |
|
|
{ |
| 48 |
|
|
[predicate autorelease]; |
| 49 |
|
|
predicate = [aPredicate retain]; |
| 50 |
|
|
} |
| 51 |
|
|
|
| 52 |
|
|
- (void)dealloc |
| 53 |
|
|
{ |
| 54 |
|
|
self.rowTemplate = nil; |
| 55 |
|
|
[predicate release]; |
| 56 |
|
|
|
| 57 |
|
|
[super dealloc]; |
| 58 |
|
|
} |
| 59 |
|
|
- (void)build {} |
| 60 |
|
|
- (NSDictionary *)rows |
| 61 |
|
|
{ |
| 62 |
|
|
NSDictionary *rows = [NSMutableDictionary dictionaryWithObjectsAndKeys: |
| 63 |
|
|
[self rowType], @"rowType", |
| 64 |
|
|
[self displayValues], @"displayValues", |
| 65 |
|
|
[self criteria], @"criteria", |
| 66 |
|
|
[self subrows], @"subrows", |
| 67 |
|
|
nil]; |
| 68 |
|
|
return rows; |
| 69 |
|
|
} |
| 70 |
|
|
|
| 71 |
|
|
- (NSNumber *)rowType { return nil; } |
| 72 |
|
|
- (NSArray *)criteria { return nil; } |
| 73 |
|
|
- (NSArray *)subrows { return nil; } |
| 74 |
|
|
- (NSArray *)displayValues |
| 75 |
|
|
{ |
| 76 |
|
|
return [NSArray arrayWithObjects: |
| 77 |
|
|
[self value01], [self value02], [self value03], [self value04], |
| 78 |
|
|
[self value05], [self value06], [self value07], |
| 79 |
|
|
nil]; |
| 80 |
|
|
} |
| 81 |
|
|
- (id)value01 { return nil; } |
| 82 |
|
|
- (id)value02 { return nil; } |
| 83 |
|
|
- (id)value03 { return nil; } |
| 84 |
|
|
- (id)value04 { return nil; } |
| 85 |
|
|
- (id)value05 { return nil; } |
| 86 |
|
|
- (id)value06 { return nil; } |
| 87 |
|
|
- (id)value07 { return nil; } |
| 88 |
|
|
@end |