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