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 "XmlRpcMethodResponse.h"
24 #include "XmlRpcCoder.h"
27 @interface XmlRpcMethodResponse(PrivateMethodes)
28 - (NSString *)_encodeXmlRpcMethodResponse;
31 @implementation XmlRpcMethodResponse
33 - (id)initWithXmlRpcString:(NSString *)_string {
35 XmlRpcMethodResponse *baseResponse;
37 if ([_string length] == 0) {
42 coder = [[XmlRpcDecoder alloc] initForReadingWithString:_string];
43 baseResponse = [coder decodeMethodResponse];
46 if (baseResponse == nil) {
51 self = [self initWithResult:[baseResponse result]];
55 - (id)initWithXmlRpcData:(NSData *)_data {
57 XmlRpcMethodResponse *baseResponse;
59 if ([_data length] == 0) {
64 coder = [[XmlRpcDecoder alloc] initForReadingWithData:_data];
65 baseResponse = [coder decodeMethodResponse];
68 if (baseResponse == nil) {
73 self = [self initWithResult:[baseResponse result]];
78 - (id)initWithResult:(id)_result {
79 if ((self = [super init])) {
80 self->result = [_result retain];
86 [self->result release];
92 - (void)setResult:(id)_result {
93 [self->result autorelease];
94 self->result = [_result retain];
100 - (NSString *)xmlRpcString {
101 return [self _encodeXmlRpcMethodResponse];
106 - (NSString *)description {
109 ms = [NSMutableString stringWithCapacity:64];
110 [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
113 [ms appendFormat:@" %@", self->result];
115 [ms appendString:@" no result"];
117 [ms appendString:@">"];
121 @end /* XmlRpcMethodResponse */
123 @implementation XmlRpcMethodResponse(PrivateMethodes)
125 - (NSString *)_encodeXmlRpcMethodResponse {
126 XmlRpcEncoder *encoder = nil;
127 NSMutableString *str = nil;
129 str = [NSMutableString stringWithCapacity:512];
131 encoder = [[XmlRpcEncoder alloc] initForWritingWithMutableString:str];
132 [encoder encodeMethodResponse:self];
138 @end /* XmlRpcMethodResponse(PrivateMethodes) */