PageRenderTime 59ms CodeModel.GetById 34ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://macfuse.googlecode.com/
Objective C | 97 lines | 50 code | 23 blank | 24 comment | 1 complexity | 1498b51882eff9ad461f10310af54310 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//  GDataPostalAddress.m
18//
19
20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE
21
22#import "GDataPostalAddress.h"
23
24static NSString* const kRelAttr = @"rel";
25static NSString* const kLabelAttr = @"label";
26static NSString* const kPrimaryAttr = @"primary";
27
28@implementation GDataPostalAddress
29// postal address, as in
30//  <gd:postalAddress>
31//    500 West 45th Street
32//    New York, NY 10036
33//  </gd:postalAddress>
34//
35// http://code.google.com/apis/gdata/common-elements.html#gdPostalAddress
36
37+ (NSString *)extensionElementURI       { return kGDataNamespaceGData; }
38+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGDataPrefix; }
39+ (NSString *)extensionElementLocalName { return @"postalAddress"; }
40
41+ (GDataPostalAddress *)postalAddressWithString:(NSString *)str {
42  GDataPostalAddress* obj = [self object];
43  [obj setStringValue:str];
44  return obj;
45}
46
47
48- (void)addParseDeclarations {
49  NSArray *attrs = [NSArray arrayWithObjects:
50                    kLabelAttr, kRelAttr, kPrimaryAttr, nil];
51
52  [self addLocalAttributeDeclarations:attrs];
53
54  [self addContentValueDeclaration];
55}
56
57- (NSArray *)attributesIgnoredForEquality {
58
59  return [NSArray arrayWithObject:kPrimaryAttr];
60}
61
62#pragma mark -
63
64- (NSString *)label {
65  return [self stringValueForAttribute:kLabelAttr];
66}
67
68- (void)setLabel:(NSString *)str {
69  [self setStringValue:str forAttribute:kLabelAttr];
70}
71
72- (NSString *)stringValue {
73  return [self contentStringValue];
74}
75
76- (void)setStringValue:(NSString *)str {
77  [self setContentStringValue:str];
78}
79
80- (NSString *)rel {
81  return [self stringValueForAttribute:kRelAttr];
82}
83
84- (void)setRel:(NSString *)str {
85  [self setStringValue:str forAttribute:kRelAttr];
86}
87
88- (BOOL)isPrimary {
89  return [self boolValueForAttribute:kPrimaryAttr defaultValue:NO];
90}
91
92- (void)setIsPrimary:(BOOL)flag {
93  [self setBoolValue:flag defaultValue:NO forAttribute:kPrimaryAttr];
94}
95@end
96
97#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE