public class LogEventCollector extends java.util.ArrayList<LogEvent> implements LogListener, LogBroadcaster
Constructor and Description |
---|
LogEventCollector(java.lang.String name,
LogBroadcaster lb,
de.infinityloop.util.log.filter.LogEventFilter f) |
LogEventCollector(java.lang.String name,
de.infinityloop.util.log.filter.LogEventFilter f)
Constructors
|
Modifier and Type | Method and Description |
---|---|
void |
addedTo(LogBroadcaster le)
Called when this object is successfully attached to a LogPublisher.
|
void |
addLogListener(LogListener ls)
Call to attach a Listener for log events received by the LogBroadcaster.
|
LogEvent |
broadcast(LogEvent le)
Broadcasts the passed log event to all of our listeners
|
void |
clear()
Clears all collected notifications.
|
int |
countType(int type)
Counts the number of messages in this collection of the respective type
|
boolean |
equals(java.lang.Object o)
We MUST override equals() since the behaviour of the inherited method of ArrayList is not what we
require.
|
LogEventCollector |
extractSignificantEntries(int[] types,
int[] including,
int[] excluding)
This method tells whether this exception contains a LogEvent that is significant for you.
|
LogEventCollector |
extractSignificantEntries(de.infinityloop.util.log.filter.LogEventFilter f)
Return the entries that are matched by the specified LogEventFilter.
|
java.lang.String |
getAsString()
human readable representation of the collected notifications
|
int |
getCode(int i) |
java.lang.Throwable |
getEmbeddedException(int i) |
LogEventCollector |
getEntriesByType(int type)
Returns an ArrayList object that holds all those LogEntry objects that are of the specified type.
|
LogEvent |
getEntryByCode(int code)
Returns the (first) entry with the specified code or null if that message is not contained
in this exception.
|
de.infinityloop.util.log.filter.LogEventFilter |
getFilter()
Returns the incoming filter instance active for this LogEventCollector.
|
LogEvent |
getLogEvent(int i)
Retrieve the i
|
java.lang.String |
getMessage(int i) |
java.util.ArrayList |
getNotifications()
Returns the collected notifications
|
java.lang.Object[] |
getParameters(int i)
retrieves the parameter objects for the respective error message
|
int |
hashCode()
We MUST override the default hash function as that changes with changing the list entries, which we do not want!
|
boolean |
receiveLogEvent(LogEvent le)
Receive a LogEvent from a publisher we are registered to.
|
void |
removeAllSubscribers()
This method unregisters all LogSubscriber from this LogPublisher.
|
void |
removedFrom(LogBroadcaster le)
Called when we get removed from a LogPublisher.
|
void |
removeLogListener(LogListener ls)
Call to detach a Listener for log events received by the LogBroadcaster.
|
void |
setFilter(de.infinityloop.util.log.filter.LogEventFilter f)
Sets a new LogEventFilter instance for this collector.
|
void |
setLevel(int filterLevel) |
void |
setName(java.lang.String name)
Sets a new name for the delegates
|
java.lang.String |
toString() |
void |
unregisterFromAll()
This method unregisters this LogSubscriber from all LogPublishers it is registered with.
|
add, add, addAll, addAll, clone, contains, ensureCapacity, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeRange, retainAll, set, size, subList, toArray, toArray, trimToSize
public LogEventCollector(java.lang.String name, de.infinityloop.util.log.filter.LogEventFilter f)
name
- TODOpublic LogEventCollector(java.lang.String name, LogBroadcaster lb, de.infinityloop.util.log.filter.LogEventFilter f)
public de.infinityloop.util.log.filter.LogEventFilter getFilter()
public void setFilter(de.infinityloop.util.log.filter.LogEventFilter f)
public void setName(java.lang.String name)
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<LogEvent>
equals
in interface java.util.List<LogEvent>
equals
in class java.util.AbstractList<LogEvent>
o
- object to compare toAbstractList.equals(java.lang.Object)
public int hashCode()
public boolean receiveLogEvent(LogEvent le)
receiveLogEvent
in interface LogListener
le
- true
if we handled the eventLogListener.receiveLogEvent(de.infinityloop.util.log.LogEvent)
public java.util.ArrayList getNotifications()
public void clear()
public int countType(int type)
type
- one of the typespublic LogEvent getLogEvent(int i) throws java.lang.ArrayIndexOutOfBoundsException
i
- java.lang.ArrayIndexOutOfBoundsException
public java.lang.String getAsString()
public void addedTo(LogBroadcaster le)
addedTo
in interface LogListener
le
- LogListener.addedTo(de.infinityloop.util.log.LogBroadcaster)
public void removedFrom(LogBroadcaster le)
removedFrom
in interface LogListener
le
- LogListener.removedFrom(de.infinityloop.util.log.LogBroadcaster)
public void unregisterFromAll()
public LogEventCollector extractSignificantEntries(int[] types, int[] including, int[] excluding)
null
, all entries are examined. Otherwise, only those that match any of the
contained types are observed.
including
. If
including
is null
, all entries pass this step.
excluding
. If
excluding
is null
, all entries pass this step.
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.null
!)public LogEventCollector extractSignificantEntries(de.infinityloop.util.log.filter.LogEventFilter f)
f
- the filterLogEventFilter
instancepublic LogEvent getEntryByCode(int code)
code
- the code to look forpublic LogEventCollector getEntriesByType(int type)
type
- the type of the entries to retrievepublic java.lang.Throwable getEmbeddedException(int i) throws java.lang.ArrayIndexOutOfBoundsException
i
- index in list of entriesjava.lang.ArrayIndexOutOfBoundsException
- when the index is out of boundspublic java.lang.Object[] getParameters(int i) throws java.lang.ArrayIndexOutOfBoundsException
i
- index in list of entriesnull
if none was specifiedjava.lang.ArrayIndexOutOfBoundsException
- when the index is out of boundspublic int getCode(int i) throws java.lang.ArrayIndexOutOfBoundsException
i
- index in list of entriesjava.lang.ArrayIndexOutOfBoundsException
- when the index is out of boundspublic java.lang.String getMessage(int i) throws java.lang.ArrayIndexOutOfBoundsException
i
- index in list of entriesjava.lang.ArrayIndexOutOfBoundsException
- when the index is out of boundspublic final void setLevel(int filterLevel)
filterLevel
- The filterLevel to set.public void addLogListener(LogListener ls)
LogBroadcaster
addLogListener
in interface LogBroadcaster
ls
- LogBroadcaster.addLogListener(de.infinityloop.util.log.LogListener)
public LogEvent broadcast(LogEvent le)
broadcast
in interface LogBroadcaster
le
- LogBroadcaster.broadcast(de.infinityloop.util.log.LogEvent)
public void removeLogListener(LogListener ls)
LogBroadcaster
removeLogListener
in interface LogBroadcaster
ls
- LogBroadcaster.removeLogListener(de.infinityloop.util.log.LogListener)
public void removeAllSubscribers()
public java.lang.String toString()
toString
in class java.util.AbstractCollection<LogEvent>
AbstractCollection.toString()