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

http://macfuse.googlecode.com/ · Objective C · 113 lines · 69 code · 27 blank · 17 comment · 1 complexity · 5f23f59ce2bf6b8e5efefa288bb1d2c2 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. // GDataAnalyticsDataSource.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE
  19. #import "GDataAnalyticsDataSource.h"
  20. #import "GDataAnalyticsConstants.h"
  21. #import "GDataAnalyticsElements.h"
  22. #import "GDataUtilities.h"
  23. @implementation GDataAnalyticsDataSource
  24. + (NSString *)extensionElementURI { return kGDataNamespaceAnalyticsDXP; }
  25. + (NSString *)extensionElementPrefix { return kGDataNamespaceAnalyticsDXPPrefix; }
  26. + (NSString *)extensionElementLocalName { return @"dataSource"; }
  27. - (void)addExtensionDeclarations {
  28. [super addExtensionDeclarations];
  29. [self addExtensionDeclarationForParentClass:[self class]
  30. childClasses:
  31. [GDataAnalyticsProperty class],
  32. [GDataAnalyticsTableID class],
  33. [GDataAnalyticsTableName class],
  34. nil];
  35. }
  36. #if !GDATA_SIMPLE_DESCRIPTIONS
  37. - (NSMutableArray *)itemsForDescription {
  38. static struct GDataDescriptionRecord descRecs[] = {
  39. { @"tableID", @"tableID", kGDataDescValueLabeled },
  40. { @"tableName", @"tableName", kGDataDescValueLabeled },
  41. { @"properties", @"properties", kGDataDescArrayDescs },
  42. { nil, nil, (GDataDescRecTypes)0 }
  43. };
  44. NSMutableArray *items = [super itemsForDescription];
  45. [self addDescriptionRecords:descRecs toItems:items];
  46. return items;
  47. }
  48. #endif
  49. #pragma mark -
  50. - (NSString *)tableID {
  51. GDataAnalyticsTableID *obj;
  52. obj = [self objectForExtensionClass:[GDataAnalyticsTableID class]];
  53. return [obj stringValue];
  54. }
  55. - (void)setTableID:(NSString *)str {
  56. GDataAnalyticsTableID *obj = [GDataAnalyticsTableID valueWithString:str];
  57. [self setObject:obj forExtensionClass:[GDataAnalyticsTableID class]];
  58. }
  59. - (NSString *)tableName {
  60. GDataAnalyticsTableName *obj;
  61. obj = [self objectForExtensionClass:[GDataAnalyticsTableName class]];
  62. return [obj stringValue];
  63. }
  64. - (void)setTableName:(NSString *)str {
  65. GDataAnalyticsTableName *obj = [GDataAnalyticsTableName valueWithString:str];
  66. [self setObject:obj forExtensionClass:[GDataAnalyticsTableName class]];
  67. }
  68. - (NSArray *)analyticsProperties {
  69. return [self objectsForExtensionClass:[GDataAnalyticsProperty class]];
  70. }
  71. - (void)setAnalyticsProperties:(NSArray *)array {
  72. [self setObjects:array forExtensionClass:[GDataAnalyticsProperty class]];
  73. }
  74. - (void)addAnalyticsProperty:(GDataAnalyticsProperty *)obj {
  75. [self addObject:obj forExtensionClass:[GDataAnalyticsProperty class]];
  76. }
  77. #pragma mark -
  78. - (GDataAnalyticsProperty *)analyticsPropertyWithName:(NSString *)name {
  79. NSArray *array = [self analyticsProperties];
  80. GDataAnalyticsProperty *obj = [GDataUtilities firstObjectFromArray:array
  81. withValue:name
  82. forKeyPath:@"name"];
  83. return obj;
  84. }
  85. @end
  86. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE