org.objectweb.cjdbc.common.exceptions.driver.protocol
Class SerializableException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byorg.objectweb.cjdbc.common.exceptions.driver.protocol.SerializableException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BackendDriverException, ControllerCoreException

public class SerializableException
extends java.lang.Exception

This class implements our own Exception chain, overriding Throwable as much as possible, relying on our own SerializableStackTraceElement instead of java.lang.StackStraceElement.

The main reason for this class is that java.lang.StackStraceElement is not serializable in JDK 1.4 (the constructor is missing, whereas 1.5 has it). Unfortunately we cannot override everything we would like to because StackTraceElement is also final and so SerializableStackTraceElement cannot subtype+override it.

Version:
1.0
Author:
Marc Herbert
See Also:
Serialized Form

Field Summary
private  java.lang.String sqlState
           
private  SerializableStackTraceElement[] stackTrace
           
private  int vendorCode
           
 
Fields inherited from class java.lang.Exception
 
Fields inherited from class java.lang.Throwable
 
Constructor Summary
(package private) SerializableException(CJDBCInputStream in)
          Constructs/reads a new SerializableException chain from the stream
(package private) SerializableException(java.lang.String message, SerializableException cause)
           
(package private) SerializableException(java.lang.Throwable start)
          Converts a chain of Throwables to a chain of SerializableException.
 
Method Summary
(package private)  void convertStackTrace(java.lang.Throwable regularEx)
           
 java.lang.Throwable fillInStackTrace()
          Deprecated.  
 int getErrorCode()
          Returns the vendorCode value.
 SerializableStackTraceElement[] getSerializableStackTrace()
          Returns our private stack trace, the one which is serializable.
 java.lang.String getSQLState()
          Returns the sQLState value.
 java.lang.StackTraceElement[] getStackTrace()
          Deprecated.  
 java.lang.Throwable initCause(java.lang.Throwable cause)
          Override super, adding an extra check because we do not want a mixed chain.
 void printStackTrace()
           
 void printStackTrace(java.io.PrintStream s)
          Prints this throwable and its backtrace to the specified print stream.
 void printStackTrace(java.io.PrintWriter s)
          Prints this throwable and its backtrace to the specified print writer.
 void sendToStream(CJDBCOutputStream out)
          Send the Serializable chain to the given stream.
(package private)  void setErrorCode(int vendorCode)
          Sets the vendorCode value.
 void setSQLState(java.lang.String sQLState)
          Sets the sQLState value.
 void setStackTrace(java.lang.StackTraceElement[] ignored)
          Deprecated.  
private  void throwsIfNotSerializable(java.lang.Throwable cause)
           
 
Methods inherited from class java.lang.Throwable
getCause, getLocalizedMessage, getMessage, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sqlState

private java.lang.String sqlState

vendorCode

private int vendorCode

stackTrace

private SerializableStackTraceElement[] stackTrace
Constructor Detail

SerializableException

SerializableException(java.lang.String message,
                      SerializableException cause)
See Also:
Exception.Exception(java.lang.Throwable)

SerializableException

SerializableException(java.lang.Throwable start)
Converts a chain of Throwables to a chain of SerializableException. The resulting chain has the same length.

Parameters:
start - head of chain to convert

SerializableException

SerializableException(CJDBCInputStream in)
                throws java.io.IOException
Constructs/reads a new SerializableException chain from the stream

Method Detail

convertStackTrace

void convertStackTrace(java.lang.Throwable regularEx)

sendToStream

public void sendToStream(CJDBCOutputStream out)
                  throws java.io.IOException
Send the Serializable chain to the given stream.

Parameters:
out - destination stream
Throws:
java.io.IOException - stream error

printStackTrace

public void printStackTrace()
See Also:
Throwable.printStackTrace()

printStackTrace

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

Parameters:
s - PrintStream to use for output

printStackTrace

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

Parameters:
s - PrintWriter to use for output

fillInStackTrace

public java.lang.Throwable fillInStackTrace()
Deprecated.  

See Also:
Throwable.fillInStackTrace()

getStackTrace

public java.lang.StackTraceElement[] getStackTrace()
Deprecated.  

Please use getSerializedStackTrace() instead. Unfortunately StackTraceElement has no constructor in 1.4 and cannot be overriden (final).

See Also:
Throwable.getStackTrace()

getSerializableStackTrace

public SerializableStackTraceElement[] getSerializableStackTrace()
Returns our private stack trace, the one which is serializable.

Returns:
our private stack trace

setStackTrace

public void setStackTrace(java.lang.StackTraceElement[] ignored)
Deprecated.  

This method is deprecated and erases the regular, non serializable stack trace. Please use setSerializedStackTrace() instead. Unfortunately StackTraceElement has no constructor in 1.4 and cannot be overriden (final).

See Also:
Throwable.setStackTrace(java.lang.StackTraceElement[])

setErrorCode

void setErrorCode(int vendorCode)
Sets the vendorCode value.

Parameters:
vendorCode - The vendorCode to set.

getErrorCode

public int getErrorCode()
Returns the vendorCode value.

Returns:
Returns the vendorCode.

setSQLState

public void setSQLState(java.lang.String sQLState)
Sets the sQLState value.

Parameters:
sQLState - The sQLState to set.

getSQLState

public java.lang.String getSQLState()
Returns the sQLState value.

Returns:
Returns the sQLState.

initCause

public java.lang.Throwable initCause(java.lang.Throwable cause)
Override super, adding an extra check because we do not want a mixed chain.

See Also:
Throwable.initCause(java.lang.Throwable)

throwsIfNotSerializable

private void throwsIfNotSerializable(java.lang.Throwable cause)
                              throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.