de.infinityloop.util
Class ILException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by de.infinityloop.util.ILException
All Implemented Interfaces:
java.io.Serializable

public class ILException
extends java.lang.Exception

Special Exception for infinity-loop products. This exception is able to

Version:
1.1
Author:
Christian Roth
See Also:
Serialized Form

Constructor Summary
ILException()
          Constructor
ILException(java.lang.Exception e)
          Constructor
ILException(int code, java.lang.Object[] params)
          Constructor
ILException(int code, java.lang.String msg)
          Constructor
ILException(int code, java.lang.String msg, java.lang.Exception e)
          Constructor
ILException(NotificationCollector coll)
          Constructor
ILException(java.lang.String s)
          Constructor
 
Method Summary
 NotificationCollector extractSignificantEntries(int[] types, int[] including, int[] excluding)
          This method tells whether this exception contains a LogEntry that is significant for you.
 int getCode(int i)
           
 java.lang.Throwable getEmbeddedException(int i)
           
 NotificationCollector getEntries()
          get the entries of this exception as a List
 NotificationCollector getEntriesByType(int type)
          Returns an ArrayList object that holds all those LogEntry objects that are of the specified type.
 LogEntry getEntryByCode(int code)
          Returns the (first) entry with the specified code or null if that message is not contained in this exception.
 java.lang.String getMessage()
           
 java.lang.String getMessage(int i)
           
 java.lang.Object[] getParameters(int i)
          retrieves the parameter objects for the respective error message
 int size()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ILException

public ILException(java.lang.String s)
Constructor

Parameters:
s - human readable message

ILException

public ILException()
Constructor


ILException

public ILException(java.lang.Exception e)
Constructor

Parameters:
e - the exception to wrap

ILException

public ILException(NotificationCollector coll)
Constructor

Parameters:
coll - the notification collector whose objects we should use

ILException

public ILException(int code,
                   java.lang.String msg)
Constructor

Parameters:
code - the error/warning code
msg - the error/message message

ILException

public ILException(int code,
                   java.lang.Object[] params)
Constructor

Parameters:
code - the error/warning code
params - the parameters for formatting the message template

ILException

public ILException(int code,
                   java.lang.String msg,
                   java.lang.Exception e)
Constructor

Parameters:
code - the error/warning code
msg - the error/message message
e - wrapped exception
Method Detail

getEntries

public NotificationCollector getEntries()
get the entries of this exception as a List


size

public int size()
Returns:
the number of entries in this exception

getEmbeddedException

public java.lang.Throwable getEmbeddedException(int i)
                                         throws java.lang.ArrayIndexOutOfBoundsException
Parameters:
i - index in list of entries
Returns:
the embedded exception at index i or null if none was specified
Throws:
java.lang.ArrayIndexOutOfBoundsException - when the index is out of bounds

getParameters

public java.lang.Object[] getParameters(int i)
                                 throws java.lang.ArrayIndexOutOfBoundsException
retrieves the parameter objects for the respective error message

Parameters:
i - index in list of entries
Returns:
the parameter Object[] array or null if none was specified
Throws:
java.lang.ArrayIndexOutOfBoundsException - when the index is out of bounds

getCode

public int getCode(int i)
            throws java.lang.ArrayIndexOutOfBoundsException
Parameters:
i - index in list of entries
Returns:
the code at index i
Throws:
java.lang.ArrayIndexOutOfBoundsException - when the index is out of bounds

getMessage

public java.lang.String getMessage(int i)
                            throws java.lang.ArrayIndexOutOfBoundsException
Parameters:
i - index in list of entries
Returns:
the message at index i
Throws:
java.lang.ArrayIndexOutOfBoundsException - when the index is out of bounds

getEntriesByType

public NotificationCollector getEntriesByType(int type)
Returns an ArrayList object that holds all those LogEntry objects that are of the specified type.

Parameters:
type - the type of the entries to retrieve, one of:
  • NotificationCollector.DEBUG
  • NotificationCollector.INFO
  • NotificationCollector.WARN
  • NotificationCollector.ERROR
  • NotificationCollector.FATAL
Returns:
a NotificationCollector containing all LogEntry()s matching the specified type

extractSignificantEntries

public NotificationCollector extractSignificantEntries(int[] types,
                                                       int[] including,
                                                       int[] excluding)
This method tells whether this exception contains a LogEntry that is significant for you. What is significant can be specified using three parameters. The processing model is as follows:
  1. If types is null, all entries are examined. Otherwise, only those that match any of the contained types are observed.
  2. From the set of remaining entries after step 1, only those are kept that are contained in including. If including is null, all entries pass this step.
  3. From the set of remaining entries after step 2, only those are kept that are not in excluding. If excluding is null, all entries pass this step.
  4. All entries left after performing step 3 are returned in form of an ArrayList containing exactly those remaining LogEntry objects.

Parameters:
types - a variable length array of integers containing the type of LogEntry()s you are interested in. E.g. passing new int[] { NotificationCollector.ERROR } will only report entries of type ERROR. If you pass null, all entries are respected.
including - Again in form of a variable size integer array, you can specify which error codes are interesting for you. If you pass null, all error codes are observed.
excluding - Same as for including, but lists the error codes you are not interested in.
Returns:
a NotificationCollector object containing the LogEntry()s left after performing the filtering. If none of the source items match, an empty NotificationCollector is returned (not null!)

getMessage

public java.lang.String getMessage()
Overrides:
getMessage in class java.lang.Throwable
Returns:
the combined, human-readable message of the whole Exception

getEntryByCode

public LogEntry getEntryByCode(int code)
Returns the (first) entry with the specified code or null if that message is not contained in this exception.

Parameters:
code - the code to look for
Returns:
the first LogEntry with the specified code or null if not found