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

http://macfuse.googlecode.com/ · Objective C · 122 lines · 72 code · 31 blank · 19 comment · 1 complexity · 9818015f361133d02f5e8aec0755afe9 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. // GDataAnalyticsDestination.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE
  19. #import "GDataAnalyticsDestination.h"
  20. #import "GDataAnalyticsConstants.h"
  21. static NSString *const kCaseSensitiveAttr = @"caseSensitive";
  22. static NSString *const kExpressionAttr = @"expression";
  23. static NSString *const kMatchTypeAttr = @"matchType";
  24. static NSString *const kStep1RequiredAttr = @"step1Required";
  25. @implementation GDataAnalyticsDestination
  26. + (NSString *)extensionElementURI { return kGDataNamespaceAnalyticsGA; }
  27. + (NSString *)extensionElementPrefix { return kGDataNamespaceAnalyticsGAPrefix; }
  28. + (NSString *)extensionElementLocalName { return @"destination"; }
  29. - (void)addParseDeclarations {
  30. NSArray *attrs = [NSArray arrayWithObjects:
  31. kCaseSensitiveAttr, kExpressionAttr,
  32. kMatchTypeAttr, kStep1RequiredAttr, nil];
  33. [self addLocalAttributeDeclarations:attrs];
  34. }
  35. - (void)addExtensionDeclarations {
  36. [super addExtensionDeclarations];
  37. [self addExtensionDeclarationForParentClass:[self class]
  38. childClass:[GDataAnalyticsStep class]];
  39. }
  40. #if !GDATA_SIMPLE_DESCRIPTIONS
  41. - (NSMutableArray *)itemsForDescription {
  42. static struct GDataDescriptionRecord descRecs[] = {
  43. { @"steps", @"steps", kGDataDescArrayDescs },
  44. { nil, nil, (GDataDescRecTypes)0 }
  45. };
  46. NSMutableArray *items = [super itemsForDescription];
  47. [self addDescriptionRecords:descRecs toItems:items];
  48. return items;
  49. }
  50. #endif
  51. #pragma mark -
  52. // Attributes
  53. - (BOOL)isCaseSensitive {
  54. return [self boolValueForAttribute:kCaseSensitiveAttr
  55. defaultValue:NO];
  56. }
  57. - (void)setIsCaseSensitive:(BOOL)flag {
  58. [self setExplicitBoolValue:flag forAttribute:kCaseSensitiveAttr];
  59. }
  60. - (NSString *)expression {
  61. return [self stringValueForAttribute:kExpressionAttr];
  62. }
  63. - (void)setExpression:(NSString *)str {
  64. [self setStringValue:str forAttribute:kExpressionAttr];
  65. }
  66. - (NSString *)matchType {
  67. return [self stringValueForAttribute:kMatchTypeAttr];
  68. }
  69. - (void)setMatchType:(NSString *)str {
  70. [self setStringValue:str forAttribute:kMatchTypeAttr];
  71. }
  72. - (BOOL)isStep1Required {
  73. return [self boolValueForAttribute:kStep1RequiredAttr
  74. defaultValue:NO];
  75. }
  76. - (void)setIsStep1Required:(BOOL)flag {
  77. [self setExplicitBoolValue:flag forAttribute:kStep1RequiredAttr];
  78. }
  79. #pragma mark -
  80. // Extensions
  81. - (NSArray *)steps {
  82. return [self objectsForExtensionClass:[GDataAnalyticsStep class]];
  83. }
  84. - (void)setSteps:(NSArray *)array {
  85. [self setObjects:array forExtensionClass:[GDataAnalyticsStep class]];
  86. }
  87. - (void)addStep:(GDataAnalyticsStep *)obj {
  88. [self addObject:obj forExtensionClass:[GDataAnalyticsStep class]];
  89. }
  90. @end
  91. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE