/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. // GDataContactLink.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE
  19. #import "GDataContactLink.h"
  20. #import "GDataEntryContact.h" // for namespace
  21. static NSString* const kRelAttr = @"rel";
  22. static NSString* const kLabelAttr = @"label";
  23. static NSString* const kHrefAttr = @"href";
  24. static NSString* const kPrimaryAttr = @"primary";
  25. @implementation GDataContactLink
  26. + (id)linkWithRel:(NSString *)rel
  27. label:(NSString *)label
  28. href:(NSString *)href {
  29. GDataContactLink *obj = [self object];
  30. [obj setRel:rel];
  31. [obj setLabel:label];
  32. [obj setHref:href];
  33. return obj;
  34. }
  35. - (void)addParseDeclarations {
  36. NSArray *attrs = [NSArray arrayWithObjects:
  37. kHrefAttr, kLabelAttr, kRelAttr, kPrimaryAttr, nil];
  38. [self addLocalAttributeDeclarations:attrs];
  39. }
  40. - (NSArray *)attributesIgnoredForEquality {
  41. return [NSArray arrayWithObject:kPrimaryAttr];
  42. }
  43. #pragma mark -
  44. - (NSString *)label {
  45. return [self stringValueForAttribute:kLabelAttr];
  46. }
  47. - (void)setLabel:(NSString *)str {
  48. [self setStringValue:str forAttribute:kLabelAttr];
  49. }
  50. - (NSString *)rel {
  51. return [self stringValueForAttribute:kRelAttr];
  52. }
  53. - (void)setRel:(NSString *)str {
  54. [self setStringValue:str forAttribute:kRelAttr];
  55. }
  56. - (NSString *)href {
  57. return [self stringValueForAttribute:kHrefAttr];
  58. }
  59. - (void)setHref:(NSString *)str {
  60. [self setStringValue:str forAttribute:kHrefAttr];
  61. }
  62. - (BOOL)isPrimary {
  63. return [self boolValueForAttribute:kPrimaryAttr defaultValue:NO];
  64. }
  65. - (void)setIsPrimary:(BOOL)flag {
  66. [self setBoolValue:flag defaultValue:NO forAttribute:kPrimaryAttr];
  67. }
  68. @end
  69. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE