Package org.apache.log4j.chainsaw
Class ChainsawCyclicBufferTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.apache.log4j.chainsaw.ChainsawCyclicBufferTableModel
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.io.Serializable
,java.util.EventListener
,javax.swing.table.TableModel
,EventContainer
,LoggerNameModel
,SortTableModel
class ChainsawCyclicBufferTableModel extends javax.swing.table.AbstractTableModel implements EventContainer, java.beans.PropertyChangeListener
A CyclicBuffer implementation of the EventContainer.NOTE: This implementation prevents duplicate rows from being added to the model.
Ignoring duplicates was added to support receivers which may attempt to deliver the same event more than once but can be safely ignored (for example, the database receiver when set to retrieve in a loop).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ChainsawCyclicBufferTableModel.ModelChanger
-
Field Summary
Fields Modifier and Type Field Description private RuleColorizer
colorizer
private java.util.List<java.lang.String>
columnNames
private boolean
currentSortAscending
private int
currentSortColumn
private boolean
cyclic
private int
cyclicBufferSize
private static int
DEFAULT_CAPACITY
private javax.swing.event.EventListenerList
eventListenerList
(package private) java.util.List
filteredList
private org.apache.log4j.Logger
logger
private LoggerNameModel
loggerNameModelDelegate
private java.lang.Object
mutex
private java.beans.PropertyChangeSupport
propertySupport
private boolean
reachedCapacity
private org.apache.log4j.rule.Rule
ruleMediator
private boolean
sortEnabled
private java.lang.String
tableModelName
(package private) java.util.List
unfilteredList
private java.util.Set
uniquePropertyKeys
(package private) int
uniqueRow
-
Constructor Summary
Constructors Constructor Description ChainsawCyclicBufferTableModel(int cyclicBufferSize, RuleColorizer colorizer, java.lang.String tableModelName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventCountListener(EventCountListener listener)
Adds an EventCountListener, to be notified when the # of events changesboolean
addLoggerName(java.lang.String loggerName)
Attempts to add the loggerName to the model, and returns true if it does, i.e that the loggerName is new, otherwise it is ignored.void
addLoggerNameListener(LoggerNameListener l)
void
addNewKeyListener(NewKeyListener l)
Adds a NewKeyListener to be notified when unique Key (Property keys) arrive into this EventContainervoid
addPropertyChangeListener(java.beans.PropertyChangeListener l)
void
addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
private void
checkForNewColumn(LoggingEventWrapper loggingEventWrapper)
void
clearModel()
Clears the model completelyint
findColoredRow(int startLocation, boolean searchForward)
Determine next row with a non-default colorprivate void
fireNewKeyColumnAdded(NewKeyEvent e)
void
fireRowUpdated(int row, boolean checkForNewColumns)
A row was updatedvoid
fireTableEvent(int begin, int end, int count)
Fire appropriate table update events for the range.java.util.List
getAllEvents()
Returns a copied list of all the event in the model.int
getColumnCount()
java.lang.String
getColumnName(int column)
java.util.List
getFilteredEvents()
Returns a copied list containing the events in the model with filter appliedjava.util.Collection
getLoggerNames()
Returns an unmodifiable Collection of the uniquely known LoggerNames within this model.java.util.List<LoggingEventWrapper>
getMatchingEvents(org.apache.log4j.rule.Rule rule)
int
getMaxSize()
If this container is in Cyclic mode, returns the Size of the cyclic buffer, otherwise this method throws an IllegalStateException, when in unlimited mode, this method has no meaning.LoggingEventWrapper
getRow(int row)
Returns the vector representing the row.int
getRowCount()
int
getRowIndex(LoggingEventWrapper loggingEventWrapper)
Returns the index of the LoggingEventWrapperint
getSearchMatchCount()
Return the visible search match countjava.lang.Object
getValueAt(int rowIndex, int columnIndex)
boolean
isAddRow(LoggingEventWrapper loggingEventWrapper)
Adds a row to the model.boolean
isCellEditable(int rowIndex, int columnIndex)
boolean
isSortable(int col)
boolean
isSortEnabled()
int
locate(org.apache.log4j.rule.Rule rule, int startLocation, boolean searchForward)
Locates a row number, starting from startRow, matching the rule providedvoid
notifyCountListeners()
Allow a forced notification of the EventCountListenersvoid
propertyChange(java.beans.PropertyChangeEvent evt)
void
reFilter()
Force a re-processing of the table layoutvoid
removeLoggerNameListener(LoggerNameListener l)
void
removeNewKeyListener(NewKeyListener l)
Removes a listener from being notified of NewKey events.void
removePropertyFromEvents(java.lang.String propName)
Remove property from all events in containervoid
reset()
The logger names have been clearedvoid
setCyclic(boolean cyclic)
Configures this model to use Cyclic or non-cyclic models.void
setRuleMediator(RuleMediator ruleMediator)
Changes the underlying display rule in use.int
size()
Returns the total number of events currently in the model (all, not just filtered)void
sort()
void
sortColumn(int col, boolean ascending)
java.lang.String
toString()
private void
updateEventMillisDelta(LoggingEventWrapper loggingEventWrapper, LoggingEventWrapper lastLoggingEventWrapper)
int
updateEventsWithFindRule(org.apache.log4j.rule.Rule findRule)
Evaluate all events against the find rule-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
-
-
-
-
Field Detail
-
DEFAULT_CAPACITY
private static final int DEFAULT_CAPACITY
- See Also:
- Constant Field Values
-
cyclic
private boolean cyclic
-
cyclicBufferSize
private int cyclicBufferSize
-
unfilteredList
java.util.List unfilteredList
-
filteredList
java.util.List filteredList
-
currentSortAscending
private boolean currentSortAscending
-
currentSortColumn
private int currentSortColumn
-
eventListenerList
private final javax.swing.event.EventListenerList eventListenerList
-
columnNames
private final java.util.List<java.lang.String> columnNames
-
sortEnabled
private boolean sortEnabled
-
reachedCapacity
private boolean reachedCapacity
-
logger
private final org.apache.log4j.Logger logger
-
loggerNameModelDelegate
private final LoggerNameModel loggerNameModelDelegate
-
mutex
private final java.lang.Object mutex
-
uniqueRow
int uniqueRow
-
uniquePropertyKeys
private final java.util.Set uniquePropertyKeys
-
ruleMediator
private org.apache.log4j.rule.Rule ruleMediator
-
propertySupport
private final java.beans.PropertyChangeSupport propertySupport
-
colorizer
private RuleColorizer colorizer
-
tableModelName
private final java.lang.String tableModelName
-
-
Constructor Detail
-
ChainsawCyclicBufferTableModel
public ChainsawCyclicBufferTableModel(int cyclicBufferSize, RuleColorizer colorizer, java.lang.String tableModelName)
-
-
Method Detail
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
getMatchingEvents
public java.util.List<LoggingEventWrapper> getMatchingEvents(org.apache.log4j.rule.Rule rule)
- Specified by:
getMatchingEvents
in interfaceEventContainer
-
reFilter
public void reFilter()
Description copied from interface:EventContainer
Force a re-processing of the table layout- Specified by:
reFilter
in interfaceEventContainer
-
locate
public int locate(org.apache.log4j.rule.Rule rule, int startLocation, boolean searchForward)
Description copied from interface:EventContainer
Locates a row number, starting from startRow, matching the rule provided- Specified by:
locate
in interfaceEventContainer
-
removeLoggerNameListener
public void removeLoggerNameListener(LoggerNameListener l)
- Specified by:
removeLoggerNameListener
in interfaceLoggerNameModel
- Parameters:
l
-
-
addLoggerName
public boolean addLoggerName(java.lang.String loggerName)
Description copied from interface:LoggerNameModel
Attempts to add the loggerName to the model, and returns true if it does, i.e that the loggerName is new, otherwise it is ignored.If the loggerName is new for this model, all the LoggerNameListeners are notified using this thread.
- Specified by:
addLoggerName
in interfaceLoggerNameModel
- Parameters:
loggerName
-- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
reset
public void reset()
Description copied from interface:LoggerNameModel
The logger names have been cleared- Specified by:
reset
in interfaceLoggerNameModel
-
addLoggerNameListener
public void addLoggerNameListener(LoggerNameListener l)
- Specified by:
addLoggerNameListener
in interfaceLoggerNameModel
- Parameters:
l
-
-
getLoggerNames
public java.util.Collection getLoggerNames()
Description copied from interface:LoggerNameModel
Returns an unmodifiable Collection of the uniquely known LoggerNames within this model.- Specified by:
getLoggerNames
in interfaceLoggerNameModel
- Returns:
-
addEventCountListener
public void addEventCountListener(EventCountListener listener)
Description copied from interface:EventContainer
Adds an EventCountListener, to be notified when the # of events changes- Specified by:
addEventCountListener
in interfaceEventContainer
-
isSortable
public boolean isSortable(int col)
- Specified by:
isSortable
in interfaceSortTableModel
-
notifyCountListeners
public void notifyCountListeners()
Description copied from interface:EventContainer
Allow a forced notification of the EventCountListeners- Specified by:
notifyCountListeners
in interfaceEventContainer
-
setRuleMediator
public void setRuleMediator(RuleMediator ruleMediator)
Changes the underlying display rule in use. If there was a previous Rule defined, this Model removes itself as a listener from the old rule, and adds itself to the new rule (if the new Rule is not Null).In any case, the model ensures the Filtered list is made up to date in a separate thread.
- Specified by:
setRuleMediator
in interfaceEventContainer
-
sort
public void sort()
- Specified by:
sort
in interfaceSortTableModel
-
isSortEnabled
public boolean isSortEnabled()
- Specified by:
isSortEnabled
in interfaceSortTableModel
-
sortColumn
public void sortColumn(int col, boolean ascending)
- Specified by:
sortColumn
in interfaceSortTableModel
-
clearModel
public void clearModel()
Description copied from interface:EventContainer
Clears the model completely- Specified by:
clearModel
in interfaceEventContainer
-
getAllEvents
public java.util.List getAllEvents()
Description copied from interface:EventContainer
Returns a copied list of all the event in the model.- Specified by:
getAllEvents
in interfaceEventContainer
-
getFilteredEvents
public java.util.List getFilteredEvents()
Description copied from interface:EventContainer
Returns a copied list containing the events in the model with filter applied- Specified by:
getFilteredEvents
in interfaceEventContainer
-
getRowIndex
public int getRowIndex(LoggingEventWrapper loggingEventWrapper)
Description copied from interface:EventContainer
Returns the index of the LoggingEventWrapper- Specified by:
getRowIndex
in interfaceEventContainer
-
removePropertyFromEvents
public void removePropertyFromEvents(java.lang.String propName)
Description copied from interface:EventContainer
Remove property from all events in container- Specified by:
removePropertyFromEvents
in interfaceEventContainer
- Parameters:
propName
- the property name to remove
-
updateEventsWithFindRule
public int updateEventsWithFindRule(org.apache.log4j.rule.Rule findRule)
Description copied from interface:EventContainer
Evaluate all events against the find rule- Specified by:
updateEventsWithFindRule
in interfaceEventContainer
-
findColoredRow
public int findColoredRow(int startLocation, boolean searchForward)
Description copied from interface:EventContainer
Determine next row with a non-default color- Specified by:
findColoredRow
in interfaceEventContainer
- Returns:
-
getSearchMatchCount
public int getSearchMatchCount()
Description copied from interface:EventContainer
Return the visible search match count- Specified by:
getSearchMatchCount
in interfaceEventContainer
- Returns:
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
-
getColumnName
public java.lang.String getColumnName(int column)
- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.AbstractTableModel
-
getRow
public LoggingEventWrapper getRow(int row)
Description copied from interface:EventContainer
Returns the vector representing the row.- Specified by:
getRow
in interfaceEventContainer
-
getRowCount
public int getRowCount()
- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
-
getValueAt
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
-
isAddRow
public boolean isAddRow(LoggingEventWrapper loggingEventWrapper)
Description copied from interface:EventContainer
Adds a row to the model.- Specified by:
isAddRow
in interfaceEventContainer
- Parameters:
loggingEventWrapper
- event- Returns:
- flag representing whether or not the row is being displayed (not filtered)
-
updateEventMillisDelta
private void updateEventMillisDelta(LoggingEventWrapper loggingEventWrapper, LoggingEventWrapper lastLoggingEventWrapper)
-
checkForNewColumn
private void checkForNewColumn(LoggingEventWrapper loggingEventWrapper)
-
fireTableEvent
public void fireTableEvent(int begin, int end, int count)
Description copied from interface:EventContainer
Fire appropriate table update events for the range.- Specified by:
fireTableEvent
in interfaceEventContainer
-
fireRowUpdated
public void fireRowUpdated(int row, boolean checkForNewColumns)
Description copied from interface:EventContainer
A row was updated- Specified by:
fireRowUpdated
in interfaceEventContainer
-
fireNewKeyColumnAdded
private void fireNewKeyColumnAdded(NewKeyEvent e)
- Parameters:
e
-
-
getMaxSize
public int getMaxSize()
Description copied from interface:EventContainer
If this container is in Cyclic mode, returns the Size of the cyclic buffer, otherwise this method throws an IllegalStateException, when in unlimited mode, this method has no meaning.- Specified by:
getMaxSize
in interfaceEventContainer
- Returns:
-
addNewKeyListener
public void addNewKeyListener(NewKeyListener l)
Description copied from interface:EventContainer
Adds a NewKeyListener to be notified when unique Key (Property keys) arrive into this EventContainer- Specified by:
addNewKeyListener
in interfaceEventContainer
-
removeNewKeyListener
public void removeNewKeyListener(NewKeyListener l)
Description copied from interface:EventContainer
Removes a listener from being notified of NewKey events.- Specified by:
removeNewKeyListener
in interfaceEventContainer
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in classjavax.swing.table.AbstractTableModel
-
setCyclic
public void setCyclic(boolean cyclic)
Description copied from interface:EventContainer
Configures this model to use Cyclic or non-cyclic models. This method should fire a property Change event if it involves an actual change in the underlying model.This method does nothing if there is no change in proprty.
- Specified by:
setCyclic
in interfaceEventContainer
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
- Specified by:
addPropertyChangeListener
in interfaceEventContainer
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
- Specified by:
addPropertyChangeListener
in interfaceEventContainer
-
size
public int size()
Description copied from interface:EventContainer
Returns the total number of events currently in the model (all, not just filtered)- Specified by:
size
in interfaceEventContainer
- Returns:
- size
-
-