/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Maps/GDataEntryMap.m

http://macfuse.googlecode.com/ · Objective C · 125 lines · 74 code · 33 blank · 18 comment · 3 complexity · 67f6120eaee56fbe8d53e168f30eaab4 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. // GDataEntryMap.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_MAPS_SERVICE
  19. #import "GDataEntryMap.h"
  20. #import "GDataMapConstants.h"
  21. @implementation GDataEntryMap
  22. + (id)mapEntryWithTitle:(NSString *)str {
  23. GDataEntryMap *obj = [self object];
  24. [obj setNamespaces:[GDataMapConstants mapsNamespaces]];
  25. [obj setTitleWithString:str];
  26. return obj;
  27. }
  28. #pragma mark -
  29. + (NSString *)standardEntryKind {
  30. return kGDataCategoryMap;
  31. }
  32. + (void)load {
  33. [self registerEntryClass];
  34. }
  35. - (void)addExtensionDeclarations {
  36. [super addExtensionDeclarations];
  37. Class entryClass = [self class];
  38. [self addExtensionDeclarationForParentClass:entryClass
  39. childClass:[GDataCustomProperty class]];
  40. }
  41. #if !GDATA_SIMPLE_DESCRIPTIONS
  42. - (NSMutableArray *)itemsForDescription {
  43. static struct GDataDescriptionRecord descRecs[] = {
  44. { @"properties", @"customProperties", kGDataDescArrayDescs },
  45. { nil, nil, (GDataDescRecTypes)0 }
  46. };
  47. NSMutableArray *items = [super itemsForDescription];
  48. [self addDescriptionRecords:descRecs toItems:items];
  49. return items;
  50. }
  51. #endif
  52. + (NSString *)defaultServiceVersion {
  53. return kGDataMapsDefaultServiceVersion;
  54. }
  55. #pragma mark -
  56. - (NSArray *)customProperties {
  57. return [self objectsForExtensionClass:[GDataCustomProperty class]];
  58. }
  59. - (void)setCustomProperties:(NSArray *)array {
  60. [self setObjects:array forExtensionClass:[GDataCustomProperty class]];
  61. }
  62. - (void)addCustomProperty:(GDataCustomProperty *)obj {
  63. [self addObject:obj forExtensionClass:[GDataCustomProperty class]];
  64. }
  65. #pragma mark -
  66. // convenience accessors
  67. - (NSURL *)featuresFeedURL {
  68. NSURL *featuresFeedURL = [[self content] sourceURL];
  69. return featuresFeedURL;
  70. }
  71. - (GDataCustomProperty *)customPropertyWithName:(NSString *)name {
  72. NSArray *array = [self customProperties];
  73. GDataCustomProperty *obj = [GDataUtilities firstObjectFromArray:array
  74. withValue:name
  75. forKeyPath:@"name"];
  76. return obj;
  77. }
  78. - (BOOL)isAPIVisible {
  79. BOOL isAPIVisible = YES;
  80. GDataCustomProperty *prop;
  81. prop = [self customPropertyWithName:kGDataMapPropertyAPIVisible];
  82. if (prop != nil) {
  83. NSString *value = [prop value];
  84. isAPIVisible = ([value intValue] > 0);
  85. }
  86. return isAPIVisible;
  87. }
  88. - (GDataLink *)viewLink {
  89. return [self linkWithRelAttributeValue:kGDataLinkMapView];
  90. }
  91. @end
  92. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_MAPS_SERVICE