|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Throwable
java.lang.Exception
java.io.IOException
de.schlichtherle.io.ChainableIOException
public class ChainableIOException
Represents a chain of IOException
s.
This class supports chaining exceptions for reasons other than causes
(which is a functionality already provided by J2SE 1.4 and later).
A ChainableIOException
can be used to implement an algorithm
which must be able to continue with some work although one or more
IOException
s have occured.
For example, when looping through a list of files, an algorithm might
encounter an IOException
when processing a file element in the list.
However, it may still be required to process the remaining files in the list
before actually throwing the corresponding IOException
.
Hence, whenever this algorithm encounters an IOException
,
it would catch the IOException
, create a
ChainableIOException
for it and continue processing the
remainder of the list.
Finally, at the end of the algorithm, if any IOException
s
have occured, the ChainableIOException
chain would get sorted
according to priority (see getPriority()
and
sortPriority()
) and finally thrown.
This would allow a client application to filter the exceptions by priority
with a simple try-catch statement, ensuring that no other exception of
higher priority is in the catched exception chain.
Note: This is not related to the cause concept of exceptions in J2SE 1.4 and higher. Exceptions chained by this class are not causes of each other, but have just been merely collected over time and then thrown as one exception (list).
ArchiveControllerException
).File.update()
,
File.umount()
,
Serialized FormConstructor Summary | |
---|---|
ChainableIOException(ChainableIOException priorException)
Constructs a new exception with the specified prior exception. |
|
ChainableIOException(ChainableIOException priorException,
IOException cause)
Constructs a new exception with the specified prior exception and the cause. |
|
ChainableIOException(ChainableIOException priorException,
String message)
Constructs a new exception with the specified prior exception and a message. |
|
ChainableIOException(ChainableIOException priorException,
String message,
IOException cause)
Constructs a new exception with the specified prior exception, a message and a cause. |
Method Summary | |
---|---|
Object |
clone()
Returns a shallow clone of this exception. |
int |
getAppearance()
|
static int |
getMaxPrintExceptions()
|
ChainableIOException |
getPrior()
|
int |
getPriority()
Returns the priority for this class of exception. |
Throwable |
initCause(IOException cause)
|
Throwable |
initCause(Throwable cause)
Calls initCause((IOException) cause) . |
void |
printStackTrace(PrintStream s)
Prints up to getMaxPrintExceptions() exceptions in this
chain to the provided PrintStream . |
void |
printStackTrace(PrintStream s,
int maxExceptions)
Prints up to maxExceptions() exceptions in this
chain to the provided PrintStream . |
void |
printStackTrace(PrintWriter s)
Prints up to getMaxPrintExceptions() exceptions in this
chain to the provided PrintStream . |
void |
printStackTrace(PrintWriter s,
int maxExceptions)
Prints up to maxExceptions() exceptions in this
chain to the provided PrintStream . |
static void |
setMaxPrintExceptions(int maxPrintExcepions)
|
ChainableIOException |
sortAppearance()
Sorts the elements of this exception chain in descending order of their appearance. |
ChainableIOException |
sortPriority()
Sorts the elements of this exception chain in descending order of their priority. |
Methods inherited from class java.lang.Throwable |
---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, printStackTrace, setStackTrace, toString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ChainableIOException(ChainableIOException priorException)
priorException
- An exception that happened before and that was
caught - may be null.ChainableIOException
public ChainableIOException(ChainableIOException priorException, String message)
priorException
- An exception that happened before and that was
caught - may be null.message
- The message for this exception.ChainableIOException
public ChainableIOException(ChainableIOException priorException, IOException cause)
priorException
- An exception that happened before and that was
caught - may be null.cause
- The cause (which is saved for later retrieval by the
Throwable.getCause()
method). (A null value is
permitted, and indicates that the cause is nonexistent or
unknown.).ChainableIOException
public ChainableIOException(ChainableIOException priorException, String message, IOException cause)
priorException
- An exception that happened before and that was
caught - may be null.message
- The message for this exception.cause
- The cause (which is saved for later retrieval by the
Throwable.getCause()
method). (A null value is
permitted, and indicates that the cause is nonexistent or
unknown.).ChainableIOException
Method Detail |
---|
public Object clone()
clone
in class Object
public int getPriority()
public final int getAppearance()
public ChainableIOException getPrior()
null
if no prior exception exists.public ChainableIOException sortPriority()
public ChainableIOException sortAppearance()
public final Throwable initCause(Throwable cause)
initCause((IOException) cause)
.
initCause
in class Throwable
ClassCastException
- If cause
is not an instance
of IOException
.public Throwable initCause(IOException cause)
public void printStackTrace(PrintStream s)
getMaxPrintExceptions()
exceptions in this
chain to the provided PrintStream
.
Exceptions are printed in ascending order of this chain. If this chain has not been sorted, this results in the exceptions being printed in order of their appearance.
If more exceptions are in this chain than are allowed to be printed, then the printed message starts with a line indicating the number of exceptions which have been omitted from the beginning of this chain. Thus, this exception is always printed as the last exception in the list.
printStackTrace
in class Throwable
public void printStackTrace(PrintStream s, int maxExceptions)
maxExceptions()
exceptions in this
chain to the provided PrintStream
.
Exceptions are printed in ascending order of this chain. If this chain has not been sorted, this results in the exceptions being printed in order of their appearance.
If more exceptions are in this chain than are allowed to be printed, then the printed message starts with a line indicating the number of exceptions which have been omitted from the beginning of this chain. Thus, this exception is always printed as the last exception in the list.
public void printStackTrace(PrintWriter s)
getMaxPrintExceptions()
exceptions in this
chain to the provided PrintStream
.
Exceptions are printed in ascending order of this chain. If this chain has not been sorted, this results in the exceptions being printed in order of their appearance.
If more exceptions are in this chain than are allowed to be printed, then the printed message starts with a line indicating the number of exceptions which have been omitted from the beginning of this chain. Thus, this exception is always printed as the last exception in the list.
printStackTrace
in class Throwable
public void printStackTrace(PrintWriter s, int maxExceptions)
maxExceptions()
exceptions in this
chain to the provided PrintStream
.
Exceptions are printed in ascending order of this chain. If this chain has not been sorted, this results in the exceptions being printed in order of their appearance.
If more exceptions are in this chain than are allowed to be printed, then the printed message starts with a line indicating the number of exceptions which have been omitted from the beginning of this chain. Thus, this exception is always printed as the last exception in the list.
public static int getMaxPrintExceptions()
printStackTrace(PrintStream)
,
printStackTrace(PrintWriter)
public static void setMaxPrintExceptions(int maxPrintExcepions)
printStackTrace(PrintStream)
,
printStackTrace(PrintWriter)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |