PageRenderTime 50ms CodeModel.GetById 15ms app.highlight 31ms RepoModel.GetById 1ms app.codeStats 1ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Contacts/GDataContactLink.m

http://macfuse.googlecode.com/
Objective C | 90 lines | 52 code | 21 blank | 17 comment | 1 complexity | b19d7bb6ce8ce3debedf7ed0e53e04b4 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//  GDataContactLink.m
18//
19
20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE
21
22#import "GDataContactLink.h"
23
24#import "GDataEntryContact.h" // for namespace
25
26static NSString* const kRelAttr = @"rel";
27static NSString* const kLabelAttr = @"label";
28static NSString* const kHrefAttr = @"href";
29static NSString* const kPrimaryAttr = @"primary";
30
31@implementation GDataContactLink
32
33+ (id)linkWithRel:(NSString *)rel
34            label:(NSString *)label
35             href:(NSString *)href {
36  
37  GDataContactLink *obj = [self object];
38  [obj setRel:rel];
39  [obj setLabel:label];
40  [obj setHref:href];
41  return obj;
42}
43
44- (void)addParseDeclarations {
45  NSArray *attrs = [NSArray arrayWithObjects: 
46                    kHrefAttr, kLabelAttr, kRelAttr, kPrimaryAttr, nil];
47  
48  [self addLocalAttributeDeclarations:attrs];
49}
50
51- (NSArray *)attributesIgnoredForEquality {
52  return [NSArray arrayWithObject:kPrimaryAttr];
53}
54
55#pragma mark -
56
57- (NSString *)label {
58  return [self stringValueForAttribute:kLabelAttr]; 
59}
60
61- (void)setLabel:(NSString *)str {
62  [self setStringValue:str forAttribute:kLabelAttr];
63}
64
65- (NSString *)rel {
66  return [self stringValueForAttribute:kRelAttr]; 
67}
68
69- (void)setRel:(NSString *)str {
70  [self setStringValue:str forAttribute:kRelAttr];
71}
72
73- (NSString *)href {
74  return [self stringValueForAttribute:kHrefAttr]; 
75}
76
77- (void)setHref:(NSString *)str {
78  [self setStringValue:str forAttribute:kHrefAttr];
79}
80
81- (BOOL)isPrimary {
82  return [self boolValueForAttribute:kPrimaryAttr defaultValue:NO]; 
83}
84
85- (void)setIsPrimary:(BOOL)flag {
86  [self setBoolValue:flag defaultValue:NO forAttribute:kPrimaryAttr];
87}
88@end
89
90#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE