Package org.apache.log4j.chainsaw
Class ChainsawCyclicBufferTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.apache.log4j.chainsaw.ChainsawCyclicBufferTableModel
- All Implemented Interfaces:
PropertyChangeListener
,Serializable
,EventListener
,TableModel
,EventContainer
,LoggerNameModel
,SortTableModel
class ChainsawCyclicBufferTableModel
extends AbstractTableModel
implements EventContainer, 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RuleColorizer
private boolean
private int
private boolean
private int
private static final int
private final EventListenerList
(package private) List
private final org.apache.log4j.Logger
private final LoggerNameModel
private final Object
private final PropertyChangeSupport
private boolean
private org.apache.log4j.rule.Rule
private boolean
private final String
(package private) List
private final Set
(package private) int
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionChainsawCyclicBufferTableModel
(int cyclicBufferSize, RuleColorizer colorizer, String tableModelName) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventCountListener
(EventCountListener listener) Adds an EventCountListener, to be notified when the # of events changesboolean
addLoggerName
(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
void
Adds a NewKeyListener to be notified when unique Key (Property keys) arrive into this EventContainervoid
void
addPropertyChangeListener
(String propertyName, PropertyChangeListener l) private void
checkForNewColumn
(LoggingEventWrapper loggingEventWrapper) void
Clears the model completelyint
findColoredRow
(int startLocation, boolean searchForward) Determine next row with a non-default colorprivate void
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.Returns a copied list of all the event in the model.int
getColumnName
(int column) Returns a copied list containing the events in the model with filter appliedReturns an unmodifiable Collection of the uniquely known LoggerNames within this model.getMatchingEvents
(org.apache.log4j.rule.Rule rule) int
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.getRow
(int row) Returns the vector representing the row.int
int
getRowIndex
(LoggingEventWrapper loggingEventWrapper) Returns the index of the LoggingEventWrapperint
Return the visible search match countgetValueAt
(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
int
locate
(org.apache.log4j.rule.Rule rule, int startLocation, boolean searchForward) Locates a row number, starting from startRow, matching the rule providedvoid
Allow a forced notification of the EventCountListenersvoid
void
reFilter()
Force a re-processing of the table layoutvoid
void
Removes a listener from being notified of NewKey events.void
removePropertyFromEvents
(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) toString()
private void
updateEventMillisDelta
(LoggingEventWrapper loggingEventWrapper, LoggingEventWrapper lastLoggingEventWrapper) int
updateEventsWithFindRule
(org.apache.log4j.rule.Rule findRule) Evaluate all events against the find ruleMethods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, removeTableModelListener, setValueAt
-
Field Details
-
DEFAULT_CAPACITY
private static final int DEFAULT_CAPACITY- See Also:
-
cyclic
private boolean cyclic -
cyclicBufferSize
private int cyclicBufferSize -
unfilteredList
List unfilteredList -
filteredList
List filteredList -
currentSortAscending
private boolean currentSortAscending -
currentSortColumn
private int currentSortColumn -
eventListenerList
-
columnNames
-
sortEnabled
private boolean sortEnabled -
reachedCapacity
private boolean reachedCapacity -
logger
private final org.apache.log4j.Logger logger -
loggerNameModelDelegate
-
mutex
-
uniqueRow
int uniqueRow -
uniquePropertyKeys
-
ruleMediator
private org.apache.log4j.rule.Rule ruleMediator -
propertySupport
-
colorizer
-
tableModelName
-
-
Constructor Details
-
ChainsawCyclicBufferTableModel
public ChainsawCyclicBufferTableModel(int cyclicBufferSize, RuleColorizer colorizer, String tableModelName)
-
-
Method Details
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
getMatchingEvents
- 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
- Specified by:
removeLoggerNameListener
in interfaceLoggerNameModel
- Parameters:
l
-
-
addLoggerName
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
-
reset
public void reset()Description copied from interface:LoggerNameModel
The logger names have been cleared- Specified by:
reset
in interfaceLoggerNameModel
-
addLoggerNameListener
- Specified by:
addLoggerNameListener
in interfaceLoggerNameModel
- Parameters:
l
-
-
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
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
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
Description copied from interface:EventContainer
Returns a copied list of all the event in the model.- Specified by:
getAllEvents
in interfaceEventContainer
-
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
Description copied from interface:EventContainer
Returns the index of the LoggingEventWrapper- Specified by:
getRowIndex
in interfaceEventContainer
-
removePropertyFromEvents
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 interfaceTableModel
-
getColumnName
- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
-
getRow
Description copied from interface:EventContainer
Returns the vector representing the row.- Specified by:
getRow
in interfaceEventContainer
-
getRowCount
public int getRowCount()- Specified by:
getRowCount
in interfaceTableModel
-
getValueAt
- Specified by:
getValueAt
in interfaceTableModel
-
isAddRow
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
-
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
- 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
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
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 interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
-
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
- Specified by:
addPropertyChangeListener
in interfaceEventContainer
-
addPropertyChangeListener
- 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
-