PageRenderTime 29ms CodeModel.GetById 12ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Introspection/GDataAtomCategoryGroup.m

http://macfuse.googlecode.com/
Objective C | 118 lines | 63 code | 26 blank | 29 comment | 4 complexity | c35101f9c9c4c4287771e115fe9f8454 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//  GDataAtomCategoryGroup.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_SERVICE_INTROSPECTION
 21
 22#import "GDataAtomCategoryGroup.h"
 23#import "GDataCategory.h"
 24
 25static NSString* const kHrefAttr = @"href";
 26static NSString* const kSchemeAttr = @"scheme";
 27static NSString* const kFixedAttr = @"fixed";
 28
 29@implementation GDataAtomCategoryGroup
 30// a collection in a service document for introspection,
 31// per http://tools.ietf.org/html/rfc5023#section-7.2
 32//
 33//  <categories fixed="yes">
 34//    <atom:category scheme="http://example.org/extra-cats/" term="joke" />
 35//    <atom:category scheme="http://example.org/extra-cats/" term="serious" />
 36//  </categories>
 37//
 38//  or
 39//
 40//  <categories href="http://example.com/cats/forMain.cats" />
 41
 42+ (NSString *)extensionElementURI       { return kGDataNamespaceAtomPub; }
 43+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAtomPubPrefix; }
 44+ (NSString *)extensionElementLocalName { return @"categories"; }
 45
 46- (void)addParseDeclarations {
 47
 48  NSArray *attrs = [NSArray arrayWithObjects:
 49                    kHrefAttr, kSchemeAttr, kFixedAttr, nil];
 50
 51  [self addLocalAttributeDeclarations:attrs];
 52}
 53
 54- (void)addExtensionDeclarations {
 55
 56  [super addExtensionDeclarations];
 57
 58  [self addExtensionDeclarationForParentClass:[self class]
 59                                   childClass:[GDataCategory class]];
 60}
 61
 62#if !GDATA_SIMPLE_DESCRIPTIONS
 63- (NSMutableArray *)itemsForDescription {
 64  static struct GDataDescriptionRecord descRecs[] = {
 65    { @"fixed",      @"isFixed",    kGDataDescBooleanPresent },
 66    { @"href",       @"href",       kGDataDescValueLabeled },
 67    { @"scheme",     @"scheme",     kGDataDescValueLabeled },
 68    { @"categories", @"categories", kGDataDescArrayDescs },
 69    { nil, nil, (GDataDescRecTypes)0 }
 70  };
 71  
 72  NSMutableArray *items = [super itemsForDescription];
 73  [self addDescriptionRecords:descRecs toItems:items];
 74  return items;
 75}
 76#endif
 77
 78#pragma mark -
 79
 80- (NSString *)href {
 81  return [self stringValueForAttribute:kHrefAttr];
 82}
 83
 84- (void)setHref:(NSString *)str {
 85  [self setStringValue:str forAttribute:kHrefAttr];
 86}
 87
 88- (NSString *)scheme {
 89  return [self stringValueForAttribute:kSchemeAttr];
 90}
 91
 92- (void)setScheme:(NSString *)str {
 93  [self setStringValue:str forAttribute:kSchemeAttr];
 94}
 95
 96- (BOOL)isFixed {
 97  // absence of the fixed attribute means no
 98  NSString *str = [self stringValueForAttribute:kFixedAttr];
 99  if (str == nil) return NO;
100
101  return ([str caseInsensitiveCompare:@"yes"] == NSOrderedSame);
102}
103
104- (void)setIsFixed:(BOOL)flag {
105  [self setStringValue:(flag ? @"yes" : nil) forAttribute:kFixedAttr];
106}
107
108- (NSArray *)categories {
109  return [self objectsForExtensionClass:[GDataCategory class]];
110}
111
112- (void)setCategories:(NSArray *)array {
113  [self setObjects:array forExtensionClass:[GDataCategory class]];
114}
115
116@end
117
118#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_SERVICE_INTROSPECTION