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

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

http://macfuse.googlecode.com/
Objective C | 70 lines | 35 code | 16 blank | 19 comment | 2 complexity | 8517f7b7e152bd09bd255b23a41c22a1 MD5 | raw file
 1/* Copyright (c) 2008 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//  GDataMoney.m
18//
19
20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_FINANCE_SERVICE || GDATA_INCLUDE_BOOKS_SERVICE
21
22#import "GDataMoney.h"
23
24static NSString* const kAmountAttr = @"amount";
25static NSString* const kCurrencyCodeAttr = @"currencyCode";
26
27@implementation GDataMoney
28// money element, as in
29//  <gd:money amount="10" currencyCode="USD"/>
30
31+ (NSString *)extensionElementURI       { return kGDataNamespaceGData; }
32+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGDataPrefix; }
33+ (NSString *)extensionElementLocalName { return @"money"; }
34
35+ (GDataMoney *)moneyWithAmount:(NSNumber *)amount
36                   currencyCode:(NSString *)currencyCode {
37  GDataMoney *obj = [self object];
38  [obj setAmount:amount];
39  [obj setCurrencyCode:currencyCode];
40  return obj;
41}
42
43- (void)addParseDeclarations {
44  NSArray *attrs = [NSArray arrayWithObjects: 
45                    kAmountAttr, kCurrencyCodeAttr, nil];
46  
47  [self addLocalAttributeDeclarations:attrs];
48}
49
50#pragma mark -
51
52- (NSDecimalNumber *)amount {
53  return [self decimalNumberForAttribute:kAmountAttr];
54}
55
56- (void)setAmount:(NSNumber *)num {
57  [self setStringValue:[num stringValue] forAttribute:kAmountAttr];
58}
59
60- (NSString *)currencyCode {
61  return [self stringValueForAttribute:kCurrencyCodeAttr]; 
62}
63
64- (void)setCurrencyCode:(NSString *)str {
65  [self setStringValue:str forAttribute:kCurrencyCodeAttr];
66}
67
68@end
69
70#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_FINANCE_SERVICE || GDATA_INCLUDE_BOOKS_SERVICE