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

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