2 Copyright (C) 2005 Helge Hess
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "NGVCardOrg.h"
25 @implementation NGVCardOrg
28 [self->orgnam release];
29 [self->orgunits release];
35 - (NSString *)orgnam {
38 - (NSArray *)orgunits {
39 return self->orgunits;
42 /* fake being an array */
44 - (id)objectAtIndex:(unsigned)_idx {
48 return (s = [self orgnam]) ? s : (NSString *)[NSNull null];
50 return [self->orgunits objectAtIndex:(_idx - 1)];
53 return 1 + [self->orgunits count];
58 - (NSString *)stringValue {
59 return [self vCardString];
62 - (NSString *)xmlString {
67 ms = [[NSMutableString alloc] initWithCapacity:256];
68 [self appendXMLTag:@"orgnam" value:[self orgnam] to:ms];
70 for (i = 0; i < [self->orgunits count]; i++) {
71 [self appendXMLTag:@"orgunit" value:[self->orgunits objectAtIndex:i]
74 s = [[ms copy] autorelease];
79 - (NSString *)vCardString {
84 ms = [[NSMutableString alloc] initWithCapacity:64];
85 [self appendVCardValue:[self orgnam] to:ms];
86 for (i = 0; i < [self->orgunits count]; i++) {
87 [ms appendString:@";"];
88 [self appendVCardValue:[self->orgunits objectAtIndex:i] to:ms];
90 s = [[ms copy] autorelease];
95 - (NSDictionary *)asDictionary {
96 static NSString *keys[2] = { @"orgnam", @"orgunits" };
99 values[0] = [self orgnam];
100 values[1] = [self orgunits];
102 return [NSDictionary dictionaryWithObjects:values forKeys:keys
106 - (NSArray *)asArray {
107 id values[[self count] + 1];
110 for (i = 0; i < [self count]; i++)
111 values[i] = [self objectAtIndex:i];
113 return [NSArray arrayWithObjects:values count:[self count]];
118 - (void)encodeWithCoder:(NSCoder *)_coder {
119 [super encodeWithCoder:_coder];
121 [_coder encodeObject:self->orgnam];
122 [_coder encodeObject:self->orgunits];
124 - (id)initWithCoder:(NSCoder *)_coder {
125 if ((self = [super initWithCoder:_coder]) != nil) {
126 self->orgnam = [[_coder decodeObject] copy];
127 self->orgunits = [[_coder decodeObject] copy];
134 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
135 [super appendAttributesToDescription:_ms];
138 @end /* NGVCardOrg */