/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/CodeSearch/GDataCodeSearchPackage.m

http://macfuse.googlecode.com/ · Objective C · 122 lines · 74 code · 25 blank · 23 comment · 7 complexity · 3ac47221cc89903f3781f795a616b99c 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. // GDataCodeSearchPackage.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CODESEARCH_SERVICE
  19. #import "GDataCodeSearchPackage.h"
  20. #import "GDataEntryCodeSearch.h"
  21. @implementation GDataCodeSearchPackage
  22. // For code search packages, like
  23. //
  24. // <gcs:package name="http://www.w3.org/Library/Distribution/w3c-libwww-5.4.0.zip"
  25. // uri="http://www.w3.org/Library/Distribution/w3c-libwww-5.4.0.zip"/>
  26. //
  27. // See http://code.google.com/apis/codesearch/reference.html
  28. + (NSString *)extensionElementURI { return kGDataNamespaceCodeSearch; }
  29. + (NSString *)extensionElementPrefix { return kGDataNamespaceCodeSearchPrefix; }
  30. + (NSString *)extensionElementLocalName { return @"package"; }
  31. + (id)packageWithName:(NSString *)name
  32. URI:(NSString *)uri {
  33. GDataCodeSearchPackage *obj = [self object];
  34. [obj setName:name];
  35. [obj setURI:uri];
  36. return obj;
  37. }
  38. - (id)initWithXMLElement:(NSXMLElement *)element
  39. parent:(GDataObject *)parent {
  40. self = [super initWithXMLElement:element
  41. parent:parent];
  42. if (self) {
  43. [self setName:[self stringForAttributeName:@"name"
  44. fromElement:element]];
  45. [self setURI:[self stringForAttributeName:@"uri"
  46. fromElement:element]];
  47. }
  48. return self;
  49. }
  50. - (void)dealloc {
  51. [name_ release];
  52. [uri_ release];
  53. [super dealloc];
  54. }
  55. - (id)copyWithZone:(NSZone *)zone {
  56. GDataCodeSearchPackage* newObj = [super copyWithZone:zone];
  57. [newObj setName:[self name]];
  58. [newObj setURI:[self URI]];
  59. return newObj;
  60. }
  61. - (BOOL)isEqual:(GDataCodeSearchPackage *)other {
  62. if (self == other) return YES;
  63. if (![other isKindOfClass:[GDataCodeSearchPackage class]]) return NO;
  64. return [super isEqual:other]
  65. && AreEqualOrBothNil([self name], [other name])
  66. && AreEqualOrBothNil([self URI], [other URI]);
  67. }
  68. #if !GDATA_SIMPLE_DESCRIPTIONS
  69. - (NSMutableArray *)itemsForDescription {
  70. NSMutableArray *items = [NSMutableArray array];
  71. [self addToArray:items objectDescriptionIfNonNil:name_ withName:@"name"];
  72. [self addToArray:items objectDescriptionIfNonNil:uri_ withName:@"URI"];
  73. return items;
  74. }
  75. #endif
  76. - (NSXMLElement *)XMLElement {
  77. NSXMLElement *element = [self XMLElementWithExtensionsAndDefaultName:nil];
  78. [self addToElement:element attributeValueIfNonNil:[self name] withName:@"name"];
  79. [self addToElement:element attributeValueIfNonNil:[self URI] withName:@"uri"];
  80. return element;
  81. }
  82. - (NSString *)name {
  83. return name_;
  84. }
  85. - (void)setName:(NSString *)str {
  86. [name_ autorelease];
  87. name_ = [str copy];
  88. }
  89. - (NSString *)URI {
  90. return uri_;
  91. }
  92. - (void)setURI:(NSString *)str {
  93. [uri_ autorelease];
  94. uri_ = [str copy];
  95. }
  96. @end
  97. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CODESEARCH_SERVICE