PageRenderTime 39ms CodeModel.GetById 19ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

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