-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGDataFeedBase.h
220 lines (169 loc) · 6.39 KB
/
GDataFeedBase.h
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/* Copyright (c) 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// GDataFeedBase.h
//
#import "GDataObject.h"
#import "GDataGenerator.h"
#import "GDataTextConstruct.h"
#import "GDataLink.h"
#import "GDataEntryBase.h"
#import "GDataCategory.h"
#import "GDataPerson.h"
#import "GDataBatchOperation.h"
#import "GDataAtomPubControl.h"
#undef _EXTERN
#undef _INITIALIZE_AS
#ifdef GDATAFEEDBASE_DEFINE_GLOBALS
#define _EXTERN
#define _INITIALIZE_AS(x) =x
#else
#define _EXTERN GDATA_EXTERN
#define _INITIALIZE_AS(x)
#endif
// this constant, returned by a subclass implementation of -classForEntries,
// specifies that a feed's entry class should be determined by inspecting
// the XML for a "kind" category and looking at the registered entry classes
// for an appropriate match
_EXTERN Class const kUseRegisteredEntryClass _INITIALIZE_AS(nil);
@interface GDataFeedBase : GDataObject <NSFastEnumeration> {
// generator is parsed manually to avoid comparison along with other
// extensions
GDataGenerator *generator_;
NSMutableArray *entries_;
}
+ (id)feedWithXMLData:(NSData *)data;
- (id)initWithData:(NSData *)data;
- (id)initWithData:(NSData *)data
serviceVersion:(NSString *)serviceVersion
shouldIgnoreUnknowns:(BOOL)shouldIgnoreUnknowns;
// subclasses override initFeed to set up their ivars
- (void)initFeedWithXMLElement:(NSXMLElement *)element;
// subclass may override this to specify an entry class or
// to return kUseRegisteredEntryClass
- (Class)classForEntries;
// subclasses may override this to specify a "generic" class for
// the feed's entries, if not GDataEntryBase, mainly for when there
// is no registered entry class found
+ (Class)defaultClassForEntries;
- (BOOL)canPost;
// getters and setters
- (GDataGenerator *)generator;
- (void)setGenerator:(GDataGenerator *)gen;
- (NSString *)identifier;
- (void)setIdentifier:(NSString *)theString;
- (GDataTextConstruct *)title;
- (void)setTitle:(GDataTextConstruct *)theTitle;
- (void)setTitleWithString:(NSString *)str;
- (GDataTextConstruct *)subtitle;
- (void)setSubtitle:(GDataTextConstruct *)theSubtitle;
- (void)setSubtitleWithString:(NSString *)str;
- (GDataTextConstruct *)rights;
- (void)setRights:(GDataTextConstruct *)theRights;
- (void)setRightsWithString:(NSString *)str;
- (NSString *)icon;
- (void)setIcon:(NSString *)theString;
- (NSString *)logo;
- (void)setLogo:(NSString *)theString;
- (NSArray *)links;
- (void)setLinks:(NSArray *)links;
- (void)addLink:(GDataLink *)obj;
- (void)removeLink:(GDataLink *)obj;
- (NSArray *)authors;
- (void)setAuthors:(NSArray *)authors;
- (void)addAuthor:(GDataPerson *)obj;
- (NSArray *)contributors;
- (void)setContributors:(NSArray *)array;
- (void)addContributor:(GDataPerson *)obj;
- (NSArray *)categories;
- (void)setCategories:(NSArray *)categories;
- (void)addCategory:(GDataCategory *)category;
- (void)removeCategory:(GDataCategory *)category;
- (GDataDateTime *)updatedDate;
- (void)setUpdatedDate:(GDataDateTime *)theDate;
- (NSString *)ETag;
- (void)setETag:(NSString *)str;
- (NSString *)fieldSelection;
- (void)setFieldSelection:(NSString *)str;
- (NSString *)kind;
- (void)setKind:(NSString *)str;
- (NSString *)resourceID;
- (void)setResourceID:(NSString *)str;
- (NSArray *)entries;
// setEntries: and addEntry: assert if the entries have other parents
// already set; use setEntriesWithEntries: and addEntryWithEntry: to copy
// entries that have other parents
- (void)setEntries:(NSArray *)entries;
- (void)addEntry:(GDataEntryBase *)obj;
- (void)setEntriesWithEntries:(NSArray *)entries;
- (void)addEntryWithEntry:(GDataEntryBase *)obj;
- (NSNumber *)totalResults;
- (void)setTotalResults:(NSNumber *)theString;
- (NSNumber *)startIndex;
- (void)setStartIndex:(NSNumber *)theString;
- (NSNumber *)itemsPerPage;
- (void)setItemsPerPage:(NSNumber *)theString;
// Atom publishing control
- (GDataAtomPubControl *)atomPubControl;
- (void)setAtomPubControl:(GDataAtomPubControl *)obj;
// Batch support
- (GDataBatchOperation *)batchOperation;
- (void)setBatchOperation:(GDataBatchOperation *)obj;
// convenience routines
- (GDataLink *)linkWithRelAttributeValue:(NSString *)rel;
- (GDataLink *)feedLink;
- (GDataLink *)alternateLink;
- (GDataLink *)relatedLink;
- (GDataLink *)postLink;
- (GDataLink *)uploadLink; // "resumable-create" link
- (GDataLink *)batchLink;
- (GDataLink *)selfLink;
- (GDataLink *)nextLink;
- (GDataLink *)previousLink;
// return the first entry, or nil if none
- (id)firstEntry;
// return the specified entry, or nil if index is out of bounds
// (does not throw an exception if index exceeds the size of the entry array)
- (id)entryAtIndex:(NSUInteger)index;
// find the entry with the given identifier, or nil if none found
- (id)entryForIdentifier:(NSString *)str;
// find all entries with a kind category for the specified term
//
// this is useful for feeds which contain various kinds of entries with
// distinct entry kind categories
- (NSArray *)entriesWithCategoryKind:(NSString *)term;
///////////////////////////////////////////////////////////////////////////////
//
// Protected methods
//
// All remaining methods are intended for use only by subclasses
// of GDataFeedBase.
//
// subclasses call registerEntryClass to register their standardFeedKind
+ (void)registerFeedClass;
+ (Class)feedClassForCategoryWithScheme:(NSString *)scheme
term:(NSString *)term;
+ (Class)feedClassForKindAttributeValue:(NSString *)kind;
// temporary bridge method
+ (void)registerFeedClass:(Class)theClass
forCategoryWithScheme:(NSString *)scheme
term:(NSString *)term;
// subclasses override standardFeedKind to provide the term string for the
// term attribute of their "kind" category element, if any
+ (NSString *)standardFeedKind;
// subclasses override standardKindAttributeValue to provide the string for the
// kind attribute identifying their class (for core protocol v2.1 and later)
+ (NSString *)standardKindAttributeValue;
@end