cz.cuni.amis.nb.pogamut.base.logging
Class LogRecordsSource<T>

Package class diagram package LogRecordsSource
java.lang.Object
  extended by cz.cuni.amis.nb.pogamut.base.logging.LogRecordsSource<T>
Direct Known Subclasses:
LogProxy

public abstract class LogRecordsSource<T>
extends Object

Source of LogRecords, it caches incomming logrecords and provides observers new collection of records when filter changes. All incoming log records are being cached so when the filter changes the listeners are provided with a refiltered list of past log records.

Author:
student

Nested Class Summary
static interface LogRecordsSource.Filter<T>
          Interface for filtering messages.
 class LogRecordsSource.RegexpFilter<T>
          Filter based on regexp matching the toString() of the object
 
Field Summary
protected  List<LogRecordsSource.Filter<T>> filters
          List of all filters.
protected  Set<LogRecordListener> listeners
           
protected  LimitedQueue<LogRecord> queue
          Queue of all log records.
 
Constructor Summary
LogRecordsSource()
           
 
Method Summary
 void addFilter(LogRecordsSource.Filter filter)
          Change records filter and notify all listeners.
 void addLogRecordListener(LogRecordListener l)
           
protected  void addMessage(T msg)
          Adds new object to queue of objects.
 void clear()
          Clears all log records.
protected  boolean filter(T msg)
           
protected  Collection<LogRecord> getFilteredData()
          Apply filter to all cached records and return this new collection.
protected  T getLogRecParam(LogRecord lr)
           
 org.openide.nodes.Sheet.Set getPropSet()
          Returns property sheet associated with node representing this source.
protected  void notifyLogRecordsListeners(LogRecord r)
          Notify all listeners that new record has arrived.
 void notifySetNewData()
          Send new data to all listeners.
 void notifySetNewData(LogRecordListener listener)
          Send new data to one listeners.
 void removeFilter(LogRecordsSource.Filter filter)
           
 void removeLogRecordListener(LogRecordListener l)
           
 LogRecordsSource.Filter<T> replaceFilter(LogRecordsSource.Filter<T> oldFilter, LogRecordsSource.Filter<T> newFilter)
           
 void setRegexpFilterPatter(Pattern pattern)
          Sets new pattern for regexp filter.
protected abstract  LogRecord toLogRecord(T t)
          Format data element as LogRecord.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filters

protected List<LogRecordsSource.Filter<T>> filters
List of all filters.


listeners

protected Set<LogRecordListener> listeners

queue

protected LimitedQueue<LogRecord> queue
Queue of all log records.

Constructor Detail

LogRecordsSource

public LogRecordsSource()
Method Detail

addLogRecordListener

public void addLogRecordListener(LogRecordListener l)

removeLogRecordListener

public void removeLogRecordListener(LogRecordListener l)

clear

public void clear()
Clears all log records.


notifyLogRecordsListeners

protected void notifyLogRecordsListeners(LogRecord r)
Notify all listeners that new record has arrived.


toLogRecord

protected abstract LogRecord toLogRecord(T t)
Format data element as LogRecord.


notifySetNewData

public void notifySetNewData()
Send new data to all listeners.


notifySetNewData

public void notifySetNewData(LogRecordListener listener)
Send new data to one listeners.


getFilteredData

protected Collection<LogRecord> getFilteredData()
Apply filter to all cached records and return this new collection.


filter

protected boolean filter(T msg)

replaceFilter

public LogRecordsSource.Filter<T> replaceFilter(LogRecordsSource.Filter<T> oldFilter,
                                                LogRecordsSource.Filter<T> newFilter)

setRegexpFilterPatter

public void setRegexpFilterPatter(Pattern pattern)
Sets new pattern for regexp filter.


addFilter

public void addFilter(LogRecordsSource.Filter filter)
Change records filter and notify all listeners.

Parameters:
filter - new filter

removeFilter

public void removeFilter(LogRecordsSource.Filter filter)

getLogRecParam

protected T getLogRecParam(LogRecord lr)
Returns:
parameter of given log record

addMessage

protected void addMessage(T msg)
Adds new object to queue of objects. This means:
  1. Construct LogRecord
  2. Memorize it
  3. Notify listeners


getPropSet

public org.openide.nodes.Sheet.Set getPropSet()
Returns property sheet associated with node representing this source. TODO move it to the node?

Returns:
property sheet associated with node representing this source.


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.