root / asi-http-request-with-pithos / Classes / CloudFiles / ASICloudFilesContainerXMLParserDelegate.m @ be116d22
History | View | Annotate | Download (2.6 kB)
1 |
// |
---|---|
2 |
// ASICloudFilesContainerXMLParserDelegate.m |
3 |
// |
4 |
// Created by Michael Mayo on 1/10/10. |
5 |
// |
6 |
|
7 |
#import "ASICloudFilesContainerXMLParserDelegate.h" |
8 |
#import "ASICloudFilesContainer.h" |
9 |
|
10 |
|
11 |
@implementation ASICloudFilesContainerXMLParserDelegate |
12 |
|
13 |
@synthesize containerObjects, currentElement, currentContent, currentObject; |
14 |
|
15 |
#pragma mark - |
16 |
#pragma mark XML Parser Delegate |
17 |
|
18 |
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { |
19 |
[self setCurrentElement:elementName]; |
20 |
|
21 |
if ([elementName isEqualToString:@"container"]) { |
22 |
[self setCurrentObject:[ASICloudFilesContainer container]]; |
23 |
} |
24 |
[self setCurrentContent:@""]; |
25 |
} |
26 |
|
27 |
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { |
28 |
|
29 |
if ([elementName isEqualToString:@"name"]) { |
30 |
[self currentObject].name = [self currentContent]; |
31 |
} else if ([elementName isEqualToString:@"count"]) { |
32 |
[self currentObject].count = [[self currentContent] intValue]; |
33 |
} else if ([elementName isEqualToString:@"bytes"]) { |
34 |
[self currentObject].bytes = [[self currentContent] intValue]; |
35 |
} else if ([elementName isEqualToString:@"cdn_enabled"]) { |
36 |
[self currentObject].cdnEnabled = [[self currentObject] isEqual:@"True"]; |
37 |
} else if ([elementName isEqualToString:@"ttl"]) { |
38 |
[self currentObject].ttl = [[self currentContent] intValue]; |
39 |
} else if ([elementName isEqualToString:@"cdn_url"]) { |
40 |
[self currentObject].cdnURL = [self currentContent]; |
41 |
} else if ([elementName isEqualToString:@"log_retention"]) { |
42 |
[self currentObject].logRetention = [[self currentObject] isEqual:@"True"]; |
43 |
} else if ([elementName isEqualToString:@"referrer_acl"]) { |
44 |
[self currentObject].referrerACL = [self currentContent]; |
45 |
} else if ([elementName isEqualToString:@"useragent_acl"]) { |
46 |
[self currentObject].useragentACL = [self currentContent]; |
47 |
} else if ([elementName isEqualToString:@"container"]) { |
48 |
// we're done with this container. time to move on to the next |
49 |
if (containerObjects == nil) { |
50 |
containerObjects = [[NSMutableArray alloc] init]; |
51 |
} |
52 |
[containerObjects addObject:currentObject]; |
53 |
[self setCurrentObject:nil]; |
54 |
} |
55 |
} |
56 |
|
57 |
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { |
58 |
[self setCurrentContent:[[self currentContent] stringByAppendingString:string]]; |
59 |
} |
60 |
|
61 |
#pragma mark - |
62 |
#pragma mark Memory Management |
63 |
|
64 |
- (void)dealloc { |
65 |
[containerObjects release]; |
66 |
[currentElement release]; |
67 |
[currentContent release]; |
68 |
[currentObject release]; |
69 |
[super dealloc]; |
70 |
} |
71 |
|
72 |
@end |