|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.xml.parser; |
|
19 |
| |
|
20 |
| import java.io.IOException; |
|
21 |
| import java.util.ArrayList; |
|
22 |
| import java.util.List; |
|
23 |
| |
|
24 |
| import javax.xml.parsers.ParserConfigurationException; |
|
25 |
| |
|
26 |
| import org.qedeq.kernel.common.SourceArea; |
|
27 |
| import org.qedeq.kernel.common.SourceFileException; |
|
28 |
| import org.qedeq.kernel.common.SourceFileExceptionList; |
|
29 |
| import org.qedeq.kernel.trace.Trace; |
|
30 |
| import org.qedeq.kernel.xml.common.XmlSyntaxException; |
|
31 |
| import org.xml.sax.SAXException; |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| public class DefaultSourceFileExceptionList extends SourceFileExceptionList { |
|
42 |
| |
|
43 |
| |
|
44 |
| private static final Class CLASS = DefaultSourceFileExceptionList.class; |
|
45 |
| |
|
46 |
| |
|
47 |
| private final List exceptions = new ArrayList(); |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
1007
| public DefaultSourceFileExceptionList() {
|
|
53 |
| } |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
10
| public DefaultSourceFileExceptionList(final IOException e) {
|
|
61 |
10
| initCause(e);
|
|
62 |
10
| add(new SourceFileException(e));
|
|
63 |
| } |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
0
| public DefaultSourceFileExceptionList(final SAXException e) {
|
|
71 |
0
| initCause(e);
|
|
72 |
0
| add(new SourceFileException(e));
|
|
73 |
| } |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
0
| public DefaultSourceFileExceptionList(final RuntimeException e) {
|
|
81 |
0
| initCause(e);
|
|
82 |
0
| add(new SourceFileException(e));
|
|
83 |
| } |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
0
| public DefaultSourceFileExceptionList(final Throwable e) {
|
|
91 |
0
| initCause(e);
|
|
92 |
0
| add(new SourceFileException(e));
|
|
93 |
0
| Trace.fatal(CLASS, "Constructor(Throwable)",
|
|
94 |
| "Major unexpected problem", e); |
|
95 |
| } |
|
96 |
| |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
0
| public DefaultSourceFileExceptionList(final Exception e) {
|
|
103 |
0
| initCause(e);
|
|
104 |
0
| Trace.fatal(CLASS, "Constructor(Exception)",
|
|
105 |
| "Unexpected problem", e); |
|
106 |
0
| add(new SourceFileException(e));
|
|
107 |
| } |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
0
| public DefaultSourceFileExceptionList(final SourceFileException e) {
|
|
115 |
0
| initCause(e);
|
|
116 |
0
| add(e);
|
|
117 |
| } |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
66
| public void add(final SourceFileException e) {
|
|
125 |
66
| exceptions.add(e);
|
|
126 |
| } |
|
127 |
| |
|
128 |
| |
|
129 |
| |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
0
| public final void add(final XmlSyntaxException e) {
|
|
134 |
0
| final SourceFileException sfe = new SourceFileException(e.getErrorCode(), e.getMessage(), e,
|
|
135 |
| new SourceArea(e.getErrorPosition().getAddress(), e.getErrorPosition(), null), null); |
|
136 |
| |
|
137 |
0
| exceptions.add(sfe);
|
|
138 |
| } |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
0
| public final void add(final SAXException e) {
|
|
146 |
0
| exceptions.add(new SourceFileException(e));
|
|
147 |
| } |
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
| |
|
154 |
0
| public final void add(final IOException e) {
|
|
155 |
0
| exceptions.add(new SourceFileException(e));
|
|
156 |
| } |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
0
| public void add(final ParserConfigurationException e) {
|
|
164 |
0
| exceptions.add(new SourceFileException(e));
|
|
165 |
| } |
|
166 |
| |
|
167 |
| |
|
168 |
| |
|
169 |
| |
|
170 |
| |
|
171 |
| |
|
172 |
0
| public void add(final RuntimeException e) {
|
|
173 |
0
| exceptions.add(new SourceFileException(e));
|
|
174 |
| } |
|
175 |
| |
|
176 |
| |
|
177 |
| |
|
178 |
| |
|
179 |
| |
|
180 |
| |
|
181 |
1324
| public final int size() {
|
|
182 |
1324
| return exceptions.size();
|
|
183 |
| } |
|
184 |
| |
|
185 |
| |
|
186 |
| |
|
187 |
| |
|
188 |
| |
|
189 |
| |
|
190 |
| |
|
191 |
520
| public final SourceFileException get(final int i) {
|
|
192 |
520
| return (SourceFileException) exceptions.get(i);
|
|
193 |
| } |
|
194 |
| |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
| |
|
199 |
| |
|
200 |
0
| public final SourceFileException[] toArray() {
|
|
201 |
0
| return (SourceFileException[]) exceptions.toArray(new SourceFileException[0]);
|
|
202 |
| } |
|
203 |
| |
|
204 |
204
| public String getMessage() {
|
|
205 |
204
| final StringBuffer buffer = new StringBuffer();
|
|
206 |
204
| for (int i = 0; i < size(); i++) {
|
|
207 |
258
| if (i != 0) {
|
|
208 |
54
| buffer.append("\n");
|
|
209 |
| } |
|
210 |
258
| final SourceFileException e = get(i);
|
|
211 |
258
| buffer.append(i).append(": ");
|
|
212 |
258
| buffer.append(e.toString());
|
|
213 |
| } |
|
214 |
204
| return buffer.toString();
|
|
215 |
| } |
|
216 |
| |
|
217 |
| } |