de.infinityloop.util
Class UpcastException

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

public class UpcastException
extends java.lang.RuntimeException

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

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

Constructor Summary
UpcastException()
          Constructor
UpcastException(java.lang.Exception e)
          Constructor
UpcastException(LogEvent le)
          Constructor
UpcastException(LogEventCollector coll)
          Constructor
UpcastException(java.lang.String s)
          Constructor
 
Method Summary
 LogEventCollector extractSignificantEntries(int[] types, int[] including, int[] excluding)
          This method extracts all LogEvent objects from this exception that are significant to you.
 void flushToLogger(LogSource lp)
          This flushes all collected events to the specified LogSource, then clears the internal log event list.
 LogEventCollector getEntries()
          get the entries of this exception as a List
 LogEvent 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()
           
 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

UpcastException

public UpcastException(java.lang.String s)
Constructor

Parameters:
s - human readable message

UpcastException

public UpcastException()
Constructor


UpcastException

public UpcastException(java.lang.Exception e)
Constructor

Parameters:
e - the exception to wrap

UpcastException

public UpcastException(LogEventCollector coll)
Constructor

Parameters:
coll - the LogEventCollector whose objects we should use

UpcastException

public UpcastException(LogEvent le)
Constructor

Parameters:
coll - the LogEventCollector whose objects we should use
Method Detail

getEntries

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


size

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

extractSignificantEntries

public LogEventCollector extractSignificantEntries(int[] types,
                                                   int[] including,
                                                   int[] excluding)
This method extracts all LogEvent objects from this exception that are significant to 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 LogEvent objects.

Parameters:
types - a variable length array of integers containing the type of LogEvent objects you are interested in. E.g. passing new int[] { LogEvent.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 LogEventCollector object containing the LogEvent objects left after performing the filtering. If none of the source items match, an empty LogEventCollector is returned (not null!)

getEntryByCode

public LogEvent 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 LogEvent with the specified code or null if not found

getMessage

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

flushToLogger

public void flushToLogger(LogSource lp)
This flushes all collected events to the specified LogSource, then clears the internal log event list.

Parameters:
lp - the LogSource to send the log events to