001: /*
002: * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
003: * Copyright (C) 2005 - Javolution (http://javolution.org/)
004: * All rights reserved.
005: *
006: * Permission to use, copy, modify, and distribute this software is
007: * freely granted, provided that this notice is preserved.
008: */
009: package javolution.xml.stream;
010:
011: /**
012: * This class represents the base exception for unexpected processing errors.
013: *
014: * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
015: * @version 3.8, May 22, 2006
016: */
017: public class XMLStreamException extends Exception {
018:
019: /**
020: * Holds the nested exception if any.
021: */
022: private Throwable _nested;
023:
024: /**
025: * Holds the location.
026: */
027: private Location _location;
028:
029: /**
030: * Default constructor
031: */
032: public XMLStreamException() {
033: super ();
034: }
035:
036: /**
037: * Constructs an exception with the assocated message.
038: *
039: * @param msg the message to report.
040: */
041: public XMLStreamException(String msg) {
042: super (msg);
043: }
044:
045: /**
046: * Constructs an exception with the assocated nested exception.
047: *
048: * @param nested the nested exception.
049: */
050: public XMLStreamException(Throwable nested) {
051: _nested = nested;
052: }
053:
054: /**
055: * Constructs an exception with the assocated message and exception.
056: *
057: * @param msg the message to report.
058: * @param nested the nested exception.
059: */
060: public XMLStreamException(String msg, Throwable nested) {
061: super (msg);
062: _nested = nested;
063: }
064:
065: /**
066: * Constructs an exception with the assocated message, exception and
067: * location.
068: *
069: * @param msg the message to report.
070: * @param location the location.
071: * @param nested the nested exception.
072: */
073: public XMLStreamException(String msg, Location location,
074: Throwable nested) {
075: super (msg);
076: _nested = nested;
077: _location = location;
078: }
079:
080: /**
081: * Constructs an exception with the assocated message, exception and
082: * location.
083: *
084: * @param msg the message to report
085: * @param location the location of the error
086: */
087: public XMLStreamException(String msg, Location location) {
088: super (msg);
089: _location = location;
090: }
091:
092: /**
093: * Returns the nested exception.
094: *
095: * @return the nested exception
096: */
097: public Throwable getNestedException() {
098: return _nested;
099: }
100:
101: /**
102: * Returns the location of the exception.
103: *
104: * @return the location of the exception or <code>null</code>
105: * if none is available
106: */
107: public Location getLocation() {
108: return _location;
109: }
110:
111: /**
112: * Returns the textual representation of this exception.
113: *
114: * @return the string representation of the exception.
115: */
116: public String toString() {
117: String msg = super .toString();
118: if (_location != null) {
119: msg += " (at line " + _location.getLineNumber()
120: + ", column " + _location.getColumnNumber() + ")";
121: }
122: if (_nested != null) {
123: msg += " caused by " + _nested.toString();
124: }
125: return msg;
126: }
127:
128: private static final long serialVersionUID = 1L;
129: }
|