com.softwareag.tamino.db.api.common
Class TException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.softwareag.tamino.db.api.common.TException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
TAccessFailureException, TAccessorException, TConnectionException, TInvocationException, TObjectModelException, TResponseBuildException, TStreamInterpretException, TStreamReadException, TStreamWriteException

public class TException
extends java.lang.Exception

The class TException and its subclasses extend java.lang.Exception. They indicate conditions that a reasonable application might want to catch. TException is the base exception for the Tamino API. It is capable of containing a chained (nested) exception.
In most of the cases a call of the method TException.getRootCause() retrieves the originating exception, e.g. java.io.IOException, TAccessFailureException.
Additionally it possible to dump the whole TException as xml string with TException.toXMLString().

Version:
$Revision: 1.37 $
Author:
Marcus Schreyer
See Also:
Serialized Form

Constructor Summary
TException(java.util.Locale locale)
          Initializes a TException instance without a specific detail message.
TException(java.lang.String message, java.util.Locale locale)
          Initializes a TException instance with a message and an internal nested exception.
TException(java.lang.String message, java.lang.Throwable nestedException, java.util.Locale locale)
          Initializes a TException instance with a message and an internal nested exception.
TException(java.lang.Throwable nestedException, java.util.Locale locale)
          Initializes a TException instance with a nested exception.
TException(TResourceId resourceId, java.util.Locale locale)
          Initializes a TException instance with a resource message.
TException(TResourceId resourceId, java.lang.Throwable nestedException, java.util.Locale locale)
          Initializes a TException instance with a resource message and an internal nested exception.
 
Method Summary
 TAccessFailureException getAccessFailureException()
          Gets the TAccessFailureException nested within this TException.
protected  org.w3c.dom.Element getAdditionalXMLMessageContent(org.w3c.dom.Document document)
          Gets an additional message content part.
 java.lang.Throwable getCause()
          Gets the internal nested exception, null if none is given.
 java.lang.Throwable getDeepestException()
          Deprecated. please use getRootCause() instead.
 TException getDeepestTException()
          Gets the deepest TException instance in the nested exceptions.
 com.softwareag.common.resourceutilities.message.Message getExceptionMessage()
          Gets the resource message instance of this exception
 java.util.Locale getLocale()
          Gets the locale.
 java.lang.String getMessageCode()
          Gets the message code.
 java.lang.String getMessageContent()
          Gets the message content.
 java.lang.Throwable getNestedException()
          Deprecated. please use getCause() instead.
 com.softwareag.common.resourceutilities.message.ResourceMessage getResourceMessage()
          Deprecated. please use getExceptionMessage() instead.
 java.lang.Throwable getRootCause()
          Gets deepest nested exception in all the nested exceptions.
 TException getRootTCause()
          Gets the deepest TException instance in the chained exceptions.
 java.lang.String getXMLMessage()
          Gets the complete exception message as XML string, like
It will be of the following form.
protected  org.w3c.dom.Element getXMLMessage(org.w3c.dom.Document document)
          Gets the complete exception message as an DOM-Element.
 boolean hasAccessFailureException()
          Indicates if exception contains a TAccessFailureException nested within this TException.
 boolean hasCause()
          Indicates if exception contains a cause (chained exception).
 boolean hasNestedException()
          Deprecated. please use hasCause().
 void printStackTrace()
          Prints the stacktrace.
 void printStackTrace(java.io.PrintStream stream)
          Prints this Exception and its backtrace to the specified print stream.
 void printStackTrace(java.io.PrintWriter writer)
          Prints this Exception and its backtrace to the specified print writer.
 void setLocale(java.util.Locale locale)
          Sets the locale.
 java.lang.String toString()
          Returns the tring representation of the TException instance.
 java.lang.String toXMLString()
          Returns the xml string representation of the TException instance.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, initCause, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TException

public TException(java.util.Locale locale)
Initializes a TException instance without a specific detail message.

Parameters:
locale - the locale

TException

public TException(java.lang.String message,
                  java.util.Locale locale)
Initializes a TException instance with a message and an internal nested exception.

Parameters:
message - is handed further to the base class.
locale - the locale

TException

public TException(java.lang.String message,
                  java.lang.Throwable nestedException,
                  java.util.Locale locale)
Initializes a TException instance with a message and an internal nested exception.

Parameters:
message - is handed further to the base class.
nestedException - can be nested into a TException if it is given.
locale - the locale

TException

public TException(TResourceId resourceId,
                  java.util.Locale locale)
Initializes a TException instance with a resource message.

Parameters:
resourceId - containing the message of this exception
locale - the locale
See Also:
TResourceId

TException

public TException(TResourceId resourceId,
                  java.lang.Throwable nestedException,
                  java.util.Locale locale)
Initializes a TException instance with a resource message and an internal nested exception.

Parameters:
resourceId - containing the message of this exception
nestedException - can be nested into a TException if it is given
locale - the locale
See Also:
TResourceId

TException

public TException(java.lang.Throwable nestedException,
                  java.util.Locale locale)
Initializes a TException instance with a nested exception.

Parameters:
nestedException - can be nested into a TException if it is given
locale - the locale
Method Detail

getMessageCode

public java.lang.String getMessageCode()
Gets the message code.

Returns:
the message code, if existent, otherwise "?".

getMessageContent

public java.lang.String getMessageContent()
Gets the message content.

Returns:
the message content, if existent, otherwise "?".

getXMLMessage

public java.lang.String getXMLMessage()
Gets the complete exception message as XML string, like
It will be of the following form.
 <exception name="TException">
      <message>
               <!-- message specific content -->
      </message>
      <failureMessage name="TAccessFailureMessage">
               <!-- failure message specific content -->
      </failureMessage>
      <exception name="..">
               <!-- nested exeption (recursivly) -->
      <exception>
 </exception>
 

Returns:
the exception message.

getXMLMessage

protected org.w3c.dom.Element getXMLMessage(org.w3c.dom.Document document)
Gets the complete exception message as an DOM-Element.

Parameters:
document - the document to use for building elements for.
Returns:
the exception element with form described in getXMLMessage().

getAdditionalXMLMessageContent

protected org.w3c.dom.Element getAdditionalXMLMessageContent(org.w3c.dom.Document document)
Gets an additional message content part. Derived classes may put in some additional information. The output should contain a element named "additional" containing the additional elements.

Returns:
the additional element.

getResourceMessage

public com.softwareag.common.resourceutilities.message.ResourceMessage getResourceMessage()
Deprecated. please use getExceptionMessage() instead.

Gets the resource message of this exception

Returns:
the resource message

getExceptionMessage

public com.softwareag.common.resourceutilities.message.Message getExceptionMessage()
Gets the resource message instance of this exception

Returns:
the message instance

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale.


getLocale

public java.util.Locale getLocale()
Gets the locale.

Returns:
the locale.

hasNestedException

public boolean hasNestedException()
Deprecated. please use hasCause().

Indicates if exception contains a nested exception.

Returns:
true if the exception contains a nested exception, false otherwise

hasCause

public boolean hasCause()
Indicates if exception contains a cause (chained exception).

Returns:
true if the exception contains a nested exception, false otherwise

hasAccessFailureException

public boolean hasAccessFailureException()
Indicates if exception contains a TAccessFailureException nested within this TException.

Returns:
true if it does, false otherwise.

getNestedException

public java.lang.Throwable getNestedException()
Deprecated. please use getCause() instead.

Gets the internal nested exception, null if none is given.

Returns:
the nested exception if it exists, null otherwise.

getCause

public java.lang.Throwable getCause()
Gets the internal nested exception, null if none is given.

Overrides:
getCause in class java.lang.Throwable
Returns:
the nested exception if it exists, null otherwise.

getDeepestException

public java.lang.Throwable getDeepestException()
Deprecated. please use getRootCause() instead.

Gets deepest nested exception in all the nested exceptions.

Returns:
the deepest nested exception if it exists, null otherwise.

getRootCause

public java.lang.Throwable getRootCause()
Gets deepest nested exception in all the nested exceptions.

Returns:
the deepest nested exception if it exists, null otherwise.

getDeepestTException

public TException getDeepestTException()
Gets the deepest TException instance in the nested exceptions. If no nested TException instances exist, this method returns itself.

Returns:
the deepest nested TException instance.

getRootTCause

public TException getRootTCause()
Gets the deepest TException instance in the chained exceptions. If no chained TException instances exist, this method returns itself.

Returns:
the deepest chained TException instance.

getAccessFailureException

public TAccessFailureException getAccessFailureException()
Gets the TAccessFailureException nested within this TException. If not existant it returns null.

Returns:
the nested TAccessorFailureException.

printStackTrace

public void printStackTrace()
Prints the stacktrace.

Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

public void printStackTrace(java.io.PrintStream stream)
Prints this Exception and its backtrace to the specified print stream.

Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
stream - - PrintStream to use for output

printStackTrace

public void printStackTrace(java.io.PrintWriter writer)
Prints this Exception and its backtrace to the specified print writer.

Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
writer - - PrintWriter to use for output

toXMLString

public java.lang.String toXMLString()
Returns the xml string representation of the TException instance.

Returns:
a xml string representation of the TException instance.

toString

public java.lang.String toString()
Returns the tring representation of the TException instance.

Overrides:
toString in class java.lang.Throwable
Returns:
a string representation of the TException instance.


Copyright (c) 2013 Software AG. All Rights Reserved.