PageRenderTime 20ms CodeModel.GetById 1ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/externals/GData/Source/Clients/Analytics/GDataAnalyticsSegment.m

http://google-email-uploader-mac.googlecode.com/
Objective C | 125 lines | 74 code | 32 blank | 19 comment | 1 complexity | bd94cb2ba1b980a73e705104fd0a3571 MD5 | raw file
  1/* Copyright (c) 2009 Google Inc.
  2 *
  3 * Licensed under the Apache License, Version 2.0 (the "License");
  4 * you may not use this file except in compliance with the License.
  5 * You may obtain a copy of the License at
  6 *
  7 *     http://www.apache.org/licenses/LICENSE-2.0
  8 *
  9 * Unless required by applicable law or agreed to in writing, software
 10 * distributed under the License is distributed on an "AS IS" BASIS,
 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12 * See the License for the specific language governing permissions and
 13 * limitations under the License.
 14 */
 15
 16//
 17//  GDataAnalyticsSegment.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE
 21
 22#import "GDataAnalyticsSegment.h"
 23#import "GDataAnalyticsConstants.h"
 24
 25static NSString *const kNameAttr = @"name";
 26static NSString *const kIDAttr = @"id";
 27
 28@implementation GDataAnalyticsSegment
 29
 30+ (NSString *)extensionElementURI       { return kGDataNamespaceAnalyticsDXP; }
 31+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAnalyticsDXPPrefix; }
 32+ (NSString *)extensionElementLocalName { return @"segment"; }
 33
 34- (void)addParseDeclarations {
 35
 36  NSArray *attrs = [NSArray arrayWithObjects:
 37                    kNameAttr, kIDAttr, nil];
 38
 39  [self addLocalAttributeDeclarations:attrs];
 40}
 41
 42- (void)addExtensionDeclarations {
 43  [super addExtensionDeclarations];
 44
 45  [self addExtensionDeclarationForParentClass:[self class]
 46                                 childClasses:
 47   [GDataAnalyticsDefinition class],
 48   [GDataAnalyticsProperty class],
 49   nil];
 50}
 51
 52#if !GDATA_SIMPLE_DESCRIPTIONS
 53- (NSMutableArray *)itemsForDescription {
 54
 55  NSArray *props = [self analyticsProperties];
 56  NSString *propsDescValue;
 57  propsDescValue = [GDataAnalyticsProperty descriptionItemForProperties:props];
 58
 59  struct GDataDescriptionRecord descRecs[] = {
 60    { @"definition", @"definition", kGDataDescValueLabeled },
 61    { @"properties", propsDescValue, kGDataDescValueIsKeyPath },
 62    { nil, nil, (GDataDescRecTypes)0 }
 63  };
 64
 65  NSMutableArray *items = [super itemsForDescription];
 66  [self addDescriptionRecords:descRecs toItems:items];
 67  return items;
 68}
 69#endif
 70
 71#pragma mark -
 72
 73// Attributes
 74
 75- (NSString *)name {
 76  NSString *str = [self stringValueForAttribute:kNameAttr];
 77  return str;
 78}
 79
 80- (void)setName:(NSString *)str {
 81  [self setStringValue:str forAttribute:kNameAttr];
 82}
 83
 84- (NSString *)analyticsID {
 85  NSString *str = [self stringValueForAttribute:kIDAttr];
 86  return str;
 87}
 88
 89- (void)setAnalyticsID:(NSString *)str {
 90  [self setStringValue:str forAttribute:kIDAttr];
 91}
 92
 93#pragma mark -
 94
 95// Extensions
 96
 97- (NSString *)definition {
 98  GDataAnalyticsDefinition *obj;
 99  obj = [self objectForExtensionClass:[GDataAnalyticsDefinition class]];
100
101  return [obj stringValue];
102}
103
104- (void)setDefinition:(NSString *)str {
105  GDataAnalyticsDefinition *obj;
106  obj = [GDataAnalyticsDefinition valueWithString:str];
107
108  [self setObject:obj forExtensionClass:[GDataAnalyticsDefinition class]];
109}
110
111- (NSArray *)analyticsProperties {
112  return [self objectsForExtensionClass:[GDataAnalyticsProperty class]];
113}
114
115- (void)setAnalyticsProperties:(NSArray *)array {
116  [self setObjects:array forExtensionClass:[GDataAnalyticsProperty class]];
117}
118
119- (void)addAnalyticsProperty:(GDataAnalyticsProperty *)obj {
120  [self addObject:obj forExtensionClass:[GDataAnalyticsProperty class]];
121}
122
123@end
124
125#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE