com.levigo.util.base
Class MimicryThrowable
java.lang.Object
java.lang.Throwable
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
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.*
).
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 mimicmessage
- The detail message to mimiclocalizedMessage
- The localized description to mimic or null
stacktrace
- the stack trace elements to mimiccause
- The cause or null
. This element will be mimiced, too.
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()