PageRenderTime 26ms CodeModel.GetById 10ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Books/GDataVolumePrice.m

http://macfuse.googlecode.com/
Objective C | 129 lines | 71 code | 30 blank | 28 comment | 1 complexity | 81710702ce8d6bdcf8cd2e4add1d9417 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//  GDataVolumePrice.m
 18//
 19
 20// book price extension, like
 21//  <gbs:price type="RetailPrice">
 22//    <gd:money amount="15.00" currencyCode="USD" />
 23//    <gbs:promotion value="print-digital-bundle" />
 24//  </gbs:price>
 25
 26#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_BOOKS_SERVICE
 27
 28#import "GDataVolumePrice.h"
 29#import "GDataValueConstruct.h"
 30#import "GDataBookConstants.h"
 31
 32@interface GDataVolumePromotion : GDataValueConstruct <GDataExtension>
 33@end
 34
 35@implementation GDataVolumePromotion
 36+ (NSString *)extensionElementURI       { return kGDataNamespaceBooks; }
 37+ (NSString *)extensionElementPrefix    { return kGDataNamespaceBooksPrefix; }
 38+ (NSString *)extensionElementLocalName { return @"promotion"; }
 39@end
 40
 41
 42static NSString* const kTypeAttr = @"type";
 43
 44@implementation GDataVolumePrice
 45
 46+ (NSString *)extensionElementURI       { return kGDataNamespaceBooks; }
 47+ (NSString *)extensionElementPrefix    { return kGDataNamespaceBooksPrefix; }
 48+ (NSString *)extensionElementLocalName { return @"price"; }
 49
 50+ (GDataVolumePrice *)volumePriceWithType:(NSString *)type
 51                                    money:(GDataMoney *)money {
 52  GDataVolumePrice *obj = [self object];
 53  [obj setType:type];
 54  [obj setMoney:money];
 55  return obj;
 56}
 57
 58- (void)addParseDeclarations {
 59  NSArray *attrs = [NSArray arrayWithObject:kTypeAttr];
 60  [self addLocalAttributeDeclarations:attrs];
 61}
 62
 63- (void)addExtensionDeclarations {
 64
 65  [super addExtensionDeclarations];
 66
 67  [self addExtensionDeclarationForParentClass:[self class]
 68                                 childClasses:
 69   [GDataMoney class],
 70   [GDataVolumePromotion class],
 71   nil];
 72}
 73
 74#if !GDATA_SIMPLE_DESCRIPTIONS
 75- (NSMutableArray *)itemsForDescription {
 76
 77  static struct GDataDescriptionRecord descRecs[] = {
 78    { @"money",     @"money",                 kGDataDescValueLabeled },
 79    { @"promotion", @"promotion.stringValue", kGDataDescValueLabeled },
 80    { nil, nil, (GDataDescRecTypes)0 }
 81  };
 82
 83  NSMutableArray *items = [super itemsForDescription];
 84  [self addDescriptionRecords:descRecs toItems:items];
 85  return items;
 86}
 87#endif
 88
 89#pragma mark -
 90
 91//
 92// attributes
 93//
 94
 95- (NSString *)type {
 96  return [self stringValueForAttribute:kTypeAttr];
 97}
 98
 99- (void)setType:(NSString *)str {
100  [self setStringValue:str forAttribute:kTypeAttr];
101}
102
103//
104// extensions
105//
106
107- (GDataMoney *)money {
108  return [self objectForExtensionClass:[GDataMoney class]];
109}
110
111- (void)setMoney:(GDataMoney *)obj {
112  [self setObject:obj forExtensionClass:[GDataMoney class]];
113}
114
115- (NSString *)promotion {
116  GDataVolumePromotion *obj;
117
118  obj = [self objectForExtensionClass:[GDataVolumePromotion class]];
119  return [obj stringValue];
120}
121
122- (void)setPromotion:(NSString *)str {
123  GDataVolumePromotion *obj = [GDataVolumePromotion valueWithString:str];
124  [self setObject:obj forExtensionClass:[GDataVolumePromotion class]];
125}
126
127@end
128
129#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_BOOKS_SERVICE