PageRenderTime 20ms CodeModel.GetById 2ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 1ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Elements/GDataAtomPubControl.m

http://macfuse.googlecode.com/
Objective C | 108 lines | 59 code | 27 blank | 22 comment | 4 complexity | c1b60a1a09b2b33f2fbe9e22329c9c7c MD5 | raw file
  1/* Copyright (c) 2007 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//  GDataAtomPubControl.m
 18//
 19
 20#import "GDataAtomPubControl.h"
 21#import "GDataValueConstruct.h"
 22
 23// app:draft, like
 24//   <app:draft>yes<app:draft>
 25
 26@interface GDataAtomPubDraft : GDataValueElementConstruct <GDataExtension>
 27@end
 28
 29@implementation GDataAtomPubDraft
 30+ (NSString *)extensionElementURI       { return kGDataNamespaceAtomPub; }
 31+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAtomPubPrefix; }
 32+ (NSString *)extensionElementLocalName { return @"draft"; }
 33@end
 34
 35@implementation GDataAtomPubControl
 36
 37// For app:control, like:
 38//   <app:control><app:draft>yes</app:draft></app:control>
 39
 40+ (NSString *)extensionElementURI       { return kGDataNamespaceAtomPub; }
 41+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAtomPubPrefix; }
 42+ (NSString *)extensionElementLocalName { return @"control"; }
 43
 44+ (GDataAtomPubControl *)atomPubControl {
 45  GDataAtomPubControl *obj = [self object];
 46
 47  // add the "app" namespace
 48  NSString *nsURI = [[self class] extensionElementURI];
 49  NSDictionary *namespaceDict = [NSDictionary dictionaryWithObject:nsURI
 50                                                            forKey:kGDataNamespaceAtomPubPrefix];
 51  [obj setNamespaces:namespaceDict];
 52
 53  return obj;
 54}
 55
 56+ (GDataAtomPubControl *)atomPubControlWithIsDraft:(BOOL)isDraft {
 57  GDataAtomPubControl *obj = [self atomPubControl];
 58  [obj setIsDraft:isDraft];
 59  return obj;
 60}
 61
 62+ (NSString *)defaultServiceVersion {
 63  return @"2.0";
 64}
 65
 66- (void)addExtensionDeclarations {
 67
 68  [super addExtensionDeclarations];
 69
 70  [self addExtensionDeclarationForParentClass:[self class]
 71                                   childClass:[GDataAtomPubDraft class]];
 72}
 73
 74#if !GDATA_SIMPLE_DESCRIPTIONS
 75- (NSMutableArray *)itemsForDescription {
 76  NSMutableArray *items = [NSMutableArray array];
 77
 78  NSString *str = ([self isDraft] ? @"yes" : @"no");
 79  [self addToArray:items objectDescriptionIfNonNil:str
 80          withName:@"isDraft"];
 81
 82  return items;
 83}
 84#endif
 85
 86- (BOOL)isDraft {
 87  GDataValueElementConstruct *obj;
 88  obj = [self objectForExtensionClass:[GDataAtomPubDraft class]];
 89
 90  NSString *str = [obj stringValue];
 91  BOOL isDraft = (str != nil
 92                  && [str caseInsensitiveCompare:@"yes"] == NSOrderedSame);
 93  return isDraft;
 94}
 95
 96- (void)setIsDraft:(BOOL)isDraft {
 97
 98  id obj = nil;
 99  if (isDraft) {
100    obj = [GDataAtomPubDraft valueWithString:@"yes"];
101  }
102
103  [self setObject:obj forExtensionClass:[GDataAtomPubDraft class]];
104}
105
106@end
107
108