Method from javax.xml.transform.TransformerException Detail: |
public Throwable getCause() {
return ((containedException == this)
? null
: containedException);
}
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.) |
public Throwable getException() {
return containedException;
}
This method retrieves an exception that this exception wraps. |
public String getLocationAsString() {
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;
}
}
Get the location information as a string. |
public SourceLocator getLocator() {
return locator;
}
Method getLocator retrieves an instance of a SourceLocator
object that specifies where an error occurred. |
public String getMessageAndLocation() {
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();
}
Get the error message with location information
appended. |
public synchronized Throwable initCause(Throwable cause) {
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;
}
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 #TransformerException(Throwable) or
#TransformerException(String,Throwable) , this method cannot be called
even once. |
public void printStackTrace() {
printStackTrace(new java.io.PrintWriter(System.err, true));
}
Print the the trace of methods from where the error
originated. This will trace all nested exception
objects, as well as this object. |
public void printStackTrace(PrintStream s) {
printStackTrace(new 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. |
public void printStackTrace(PrintWriter s) {
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) {}
boolean isJdk14OrHigher = false;
try {
Throwable.class.getMethod("getCause",(Class[]) null);
isJdk14OrHigher = true;
} catch (NoSuchMethodException nsme) {
// do nothing
}
// The printStackTrace method of the Throwable class in jdk 1.4
// and higher will include the cause when printing the backtrace.
// The following code is only required when using jdk 1.3 or lower
if (!isJdk14OrHigher) {
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();
}
Print the the trace of methods from where the error
originated. This will trace all nested exception
objects, as well as this object. |
public void setLocator(SourceLocator location) {
locator = location;
}
Method setLocator sets an instance of a SourceLocator
object that specifies where an error occurred. |