KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javolution > xml > stream > XMLStreamException


1 /*
2  * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
3  * Copyright (C) 2005 - Javolution (http://javolution.org/)
4  * All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software is
7  * freely granted, provided that this notice is preserved.
8  */

9 package javolution.xml.stream;
10
11 /**
12  * This class represents the base exception for unexpected processing errors.
13  *
14  * @author <a HREF="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
15  * @version 3.8, May 22, 2006
16  */

17 public class XMLStreamException extends Exception JavaDoc {
18
19     /**
20      * Holds the nested exception if any.
21      */

22     private Throwable JavaDoc _nested;
23
24     /**
25      * Holds the location.
26      */

27     private Location _location;
28
29     /**
30      * Default constructor
31      */

32     public XMLStreamException() {
33         super();
34     }
35
36     /**
37      * Constructs an exception with the assocated message.
38      *
39      * @param msg the message to report.
40      */

41     public XMLStreamException(String JavaDoc msg) {
42         super(msg);
43     }
44
45     /**
46      * Constructs an exception with the assocated nested exception.
47      *
48      * @param nested the nested exception.
49      */

50     public XMLStreamException(Throwable JavaDoc nested) {
51         _nested = nested;
52     }
53
54     /**
55      * Constructs an exception with the assocated message and exception.
56      *
57      * @param msg the message to report.
58      * @param nested the nested exception.
59      */

60     public XMLStreamException(String JavaDoc msg, Throwable JavaDoc nested) {
61         super(msg);
62         _nested = nested;
63     }
64
65     /**
66      * Constructs an exception with the assocated message, exception and
67      * location.
68      *
69      * @param msg the message to report.
70      * @param location the location.
71      * @param nested the nested exception.
72      */

73     public XMLStreamException(String JavaDoc msg, Location location, Throwable JavaDoc nested) {
74         super(msg);
75         _nested = nested;
76         _location = location;
77     }
78
79     /**
80      * Constructs an exception with the assocated message, exception and
81      * location.
82      *
83      * @param msg the message to report
84      * @param location the location of the error
85      */

86     public XMLStreamException(String JavaDoc msg, Location location) {
87         super(msg);
88         _location = location;
89     }
90
91     /**
92      * Returns the nested exception.
93      *
94      * @return the nested exception
95      */

96     public Throwable JavaDoc getNestedException() {
97         return _nested;
98     }
99
100     /**
101      * Returns the location of the exception.
102      *
103      * @return the location of the exception or <code>null</code>
104      * if none is available
105      */

106     public Location getLocation() {
107         return _location;
108     }
109
110     /**
111      * Returns the textual representation of this error.
112      *
113      * @return the string representation of the error.
114      */

115     public String JavaDoc toString() {
116         String JavaDoc msg = super.toString();
117         if (_location != null) {
118             msg += " (at line " + _location.getLineNumber() + ", column "
119                     + _location.getColumnNumber() + ")";
120         }
121         if (_nested != null) {
122             msg += " caused by " + _nested.toString();
123         }
124         return msg;
125     }
126
127     private static final long serialVersionUID = 1L;
128 }
129
Popular Tags