NSFetchRequest.m
1 /* Copyright (c) 2008 Dan Knapp 2 3 Permission is hereby granted, free of charge, to any person obtaining a copy of 4 this software and associated documentation files (the "Software"), to deal in 5 the Software without restriction, including without limitation the rights to 6 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 the Software, and to permit persons to whom the Software is furnished to do so, 8 subject to the following conditions: 9 10 The above copyright notice and this permission notice shall be included in all 11 copies or substantial portions of the Software. 12 13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 19 #import <CoreData/NSEntityDescription.h> 20 #import <CoreData/NSFetchRequest.h> 21 #import <CoreData/NSManagedObject.h> 22 #import <CoreData/NSManagedObjectContext.h> 23 #import <Foundation/NSRaise.h> 24 25 @implementation NSFetchRequest 26 27 - init { 28 _entity = nil; 29 _predicate = nil; 30 _sortDescriptors = nil; 31 _affectedStores = nil; 32 _fetchLimit = 0; 33 return self; 34 } 35 36 - initWithCoder: (NSCoder *) coder { 37 NSUnimplementedMethod(); 38 return nil; 39 } 40 41 - (void) encodeWithCoder: (NSCoder *) coder { 42 NSUnimplementedMethod(); 43 } 44 45 - copyWithZone: (NSZone *) zone { 46 NSFetchRequest *result = NSCopyObject(self, 0, zone); 47 48 result->_entity = [_entity retain]; 49 result->_predicate = [_predicate copy]; 50 result->_sortDescriptors = [_sortDescriptors copy]; 51 result->_affectedStores = [_affectedStores copy]; 52 result->_propertiesToFetch = [_propertiesToFetch copy]; 53 result->_relationshipKeyPathsForPrefetching = 54 [_relationshipKeyPathsForPrefetching copy]; 55 56 return result; 57 } 58 59 - (void) dealloc { 60 [_entity release]; 61 [_predicate release]; 62 [_sortDescriptors release]; 63 [_affectedStores release]; 64 [super dealloc]; 65 } 66 67 - (NSFetchRequestResultType) resultType { 68 return _resultType; 69 } 70 71 - (NSEntityDescription *) entity { 72 return _entity; 73 } 74 75 - (NSPredicate *) predicate { 76 return _predicate; 77 } 78 79 - (NSArray *) sortDescriptors { 80 return _sortDescriptors; 81 } 82 83 - (NSArray *) affectedStores { 84 return _affectedStores; 85 } 86 87 - (NSUInteger) fetchLimit { 88 return _fetchLimit; 89 } 90 91 - (NSUInteger) fetchBatchSize { 92 return _fetchBatchSize; 93 } 94 95 - (NSUInteger) fetchOffset { 96 return _fetchOffset; 97 } 98 99 - (BOOL) includesPendingChanges { 100 return _includesPendingChanges; 101 } 102 103 - (BOOL) includesPropertyValues { 104 return _includesPropertyValues; 105 } 106 107 - (BOOL) includesSubentities { 108 return _includesSubentities; 109 } 110 111 - (BOOL) returnsDistinctResults { 112 return _returnsDistinctResults; 113 } 114 115 - (BOOL) returnsObjectsAsFaults { 116 return _returnsObjectsAsFaults; 117 } 118 119 - (NSArray *) propertiesToFetch { 120 return _propertiesToFetch; 121 } 122 123 - (NSArray *) relationshipKeyPathsForPrefetching { 124 return _relationshipKeyPathsForPrefetching; 125 } 126 127 - (void) setResultType: (NSFetchRequestResultType) type { 128 _resultType = type; 129 } 130 131 - (void) setEntity: (NSEntityDescription *) value { 132 value = [value retain]; 133 [_entity release]; 134 _entity = value; 135 } 136 137 - (void) setPredicate: (NSPredicate *) value { 138 value = [value retain]; 139 [_predicate release]; 140 _predicate = value; 141 } 142 143 - (void) setSortDescriptors: (NSArray *) value { 144 value = [value copy]; 145 [_sortDescriptors release]; 146 _sortDescriptors = value; 147 } 148 149 - (void) setAffectedStores: (NSArray *) value { 150 value = [value copy]; 151 [_affectedStores release]; 152 _affectedStores = value; 153 } 154 155 - (void) setFetchLimit: (NSUInteger) value { 156 _fetchLimit = value; 157 } 158 159 - (void) setFetchBatchSize: (NSUInteger) value { 160 _fetchBatchSize = value; 161 } 162 163 - (void) setFetchOffset: (NSUInteger) value { 164 _fetchOffset = value; 165 } 166 167 - (void) setIncludesPendingChanges: (BOOL) value { 168 _includesPendingChanges = value; 169 } 170 171 - (void) setIncludesPropertyValues: (BOOL) value { 172 _includesPropertyValues = value; 173 } 174 175 - (void) setIncludesSubentities: (BOOL) value { 176 _includesSubentities = value; 177 } 178 179 - (void) setReturnsDistinctResults: (BOOL) value { 180 _returnsDistinctResults = value; 181 } 182 183 - (void) setReturnsObjectsAsFaults: (BOOL) value { 184 _returnsObjectsAsFaults = value; 185 } 186 187 - (void) setPropertiesToFetch: (NSArray *) value { 188 value = [value copy]; 189 [_propertiesToFetch release]; 190 _propertiesToFetch = value; 191 } 192 193 - (void) setRelationshipKeyPathsForPrefetching: (NSArray *) value { 194 value = [value copy]; 195 [_relationshipKeyPathsForPrefetching release]; 196 _relationshipKeyPathsForPrefetching = value; 197 } 198 199 - (NSUInteger) _countInContext: (NSManagedObjectContext *) _context { 200 NSLog(@"Stub called: _countInContext in %@", [self class]); 201 return 0; 202 } 203 204 @end