PageRenderTime 41ms CodeModel.GetById 13ms app.highlight 24ms RepoModel.GetById 2ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Elements/GDataPerson.m

http://macfuse.googlecode.com/
Objective C | 138 lines | 86 code | 27 blank | 25 comment | 0 complexity | 0d1080bf44cee90ec17880aabc83e4d1 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//  GDataPerson.m
 18//
 19
 20#import "GDataPerson.h"
 21#import "GDataValueConstruct.h"
 22
 23static NSString *const kLangAttr = @"xml:lang";
 24
 25// name, like <atom:name>Fred Flintstone<atom:name>
 26@interface GDataPersonName : GDataValueElementConstruct <GDataExtension>
 27@end
 28
 29@implementation GDataPersonName
 30+ (NSString *)extensionElementURI       { return kGDataNamespaceAtom; }
 31+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAtomPrefix; }
 32+ (NSString *)extensionElementLocalName { return @"name"; }
 33@end
 34
 35// email, like <atom:email>fred@flintstone.com<atom:email>
 36@interface GDataPersonEmail : GDataValueElementConstruct <GDataExtension>
 37@end
 38
 39@implementation GDataPersonEmail
 40+ (NSString *)extensionElementURI       { return kGDataNamespaceAtom; }
 41+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAtomPrefix; }
 42+ (NSString *)extensionElementLocalName { return @"email"; }
 43@end
 44
 45// URI, like <atom:uri>http://flintstone.com/resource<atom:uri>
 46@interface GDataPersonURI : GDataValueElementConstruct <GDataExtension>
 47@end
 48
 49@implementation GDataPersonURI
 50+ (NSString *)extensionElementURI       { return kGDataNamespaceAtom; }
 51+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAtomPrefix; }
 52+ (NSString *)extensionElementLocalName { return @"uri"; }
 53@end
 54
 55@implementation GDataPerson
 56// a person, as in
 57// <author>
 58//   <name>Fred Flintstone</name>
 59//   <email>fred@flintstone.com</email>
 60// </author>
 61
 62+ (NSString *)extensionElementURI       { return kGDataNamespaceAtom; }
 63+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAtomPrefix; }
 64+ (NSString *)extensionElementLocalName { return @"author"; }
 65
 66+ (GDataPerson *)personWithName:(NSString *)name email:(NSString *)email {
 67  GDataPerson* obj = [self object];
 68  [obj setName:name];
 69  [obj setEmail:email];
 70  return obj;
 71}
 72
 73- (void)addParseDeclarations {
 74  [self addLocalAttributeDeclarations:[NSArray arrayWithObject:kLangAttr]];
 75}
 76
 77- (void)addExtensionDeclarations {
 78
 79  [super addExtensionDeclarations];
 80
 81  [self addExtensionDeclarationForParentClass:[self class]
 82                                 childClasses:
 83   [GDataPersonName class],
 84   [GDataPersonEmail class],
 85   [GDataPersonURI class],
 86   nil];
 87}
 88
 89#if !GDATA_SIMPLE_DESCRIPTIONS
 90- (NSMutableArray *)itemsForDescription {
 91  NSMutableArray *items = [super itemsForDescription];
 92
 93  [self addToArray:items objectDescriptionIfNonNil:[self name] withName:@"name"];
 94  [self addToArray:items objectDescriptionIfNonNil:[self URI] withName:@"URI"];
 95  [self addToArray:items objectDescriptionIfNonNil:[self email] withName:@"email"];
 96
 97  return items;
 98}
 99#endif
100
101- (NSString *)name {
102  GDataPersonName *obj = [self objectForExtensionClass:[GDataPersonName class]];
103  return [obj stringValue];
104}
105
106- (void)setName:(NSString *)str {
107  GDataPersonName *obj = [GDataPersonName valueWithString:str];
108  [self setObject:obj forExtensionClass:[GDataPersonName class]];
109}
110
111- (NSString *)nameLang {
112  return [self stringValueForAttribute:kLangAttr];
113}
114
115- (void)setNameLang:(NSString *)str {
116  [self setStringValue:str forAttribute:kLangAttr];
117}
118
119- (NSString *)URI {
120  GDataPersonURI *obj = [self objectForExtensionClass:[GDataPersonURI class]];
121  return [obj stringValue];
122}
123
124- (void)setURI:(NSString *)str {
125  GDataPersonURI *obj = [GDataPersonURI valueWithString:str];
126  [self setObject:obj forExtensionClass:[GDataPersonURI class]];
127}
128
129- (NSString *)email {
130  GDataPersonEmail *obj = [self objectForExtensionClass:[GDataPersonEmail class]];
131  return [obj stringValue];
132}
133
134- (void)setEmail:(NSString *)str {
135  GDataPersonEmail *obj = [GDataPersonEmail valueWithString:str];
136  [self setObject:obj forExtensionClass:[GDataPersonEmail class]];
137}
138@end