2 Copyright (C) 2000-2005 SKYRIX Software AG
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 "SoObjectResultEntry.h"
25 @implementation SoObjectResultEntry
27 static BOOL debugOn = NO;
29 - (id)initWithURI:(NSString *)_href object:(id)_o values:(NSDictionary *)_d {
30 if ((self = [super init])) {
32 // TODO: this happens if we access using Goliath
33 if ([_href hasPrefix:@"http:/"] && ![_href hasPrefix:@"http://"]) {
34 [self logWithFormat:@"BROKEN URL: %@", _href];
41 self->href = [_href copy];
42 self->values = [_d retain];
43 self->object = [_o retain];
48 return [self initWithURI:nil object:nil values:nil];
53 [self->values release];
54 [self->object release];
60 - (NSArray *)attributeKeys {
61 return [self->values allKeys];
66 - (NSArray *)allKeys {
67 return [self->values allKeys];
69 - (NSEnumerator *)keyEnumerator {
70 return [self->values keyEnumerator];
72 - (id)objectForKey:(id)_key {
73 return [self->values objectForKey:_key];
78 - (BOOL)kvcIsPreferredInKeyPath {
80 This is difficult to grasp. It says, that the WOKeyPathAssociation
81 should *always* use -valueForKey:, even if the object has an accessors
82 method matching the key.
83 It's required for all "storage" type objects.
88 - (id)valueForKey:(NSString *)_key {
89 if ([_key isEqualToString:@"{DAV:}href"])
92 if ([_key isEqualToString:@"{DAV:}status"])
96 return [self->values objectForKey:_key];
99 id v = [self->values objectForKey:_key];
100 [self logWithFormat:@"key %@: %@", _key, v];
107 - (NSString *)description {
110 ms = [NSMutableString stringWithCapacity:64];
111 [ms appendFormat:@"<0x%p[%@]:", self,
112 NSStringFromClass((Class)*(void**)self)];
115 [ms appendFormat:@" uri=%@", self->href];
118 [ms appendFormat:@" obj=0x%p[%@]",
119 self->object, NSStringFromClass([self->object class])];
122 if ([self->values count] > 0) {
126 [ms appendString:@" values"];
127 e = [self->values keyEnumerator];
128 while ((k = [e nextObject]))
129 [ms appendFormat:@":%@=%@", k, [self->values objectForKey:k]];
132 [ms appendString:@">"];
136 @end /* SoObjectResultEntry */
138 @implementation SoObjectErrorEntry
140 - (id)initWithURI:(NSString *)_href object:(id)_o error:(NSException *)_e {
141 self->href = [_href copy];
142 self->error = [_e retain];
143 self->object = [_o retain];
148 [self->object release];
149 [self->href release];
150 [self->error release];
156 - (NSArray *)allKeys {
159 - (NSEnumerator *)keyEnumerator {
162 - (id)objectForKey:(id)_key {
168 - (BOOL)kvcIsPreferredInKeyPath {
172 - (id)valueForKey:(NSString *)_key {
173 if ([_key isEqualToString:@"{DAV:}href"])
175 else if ([_key isEqualToString:@"{DAV:}status"])
183 - (NSString *)description {
186 ms = [NSMutableString stringWithCapacity:64];
187 [ms appendFormat:@"<0x%p[%@]:", self,
188 NSStringFromClass((Class)*(void**)self)];
191 [ms appendFormat:@" uri=%@", self->href];
194 [ms appendFormat:@" obj=0x%p[%@]",
195 self->object, NSStringFromClass([self->object class])];
199 [ms appendFormat:@" error=%@", self->error];
201 [ms appendString:@">"];
205 @end /* SoObjectErrorEntry */