/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. // GDataAnalyticsSegment.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE
  19. #import "GDataAnalyticsSegment.h"
  20. #import "GDataAnalyticsConstants.h"
  21. static NSString *const kNameAttr = @"name";
  22. static NSString *const kIDAttr = @"id";
  23. @implementation GDataAnalyticsSegment
  24. + (NSString *)extensionElementURI { return kGDataNamespaceAnalyticsDXP; }
  25. + (NSString *)extensionElementPrefix { return kGDataNamespaceAnalyticsDXPPrefix; }
  26. + (NSString *)extensionElementLocalName { return @"segment"; }
  27. - (void)addParseDeclarations {
  28. NSArray *attrs = [NSArray arrayWithObjects:
  29. kNameAttr, kIDAttr, nil];
  30. [self addLocalAttributeDeclarations:attrs];
  31. }
  32. - (void)addExtensionDeclarations {
  33. [super addExtensionDeclarations];
  34. [self addExtensionDeclarationForParentClass:[self class]
  35. childClasses:
  36. [GDataAnalyticsDefinition class],
  37. [GDataAnalyticsProperty class],
  38. nil];
  39. }
  40. #if !GDATA_SIMPLE_DESCRIPTIONS
  41. - (NSMutableArray *)itemsForDescription {
  42. NSArray *props = [self analyticsProperties];
  43. NSString *propsDescValue;
  44. propsDescValue = [GDataAnalyticsProperty descriptionItemForProperties:props];
  45. struct GDataDescriptionRecord descRecs[] = {
  46. { @"definition", @"definition", kGDataDescValueLabeled },
  47. { @"properties", propsDescValue, kGDataDescValueIsKeyPath },
  48. { nil, nil, (GDataDescRecTypes)0 }
  49. };
  50. NSMutableArray *items = [super itemsForDescription];
  51. [self addDescriptionRecords:descRecs toItems:items];
  52. return items;
  53. }
  54. #endif
  55. #pragma mark -
  56. // Attributes
  57. - (NSString *)name {
  58. NSString *str = [self stringValueForAttribute:kNameAttr];
  59. return str;
  60. }
  61. - (void)setName:(NSString *)str {
  62. [self setStringValue:str forAttribute:kNameAttr];
  63. }
  64. - (NSString *)analyticsID {
  65. NSString *str = [self stringValueForAttribute:kIDAttr];
  66. return str;
  67. }
  68. - (void)setAnalyticsID:(NSString *)str {
  69. [self setStringValue:str forAttribute:kIDAttr];
  70. }
  71. #pragma mark -
  72. // Extensions
  73. - (NSString *)definition {
  74. GDataAnalyticsDefinition *obj;
  75. obj = [self objectForExtensionClass:[GDataAnalyticsDefinition class]];
  76. return [obj stringValue];
  77. }
  78. - (void)setDefinition:(NSString *)str {
  79. GDataAnalyticsDefinition *obj;
  80. obj = [GDataAnalyticsDefinition valueWithString:str];
  81. [self setObject:obj forExtensionClass:[GDataAnalyticsDefinition class]];
  82. }
  83. - (NSArray *)analyticsProperties {
  84. return [self objectsForExtensionClass:[GDataAnalyticsProperty class]];
  85. }
  86. - (void)setAnalyticsProperties:(NSArray *)array {
  87. [self setObjects:array forExtensionClass:[GDataAnalyticsProperty class]];
  88. }
  89. - (void)addAnalyticsProperty:(GDataAnalyticsProperty *)obj {
  90. [self addObject:obj forExtensionClass:[GDataAnalyticsProperty class]];
  91. }
  92. @end
  93. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE