57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
- initWithSerialization: (OFXMLElement*)element
{
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
name = [[[element
elementForName: @"name"
namespace: OF_SERIALIZATION_NS] stringValue] retain];
ns = [[[element
elementForName: @"namespace"
namespace: OF_SERIALIZATION_NS] stringValue] retain];
stringValue = [[[element
elementForName: @"stringValue"
namespace: OF_SERIALIZATION_NS] stringValue] retain];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
|
|
<
<
|
|
<
|
<
<
>
|
|
<
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
- initWithSerialization: (OFXMLElement*)element
{
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
name = [[[element attributeForName: @"name"] stringValue]
copy];
ns = [[[element attributeForName: @"namespace"] stringValue]
copy];
stringValue = [[[element attributeForName: @"stringValue"]
stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
OF_HASH_FINALIZE(hash);
return hash;
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"object"
namespace: OF_SERIALIZATION_NS];
pool = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
[element addChild:
[OFXMLElement elementWithName: @"name"
namespace: OF_SERIALIZATION_NS
stringValue: name]];
if (ns != nil)
[element addChild:
[OFXMLElement elementWithName: @"namespace"
namespace: OF_SERIALIZATION_NS
stringValue: ns]];
[element addChild:
[OFXMLElement elementWithName: @"stringValue"
namespace: OF_SERIALIZATION_NS
stringValue: stringValue]];
[pool release];
return element;
}
@end
|
|
|
<
<
|
|
<
<
<
<
|
<
<
|
|
|
<
|
>
>
|
>
>
>
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
OF_HASH_FINALIZE(hash);
return hash;
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS];
[element addAttributeWithName: @"name"
stringValue: name];
if (ns != nil)
[element addAttributeWithName: @"namespace"
stringValue: ns];
[element addAttributeWithName: @"stringValue"
stringValue: stringValue];
[element retain];
@try {
[pool release];
} @finally {
[element autorelease];
}
return element;
}
@end
|