|
TrueZIP Kernel 7.0-rc2 | ||||||||
| 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.truezip.io.SequentialIOException
public class SequentialIOException
Represents a chain of subsequently occured IOExceptions which have
not caused each other.
This class supports chaining I/O exceptions for reasons other than causes (which is a functionality already provided by J2SE 1.4 and later). A chainable I/O exception can be used to implement an algorithm which must be able to continue with some work although one or more I/O exceptions have occured.
For example, when looping through a list of files, an algorithm might
encounter an I/O exception 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 I/O exception.
Hence, whenever this algorithm encounters an I/O exception, it would catch
the I/O exception, create a chainable I/O exception for it and continue
processing the remainder of the list.
Finally, at the end of the algorithm, if any I/O exceptions
have occured, the chainable I/O exception would get sorted according to
priority (see getPriority() and sortPriority()) and
finally thrown.
This would allow a client application to filter the I/O exceptions by
priority with a simple try-catch statement, ensuring that no other
exception of higher priority is in the catched exception chain.
This class is thread-safe.
| Field Summary | |
|---|---|
private int |
index
|
(package private) static Comparator<SequentialIOException> |
INDEX_COMP
Compares two chainable I/O exceptions in descending order of their appearance. |
(package private) int |
maxIndex
|
private static int |
maxPrintExceptions
|
private SequentialIOException |
predecessor
The tail of this exception chain. |
private int |
priority
|
(package private) static Comparator<SequentialIOException> |
PRIORITY_COMP
Compares two chainable I/O exceptions in descending order of their priority. |
private static long |
serialVersionUID
|
| Constructor Summary | |
|---|---|
SequentialIOException()
|
|
SequentialIOException(int priority)
|
|
SequentialIOException(String message)
|
|
SequentialIOException(String message,
int priority)
|
|
SequentialIOException(String message,
Throwable cause)
|
|
SequentialIOException(String message,
Throwable cause,
int priority)
Constructs a new chainable I/O exception with the given message, cause and priority. |
|
SequentialIOException(Throwable cause)
|
|
SequentialIOException(Throwable cause,
int priority)
|
|
| Method Summary | |
|---|---|
SequentialIOException |
clone()
Returns a shallow clone of this exception. |
static int |
getMaxPrintExceptions()
|
private int |
getNumExceptions()
|
SequentialIOException |
getPredecessor()
Returns the exception chain represented by the predecessing exception, or null if no predecessing exception exists or this property
hasn't been
initialized yet. |
int |
getPriority()
Returns the priority of this exception. |
SequentialIOException |
initCause(Throwable cause)
|
SequentialIOException |
initPredecessor(SequentialIOException predecessor)
Initializes the predecessor of this chainable exception to the given object. |
private SequentialIOException |
insert(SequentialIOException element,
Comparator<SequentialIOException> cmp)
|
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)
|
private void |
setPredecessor(SequentialIOException predecessor)
|
private SequentialIOException |
sort(Comparator<SequentialIOException> cmp)
|
SequentialIOException |
sortAppearance()
Sorts the elements of this exception chain in descending order of their appearance. |
SequentialIOException |
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 |
| Field Detail |
|---|
private static final long serialVersionUID
private static int maxPrintExceptions
static final Comparator<SequentialIOException> PRIORITY_COMP
static final Comparator<SequentialIOException> INDEX_COMP
private SequentialIOException predecessor
this if the predecessor hasn't been
initPredecessor(SequentialIOException) initialized yet or
null if there are no more exceptions in this chain.
private final int priority
private int index
int maxIndex
| Constructor Detail |
|---|
public SequentialIOException()
public SequentialIOException(String message)
public SequentialIOException(Throwable cause)
public SequentialIOException(String message,
Throwable cause)
public SequentialIOException(int priority)
public SequentialIOException(String message,
int priority)
public SequentialIOException(Throwable cause,
int priority)
public SequentialIOException(String message,
Throwable cause,
int priority)
message, cause and priority.
The predecessor of this exception remains unknown until initiliazed
by calling the method initPredecessor(SequentialIOException).
message - The message for this exception.cause - The cause exception.
A null value is permitted, and indicates that the cause
for this exception is nonexistent.priority - The priority of this exception to be used for
priority sorting.| Method Detail |
|---|
public SequentialIOException clone()
clone in class Objectpublic SequentialIOException initCause(Throwable cause)
initCause in class Throwablepublic final SequentialIOException initPredecessor(SequentialIOException predecessor)
predecessor - An exception that happened before and is
not the cause for this exception!
Must be null to indicate that a predecessor does not
exist.
IllegalStateException - If the predecessor has already been set.
IllegalArgumentException - If the given predecessor is
this instance or has not been initialized with a predecessor
itself.private void setPredecessor(SequentialIOException predecessor)
public final SequentialIOException getPredecessor()
null if no predecessing exception exists or this property
hasn't been
initialized yet.
public final int getPriority()
public SequentialIOException sortPriority()
public SequentialIOException sortAppearance()
private SequentialIOException sort(Comparator<SequentialIOException> cmp)
private SequentialIOException insert(SequentialIOException element,
Comparator<SequentialIOException> cmp)
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.
private int getNumExceptions()
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)
|
TrueZIP Kernel 7.0-rc2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||