com.levigo.util.base
Class MimicryThrowable

java.lang.Object
  extended by java.lang.Throwable
      extended by com.levigo.util.base.MimicryThrowable
All Implemented Interfaces:
Serializable

public class MimicryThrowable
extends Throwable

A Throwable used to mimic arbitrary Throwables for serialization purposes. An RMI client may not have all Throwable implementations used by the server on its class path. In order to allow a rich communication of, for instance, an exception cause chain, the MimicryThrowable assumes the role of the mimic'ed Throwable.

Mimic'ed Throwables exhibit the mimic'ed Throwable's behavior in all behavior of a generic Throwable. Examples are toString(), Throwable.getCause(), Throwable.getStackTrace() Throwable.printStackTrace() etc. Behavior specific to a particular subclass of Throwable, however, is not mimic'ed. Also, please be aware that all operations involving instanceof expressions or Object.getClass() will let the real nature of the MimicryThrowable show through.

See Also:
Serialized Form

Field Summary
static String[] UNMIMICED_PACKAGE_PREFIXES
          A list of package prefixes for which no mimicry is performed through mimic(Throwable) (all from java.*).
 
Constructor Summary
MimicryThrowable(String className, String message, String localizedMessage, StackTraceElement[] stacktrace, Throwable cause)
          Creates a new MimicryThrowable from scratch
MimicryThrowable(Throwable t)
          Mimics the given Throwable.
 
Method Summary
 Throwable fillInStackTrace()
           
 String getClassName()
           
 String getLocalizedMessage()
           
static Throwable mimic(Throwable t)
          Return the mimic'ed Throwable unless mimicry isn't required for it.
 String toString()
           
 
Methods inherited from class java.lang.Throwable
getCause, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNMIMICED_PACKAGE_PREFIXES

public static final String[] UNMIMICED_PACKAGE_PREFIXES
A list of package prefixes for which no mimicry is performed through mimic(Throwable) (all from java.*).

Constructor Detail

MimicryThrowable

public MimicryThrowable(Throwable t)
Mimics the given Throwable.

Parameters:
t - The Throwable to mimic.

MimicryThrowable

public MimicryThrowable(String className,
                        String message,
                        String localizedMessage,
                        StackTraceElement[] stacktrace,
                        Throwable cause)
Creates a new MimicryThrowable from scratch

Parameters:
className - The class name to mimic
message - The detail message to mimic
localizedMessage - The localized description to mimic or null
stacktrace - the stack trace elements to mimic
cause - The cause or null. This element will be mimiced, too.
Method Detail

mimic

public static Throwable mimic(Throwable t)
Return the mimic'ed Throwable unless mimicry isn't required for it.

Parameters:
t - The Throwable to mimicry
Returns:
A mimic'ed Throwable (if necessary)

fillInStackTrace

public Throwable fillInStackTrace()
Overrides:
fillInStackTrace in class Throwable

getLocalizedMessage

public String getLocalizedMessage()
Overrides:
getLocalizedMessage in class Throwable

toString

public String toString()
Overrides:
toString in class Throwable

getClassName

public String getClassName()


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.