2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo 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 OGo 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 OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "SoObjectResultEntry.h"
26 @implementation SoObjectResultEntry
28 - (id)initWithURI:(NSString *)_href object:(id)_o values:(NSDictionary *)_d {
29 self->href = [_href copy];
30 self->values = [_d retain];
31 self->object = [_o retain];
37 [self->values release];
38 [self->object release];
44 - (NSArray *)attributeKeys {
45 return [self->values allKeys];
50 - (NSArray *)allKeys {
51 return [self->values allKeys];
53 - (NSEnumerator *)keyEnumerator {
54 return [self->values keyEnumerator];
56 - (id)objectForKey:(id)_key {
57 return [self->values objectForKey:_key];
62 - (BOOL)kvcIsPreferredInKeyPath {
64 This is difficult to grasp. It says, that the WOKeyPathAssociation
65 should *always* use -valueForKey:, even if the object has an accessors
66 method matching the key.
67 It's required for all "storage" type objects.
72 - (id)valueForKey:(NSString *)_key {
73 if ([_key isEqualToString:@"{DAV:}href"])
75 else if ([_key isEqualToString:@"{DAV:}status"])
79 return [self->values objectForKey:_key];
81 id v = [self->values objectForKey:_key];
82 [self logWithFormat:@"key %@: %@", _key, v];
90 - (NSString *)description {
93 ms = [NSMutableString stringWithCapacity:64];
94 [ms appendFormat:@"<0x%08X[%@]:", self,
95 NSStringFromClass((Class)*(void**)self)];
98 [ms appendFormat:@" uri=%@", self->href];
101 [ms appendFormat:@" obj=0x%08X[%@]",
102 self->object, NSStringFromClass([self->object class])];
105 if ([self->values count] > 0) {
109 [ms appendString:@" values"];
110 e = [self->values keyEnumerator];
111 while ((k = [e nextObject]))
112 [ms appendFormat:@":%@=%@", k, [self->values objectForKey:k]];
115 [ms appendString:@">"];
119 @end /* SoObjectResultEntry */
121 @implementation SoObjectErrorEntry
123 - (id)initWithURI:(NSString *)_href object:(id)_o error:(NSException *)_e {
124 self->href = [_href copy];
125 self->error = [_e retain];
126 self->object = [_o retain];
131 [self->object release];
132 [self->href release];
133 [self->error release];
139 - (NSArray *)allKeys {
142 - (NSEnumerator *)keyEnumerator {
145 - (id)objectForKey:(id)_key {
151 - (BOOL)kvcIsPreferredInKeyPath {
155 - (id)valueForKey:(NSString *)_key {
156 if ([_key isEqualToString:@"{DAV:}href"])
158 else if ([_key isEqualToString:@"{DAV:}status"])
166 - (NSString *)description {
169 ms = [NSMutableString stringWithCapacity:64];
170 [ms appendFormat:@"<0x%08X[%@]:", self,
171 NSStringFromClass((Class)*(void**)self)];
174 [ms appendFormat:@" uri=%@", self->href];
177 [ms appendFormat:@" obj=0x%08X[%@]",
178 self->object, NSStringFromClass([self->object class])];
182 [ms appendFormat:@" error=%@", self->error];
184 [ms appendString:@">"];
188 @end /* SoObjectErrorEntry */