/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Analytics/GDataAnalyticsGoal.m

http://macfuse.googlecode.com/ · Objective C · 130 lines · 80 code · 31 blank · 19 comment · 1 complexity · bc2bbb23827504cd2d1d310b75df86be 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. // GDataAnalyticsGoal.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE
  19. #import "GDataAnalyticsGoal.h"
  20. #import "GDataAnalyticsConstants.h"
  21. static NSString *const kActiveAttr = @"active";
  22. static NSString *const kNameAttr = @"name";
  23. static NSString *const kNumberAttr = @"number";
  24. static NSString *const kValueAttr = @"value";
  25. @implementation GDataAnalyticsGoal
  26. + (NSString *)extensionElementURI { return kGDataNamespaceAnalyticsGA; }
  27. + (NSString *)extensionElementPrefix { return kGDataNamespaceAnalyticsGAPrefix; }
  28. + (NSString *)extensionElementLocalName { return @"goal"; }
  29. - (void)addParseDeclarations {
  30. NSArray *attrs = [NSArray arrayWithObjects:
  31. kActiveAttr, kNameAttr, kNumberAttr, kValueAttr, nil];
  32. [self addLocalAttributeDeclarations:attrs];
  33. }
  34. - (void)addExtensionDeclarations {
  35. [super addExtensionDeclarations];
  36. [self addExtensionDeclarationForParentClass:[self class]
  37. childClasses:
  38. [GDataAnalyticsDestination class],
  39. [GDataAnalyticsEngagement class],
  40. nil];
  41. }
  42. #if !GDATA_SIMPLE_DESCRIPTIONS
  43. - (NSMutableArray *)itemsForDescription {
  44. static struct GDataDescriptionRecord descRecs[] = {
  45. { @"destination", @"destination", kGDataDescValueLabeled },
  46. { @"engagement", @"engagement", kGDataDescValueLabeled },
  47. { nil, nil, (GDataDescRecTypes)0 }
  48. };
  49. NSMutableArray *items = [super itemsForDescription];
  50. [self addDescriptionRecords:descRecs toItems:items];
  51. return items;
  52. }
  53. #endif
  54. #pragma mark -
  55. // Attributes
  56. - (BOOL)isActive {
  57. BOOL flag = [self boolValueForAttribute:kActiveAttr
  58. defaultValue:NO];
  59. return flag;
  60. }
  61. - (void)setIsActive:(BOOL)flag {
  62. [self setExplicitBoolValue:flag forAttribute:kActiveAttr];
  63. }
  64. - (NSString *)name {
  65. NSString *str = [self stringValueForAttribute:kNameAttr];
  66. return str;
  67. }
  68. - (void)setName:(NSString *)str {
  69. [self setStringValue:str forAttribute:kNameAttr];
  70. }
  71. - (NSNumber *)number { // int
  72. NSNumber *num = [self intNumberForAttribute:kNumberAttr];
  73. return num;
  74. }
  75. - (void)setNumber:(NSNumber *)num {
  76. [self setStringValue:[num stringValue] forAttribute:kNumberAttr];
  77. }
  78. - (NSNumber *)value { // double
  79. NSNumber *num = [self doubleNumberForAttribute:kValueAttr];
  80. return num;
  81. }
  82. - (void)setValue:(NSNumber *)num {
  83. [self setStringValue:[num stringValue] forAttribute:kValueAttr];
  84. }
  85. // Extensions
  86. - (GDataAnalyticsDestination *)destination {
  87. return [self objectForExtensionClass:[GDataAnalyticsDestination class]];
  88. }
  89. - (void)setDestination:(GDataAnalyticsDestination *)obj {
  90. [self setObject:obj forExtensionClass:[GDataAnalyticsDestination class]];
  91. }
  92. - (GDataAnalyticsEngagement *)engagement {
  93. return [self objectForExtensionClass:[GDataAnalyticsEngagement class]];
  94. }
  95. - (void)setEngagement:(GDataAnalyticsEngagement *)obj {
  96. [self setObject:obj forExtensionClass:[GDataAnalyticsEngagement class]];
  97. }
  98. @end
  99. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE