PageRenderTime 31ms CodeModel.GetById 1ms app.highlight 26ms RepoModel.GetById 1ms app.codeStats 0ms

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