︙ | | | ︙ | |
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
+ elementWithFile: (OFString*)path
{
return [[[self alloc] initWithFile: path] autorelease];
}
- init
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithName: (OFString*)name_
{
|
|
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
+ elementWithFile: (OFString*)path
{
return [[[self alloc] initWithFile: path] autorelease];
}
- init
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithName: (OFString*)name_
{
|
︙ | | | ︙ | |
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
stringValue: (OFString*)stringValue
{
self = [super init];
@try {
if (name_ == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
name = [name_ copy];
ns = [ns_ copy];
namespaces = [[OFMutableDictionary alloc]
initWithKeysAndObjects:
|
|
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
stringValue: (OFString*)stringValue
{
self = [super init];
@try {
if (name_ == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
name = [name_ copy];
ns = [ns_ copy];
namespaces = [[OFMutableDictionary alloc]
initWithKeysAndObjects:
|
︙ | | | ︙ | |
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
- initWithElement: (OFXMLElement*)element
{
self = [super init];
@try {
if (element == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
name = [element->name copy];
ns = [element->ns copy];
defaultNamespace = [element->defaultNamespace copy];
attributes = [element->attributes mutableCopy];
namespaces = [element->namespaces mutableCopy];
|
|
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
- initWithElement: (OFXMLElement*)element
{
self = [super init];
@try {
if (element == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
name = [element->name copy];
ns = [element->ns copy];
defaultNamespace = [element->defaultNamespace copy];
attributes = [element->attributes mutableCopy];
namespaces = [element->namespaces mutableCopy];
|
︙ | | | ︙ | |
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
{
OFAutoreleasePool *pool;
OFXMLParser *parser;
OFXMLElementBuilder *builder;
OFXMLElement_OFXMLElementBuilderDelegate *delegate;
Class c;
c = isa;
[self release];
if (string == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
pool = [[OFAutoreleasePool alloc] init];
parser = [OFXMLParser parser];
builder = [OFXMLElementBuilder elementBuilder];
delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
|
|
|
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
{
OFAutoreleasePool *pool;
OFXMLParser *parser;
OFXMLElementBuilder *builder;
OFXMLElement_OFXMLElementBuilderDelegate *delegate;
Class c;
c = [self class];
[self release];
if (string == nil)
@throw [OFInvalidArgumentException exceptionWithClass: c
selector: _cmd];
pool = [[OFAutoreleasePool alloc] init];
parser = [OFXMLParser parser];
builder = [OFXMLElementBuilder elementBuilder];
delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
|
︙ | | | ︙ | |
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
{
OFAutoreleasePool *pool;
OFXMLParser *parser;
OFXMLElementBuilder *builder;
OFXMLElement_OFXMLElementBuilderDelegate *delegate;
Class c;
c = isa;
[self release];
pool = [[OFAutoreleasePool alloc] init];
parser = [OFXMLParser parser];
builder = [OFXMLElementBuilder elementBuilder];
delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
|
|
|
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
{
OFAutoreleasePool *pool;
OFXMLParser *parser;
OFXMLElementBuilder *builder;
OFXMLElement_OFXMLElementBuilderDelegate *delegate;
Class c;
c = [self class];
[self release];
pool = [[OFAutoreleasePool alloc] init];
parser = [OFXMLParser parser];
builder = [OFXMLElementBuilder elementBuilder];
delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
|
︙ | | | ︙ | |
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
OFXMLElement *childrenElement;
OFEnumerator *keyEnumerator, *objectEnumerator;
id key, object;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
name = [[[element attributeForName: @"name"] stringValue] copy];
ns = [[[element attributeForName: @"namespace"] stringValue]
copy];
defaultNamespace = [[[element attributeForName:
@"defaultNamespace"] stringValue] copy];
|
|
|
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
OFXMLElement *childrenElement;
OFEnumerator *keyEnumerator, *objectEnumerator;
id key, object;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
name = [[[element attributeForName: @"name"] stringValue] copy];
ns = [[[element attributeForName: @"namespace"] stringValue]
copy];
defaultNamespace = [[[element attributeForName:
@"defaultNamespace"] stringValue] copy];
|
︙ | | | ︙ | |
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
|
if ((attributes != nil &&
![attributes isKindOfClass: [OFMutableArray class]]) ||
(namespaces != nil &&
![namespaces isKindOfClass: [OFMutableDictionary class]]) ||
(children != nil &&
![children isKindOfClass: [OFMutableArray class]]))
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
objectEnumerator = [attributes objectEnumerator];
while ((object = [objectEnumerator nextObject]) != nil)
if (![object isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
keyEnumerator = [namespaces keyEnumerator];
objectEnumerator = [namespaces objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
if (![key isKindOfClass: [OFString class]] ||
![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
objectEnumerator = [children objectEnumerator];
while ((object = [objectEnumerator nextObject]) != nil)
if (![object isKindOfClass: [OFXMLNode class]])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
if (namespaces == nil)
namespaces = [[OFMutableDictionary alloc] init];
[namespaces setObject: @"xml"
forKey: @"http://www.w3.org/XML/1998/namespace"];
[namespaces setObject: @"xmlns"
forKey: @"http://www.w3.org/2000/xmlns/"];
if (name == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)setName: (OFString*)name_
{
if (name_ == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
OF_SETTER(name, name_, YES, 1)
}
- (OFString*)name
{
OF_GETTER(name, YES)
|
|
|
|
|
|
|
>
|
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
if ((attributes != nil &&
![attributes isKindOfClass: [OFMutableArray class]]) ||
(namespaces != nil &&
![namespaces isKindOfClass: [OFMutableDictionary class]]) ||
(children != nil &&
![children isKindOfClass: [OFMutableArray class]]))
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
objectEnumerator = [attributes objectEnumerator];
while ((object = [objectEnumerator nextObject]) != nil)
if (![object isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
keyEnumerator = [namespaces keyEnumerator];
objectEnumerator = [namespaces objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
if (![key isKindOfClass: [OFString class]] ||
![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
objectEnumerator = [children objectEnumerator];
while ((object = [objectEnumerator nextObject]) != nil)
if (![object isKindOfClass: [OFXMLNode class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if (namespaces == nil)
namespaces = [[OFMutableDictionary alloc] init];
[namespaces setObject: @"xml"
forKey: @"http://www.w3.org/XML/1998/namespace"];
[namespaces setObject: @"xmlns"
forKey: @"http://www.w3.org/2000/xmlns/"];
if (name == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)setName: (OFString*)name_
{
if (name_ == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
OF_SETTER(name, name_, YES, 1)
}
- (OFString*)name
{
OF_GETTER(name, YES)
|
︙ | | | ︙ | |
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
|
OFString *tmp =
[[attributesObjects[j] stringValue] stringByXMLEscaping];
if ([attributesObjects[j] namespace] != nil &&
(attributePrefix = [allNamespaces objectForKey:
[attributesObjects[j] namespace]]) == nil)
@throw [OFUnboundNamespaceException
exceptionWithClass: isa
namespace: [attributesObjects[j]
namespace]];
length += [attributeName UTF8StringLength] +
(attributePrefix != nil ?
[attributePrefix UTF8StringLength] + 1 : 0) +
[tmp UTF8StringLength] + 4;
|
|
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
|
OFString *tmp =
[[attributesObjects[j] stringValue] stringByXMLEscaping];
if ([attributesObjects[j] namespace] != nil &&
(attributePrefix = [allNamespaces objectForKey:
[attributesObjects[j] namespace]]) == nil)
@throw [OFUnboundNamespaceException
exceptionWithClass: [self class]
namespace: [attributesObjects[j]
namespace]];
length += [attributeName UTF8StringLength] +
(attributePrefix != nil ?
[attributePrefix UTF8StringLength] + 1 : 0) +
[tmp UTF8StringLength] + 4;
|
︙ | | | ︙ | |
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
|
}
}
- (void)setPrefix: (OFString*)prefix
forNamespace: (OFString*)ns_
{
if (prefix == nil || [prefix isEqual: @""])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
if (ns_ == nil)
ns_ = @"";
[namespaces setObject: prefix
forKey: ns_];
}
|
|
>
|
|
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
|
}
}
- (void)setPrefix: (OFString*)prefix
forNamespace: (OFString*)ns_
{
if (prefix == nil || [prefix isEqual: @""])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if (ns_ == nil)
ns_ = @"";
[namespaces setObject: prefix
forKey: ns_];
}
|
︙ | | | ︙ | |
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
|
{
OF_SETTER(defaultNamespace, ns_, YES, 1)
}
- (void)addChild: (OFXMLNode*)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
if (children == nil)
children = [[OFMutableArray alloc] init];
[children addObject: child];
}
- (void)removeChild: (OFXMLNode*)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
[children removeObject: child];
}
- (OFXMLElement*)elementForName: (OFString*)elementName
{
return [[self elementsForName: elementName] firstObject];
|
|
>
|
|
>
|
|
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
|
{
OF_SETTER(defaultNamespace, ns_, YES, 1)
}
- (void)addChild: (OFXMLNode*)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if (children == nil)
children = [[OFMutableArray alloc] init];
[children addObject: child];
}
- (void)removeChild: (OFXMLNode*)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
[children removeObject: child];
}
- (OFXMLElement*)elementForName: (OFString*)elementName
{
return [[self elementsForName: elementName] firstObject];
|
︙ | | | ︙ | |
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
|
OF_HASH_FINALIZE(hash);
return hash;
}
- copy
{
return [[isa alloc] initWithElement: self];
}
- (void)dealloc
{
[name release];
[ns release];
[defaultNamespace release];
|
|
|
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
|
OF_HASH_FINALIZE(hash);
return hash;
}
- copy
{
return [[[self class] alloc] initWithElement: self];
}
- (void)dealloc
{
[name release];
[ns release];
[defaultNamespace release];
|
︙ | | | ︙ | |