@@ -165,13 +165,11 @@ { self = [super init]; @try { if (name == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _name = [name copy]; _namespace = [namespace copy]; _namespaces = [[OFMutableDictionary alloc] @@ -193,13 +191,11 @@ { self = [super init]; @try { if (element == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _name = [element->_name copy]; _namespace = [element->_namespace copy]; _defaultNamespace = [element->_defaultNamespace copy]; _attributes = [element->_attributes mutableCopy]; @@ -223,12 +219,11 @@ c = [self class]; [self release]; if (string == nil) - @throw [OFInvalidArgumentException exceptionWithClass: c - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); parser = [OFXMLParser parser]; builder = [OFXMLElementBuilder elementBuilder]; @@ -239,12 +234,11 @@ [builder setDelegate: delegate]; [parser parseString: string]; if (![parser finishedParsing]) - @throw [OFMalformedXMLException exceptionWithClass: c - parser: parser]; + @throw [OFMalformedXMLException exceptionWithParser: parser]; self = [delegate->_element retain]; objc_autoreleasePoolPop(pool); @@ -273,12 +267,11 @@ [builder setDelegate: delegate]; [parser parseFile: path]; if (![parser finishedParsing]) - @throw [OFMalformedXMLException exceptionWithClass: c - parser: parser]; + @throw [OFMalformedXMLException exceptionWithParser: parser]; self = [delegate->_element retain]; objc_autoreleasePoolPop(pool); @@ -296,13 +289,11 @@ 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]; + @throw [OFInvalidArgumentException exception]; _name = [[[element attributeForName: @"name"] stringValue] copy]; _namespace = [[[element attributeForName: @"namespace"] stringValue] copy]; @@ -333,37 +324,29 @@ 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]; + @throw [OFInvalidArgumentException exception]; objectEnumerator = [_attributes objectEnumerator]; while ((object = [objectEnumerator nextObject]) != nil) if (![object isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; 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]; + @throw [OFInvalidArgumentException exception]; objectEnumerator = [_children objectEnumerator]; while ((object = [objectEnumerator nextObject]) != nil) if (![object isKindOfClass: [OFXMLNode class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (_namespaces == nil) _namespaces = [[OFMutableDictionary alloc] init]; [_namespaces @@ -371,13 +354,11 @@ 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]; + @throw [OFInvalidArgumentException exception]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -399,13 +380,11 @@ } - (void)setName: (OFString*)name { if (name == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; OF_SETTER(_name, name, true, 1) } - (OFString*)name @@ -583,14 +562,13 @@ if ([attributesObjects[j] namespace] != nil && (attributePrefix = [allNamespaces objectForKey: [attributesObjects[j] namespace]]) == nil) @throw [OFUnboundNamespaceException - exceptionWithClass: [self class] - namespace: [attributesObjects[j] - namespace] - element: self]; + exceptionWithNamespace: [attributesObjects[j] + namespace] + element: self]; length += [attributeName UTF8StringLength] + (attributePrefix != nil ? [attributePrefix UTF8StringLength] + 1 : 0) + [tmp UTF8StringLength] + 4; @@ -921,13 +899,11 @@ - (void)setPrefix: (OFString*)prefix forNamespace: (OFString*)namespace { if ([prefix length] == 0) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (namespace == nil) namespace = @""; [_namespaces setObject: prefix forKey: namespace]; @@ -954,13 +930,11 @@ } - (void)addChild: (OFXMLNode*)child { if ([child isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (_children == nil) _children = [[OFMutableArray alloc] init]; [_children addObject: child]; @@ -968,13 +942,11 @@ - (void)insertChild: (OFXMLNode*)child atIndex: (size_t)index { if ([child isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (_children == nil) _children = [[OFMutableArray alloc] init]; [_children insertObject: child @@ -988,13 +960,11 @@ OFEnumerator *enumerator = [children objectEnumerator]; OFXMLNode *node; while ((node = [enumerator nextObject]) != nil) if ([node isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_children insertObjectsFromArray: children atIndex: index]; objc_autoreleasePoolPop(pool); @@ -1001,13 +971,11 @@ } - (void)removeChild: (OFXMLNode*)child { if ([child isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_children removeObject: child]; } - (void)removeChildAtIndex: (size_t)index @@ -1018,25 +986,21 @@ - (void)replaceChild: (OFXMLNode*)child withNode: (OFXMLNode*)node { if ([node isKindOfClass: [OFXMLAttribute class]] || [child isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_children replaceObject: child withObject: node]; } - (void)replaceChildAtIndex: (size_t)index withNode: (OFXMLNode*)node { if ([node isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_children replaceObjectAtIndex: index withObject: node]; }