PageRenderTime 56ms CodeModel.GetById 10ms app.highlight 42ms RepoModel.GetById 1ms app.codeStats 0ms

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