Constructors Summary |
---|
public TransformerException(String message, SourceLocator locator, Throwable e)Wrap an existing exception in a TransformerException.
super(message);
this.containedException = e;
this.locator = locator;
|
public TransformerException(String message)Create a new TransformerException.
super(message);
this.containedException = null;
this.locator = null;
|
public TransformerException(Throwable e)Create a new TransformerException wrapping an existing exception.
super(e.toString());
this.containedException = e;
this.locator = null;
|
public TransformerException(String message, Throwable e)Wrap an existing exception in a TransformerException.
This is used for throwing processor exceptions before
the processing has started.
super(((message == null) || (message.length() == 0))
? e.toString()
: message);
this.containedException = e;
this.locator = null;
|
public TransformerException(String message, SourceLocator locator)Create a new TransformerException from a message and a Locator.
This constructor is especially useful when an application is
creating its own exception from within a DocumentHandler
callback.
super(message);
this.containedException = null;
this.locator = locator;
|
Methods Summary |
---|
public java.lang.Throwable | getCause()Returns the cause of this throwable or null if the
cause is nonexistent or unknown. (The cause is the throwable that
caused this throwable to get thrown.)
return ((containedException == this)
? null
: containedException);
|
public java.lang.Throwable | getException()This method retrieves an exception that this exception wraps.
return containedException;
|
public java.lang.String | getLocationAsString()Get the location information as a string.
if (null != locator) {
StringBuffer sbuffer = new StringBuffer();
String systemID = locator.getSystemId();
int line = locator.getLineNumber();
int column = locator.getColumnNumber();
if (null != systemID) {
sbuffer.append("; SystemID: ");
sbuffer.append(systemID);
}
if (0 != line) {
sbuffer.append("; Line#: ");
sbuffer.append(line);
}
if (0 != column) {
sbuffer.append("; Column#: ");
sbuffer.append(column);
}
return sbuffer.toString();
} else {
return null;
}
|
public javax.xml.transform.SourceLocator | getLocator()Method getLocator retrieves an instance of a SourceLocator
object that specifies where an error occured.
return locator;
|
public java.lang.String | getMessageAndLocation()Get the error message with location information
appended.
StringBuffer sbuffer = new StringBuffer();
String message = super.getMessage();
if (null != message) {
sbuffer.append(message);
}
if (null != locator) {
String systemID = locator.getSystemId();
int line = locator.getLineNumber();
int column = locator.getColumnNumber();
if (null != systemID) {
sbuffer.append("; SystemID: ");
sbuffer.append(systemID);
}
if (0 != line) {
sbuffer.append("; Line#: ");
sbuffer.append(line);
}
if (0 != column) {
sbuffer.append("; Column#: ");
sbuffer.append(column);
}
}
return sbuffer.toString();
|
public synchronized java.lang.Throwable | initCause(java.lang.Throwable cause)Initializes the cause of this throwable to the specified value.
(The cause is the throwable that caused this throwable to get thrown.)
This method can be called at most once. It is generally called from
within the constructor, or immediately after creating the
throwable. If this throwable was created
with {@link #TransformerException(Throwable)} or
{@link #TransformerException(String,Throwable)}, this method cannot be called
even once.
if (this.containedException != null) {
throw new IllegalStateException("Can't overwrite cause");
}
if (cause == this) {
throw new IllegalArgumentException(
"Self-causation not permitted");
}
this.containedException = cause;
return this;
|
public void | printStackTrace()Print the the trace of methods from where the error
originated. This will trace all nested exception
objects, as well as this object.
printStackTrace(new java.io.PrintWriter(System.err, true));
|
public void | printStackTrace(java.io.PrintStream s)Print the the trace of methods from where the error
originated. This will trace all nested exception
objects, as well as this object.
printStackTrace(new java.io.PrintWriter(s));
|
public void | printStackTrace(java.io.PrintWriter s)Print the the trace of methods from where the error
originated. This will trace all nested exception
objects, as well as this object.
if (s == null) {
s = new java.io.PrintWriter(System.err, true);
}
try {
String locInfo = getLocationAsString();
if (null != locInfo) {
s.println(locInfo);
}
super.printStackTrace(s);
} catch (Throwable e) {}
Throwable exception = getException();
for (int i = 0; (i < 10) && (null != exception); i++) {
s.println("---------");
try {
if (exception instanceof TransformerException) {
String locInfo =
((TransformerException) exception)
.getLocationAsString();
if (null != locInfo) {
s.println(locInfo);
}
}
exception.printStackTrace(s);
} catch (Throwable e) {
s.println("Could not print stack trace...");
}
try {
Method meth =
((Object) exception).getClass().getMethod("getException",
(Class[]) null);
if (null != meth) {
Throwable prev = exception;
exception = (Throwable) meth.invoke(exception, (Object[]) null);
if (prev == exception) {
break;
}
} else {
exception = null;
}
} catch (InvocationTargetException ite) {
exception = null;
} catch (IllegalAccessException iae) {
exception = null;
} catch (NoSuchMethodException nsme) {
exception = null;
}
}
// insure output is written
s.flush();
|
public void | setLocator(javax.xml.transform.SourceLocator location)Method setLocator sets an instance of a SourceLocator
object that specifies where an error occured.
locator = location;
|