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 "XmlRpcMethodResponse.h"
23 #include "XmlRpcCoder.h"
26 @interface XmlRpcMethodResponse(PrivateMethodes)
27 - (NSString *)_encodeXmlRpcMethodResponse;
30 @implementation XmlRpcMethodResponse
32 - (id)initWithXmlRpcString:(NSString *)_string {
34 XmlRpcMethodResponse *baseResponse;
36 if ([_string length] == 0) {
41 coder = [[XmlRpcDecoder alloc] initForReadingWithString:_string];
42 baseResponse = [coder decodeMethodResponse];
45 if (baseResponse == nil) {
50 self = [self initWithResult:[baseResponse result]];
54 - (id)initWithXmlRpcData:(NSData *)_data {
56 XmlRpcMethodResponse *baseResponse;
58 if ([_data length] == 0) {
63 coder = [[XmlRpcDecoder alloc] initForReadingWithData:_data];
64 baseResponse = [coder decodeMethodResponse];
67 if (baseResponse == nil) {
72 self = [self initWithResult:[baseResponse result]];
77 - (id)initWithResult:(id)_result {
78 if ((self = [super init])) {
79 self->result = [_result retain];
85 [self->result release];
91 - (void)setResult:(id)_result {
92 [self->result autorelease];
93 self->result = [_result retain];
99 - (NSString *)xmlRpcString {
100 return [self _encodeXmlRpcMethodResponse];
105 - (NSString *)description {
108 ms = [NSMutableString stringWithCapacity:64];
109 [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
112 [ms appendFormat:@" %@", self->result];
114 [ms appendString:@" no result"];
116 [ms appendString:@">"];
120 @end /* XmlRpcMethodResponse */
122 @implementation XmlRpcMethodResponse(PrivateMethodes)
124 - (NSString *)_encodeXmlRpcMethodResponse {
125 XmlRpcEncoder *encoder = nil;
126 NSMutableString *str = nil;
128 str = [NSMutableString stringWithCapacity:512];
130 encoder = [[XmlRpcEncoder alloc] initForWritingWithMutableString:str];
131 [encoder encodeMethodResponse:self];
137 @end /* XmlRpcMethodResponse(PrivateMethodes) */