KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > ejb > cmp3 > xml > parser > XMLException


1 package oracle.toplink.essentials.internal.ejb.cmp3.xml.parser;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import oracle.toplink.essentials.internal.helper.Helper;
7
8 public class XMLException extends RuntimeException JavaDoc {
9     private List JavaDoc m_nestedExceptions;
10
11     public XMLException() {
12         super();
13         m_nestedExceptions = new ArrayList JavaDoc();
14     }
15     
16     public void addNestedException(Exception JavaDoc nestedException) {
17         m_nestedExceptions.add(nestedException);
18     }
19     
20     public String JavaDoc getMessage() {
21         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
22         Exception JavaDoc nestedException;
23         for (int x=0; x<m_nestedExceptions.size(); x++) {
24             nestedException = (Exception JavaDoc) m_nestedExceptions.get(x);
25             buffer.append(Helper.cr());
26             buffer.append('(');
27             buffer.append(x + 1);
28             buffer.append(". ");
29             buffer.append(nestedException.getMessage());
30             buffer.append(')');
31         }
32         return buffer.toString();
33     }
34     
35     public String JavaDoc toString() { return getMessage(); }
36 }
37
Popular Tags