ObjFW  Diff

Differences From Artifact [1510166b61]:

To Artifact [37f60bba81]:


16
17
18
19
20
21
22

23
24
25
26
27
28

29
30
31

32
33
34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
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

87
88
89
90
91
92
93
94
95


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

113
114

115
116
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

33







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56





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

87
88
89







+






+


-
+
-
-
-
-
-
-
-
+
















+





-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-











-
+






-
-
-
+
+
-
-
-
-
-
-
-
-
-







-
+

-
+



#include "config.h"

#include <stdlib.h>

#import "OFUnboundNamespaceException.h"
#import "OFString.h"
#import "OFXMLElement.h"

#import "common.h"

@implementation OFUnboundNamespaceException
+ (instancetype)exceptionWithClass: (Class)class
			 namespace: (OFString*)namespace
			   element: (OFXMLElement*)element
{
	return [[[self alloc] initWithClass: class
				  namespace: namespace] autorelease];
				  namespace: namespace
}

+ (instancetype)exceptionWithClass: (Class)class
			    prefix: (OFString*)prefix
{
	return [[[self alloc] initWithClass: class
				     prefix: prefix] autorelease];
				    element: element] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
      namespace: (OFString*)namespace
	element: (OFXMLElement*)element
{
	self = [super initWithClass: class];

	@try {
		_namespace = [namespace copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

		_element = [element retain];
	return self;
}

- initWithClass: (Class)class
	 prefix: (OFString*)prefix
{
	self = [super initWithClass: class];

	@try {
		_prefix = [prefix copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_namespace release];
	[_prefix release];
	[_element release];

	[super dealloc];
}

- (OFString*)description
{
	if (_namespace != nil)
		return [OFString stringWithFormat:
		    @"The namespace %@ is not bound in class %@", _namespace,
	return [OFString stringWithFormat:
	    @"The namespace %@ is not bound in class %@", _namespace, _inClass];
		    _inClass];
	else if (_prefix != nil)
		return [OFString stringWithFormat:
		    @"The prefix %@ is not bound to any namespace in class %@",
		    _prefix, _inClass];
	else
		return [OFString stringWithFormat:
		    @"A namespace or prefix is not bound in class %@",
		    _inClass];
}

- (OFString*)namespace
{
	OF_GETTER(_namespace, false)
}

- (OFString*)prefix
- (OFXMLElement*)element
{
	OF_GETTER(_prefix, false)
	OF_GETTER(_element, false)
}
@end