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 RuleColorizerprivate booleanprivate intprivate booleanprivate intprivate static final intprivate final EventListenerList(package private) Listprivate final org.apache.log4j.Loggerprivate final LoggerNameModelprivate final Objectprivate final PropertyChangeSupportprivate booleanprivate org.apache.log4j.rule.Ruleprivate booleanprivate final String(package private) Listprivate final Set(package private) intFields inherited from class AbstractTableModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionChainsawCyclicBufferTableModel(int cyclicBufferSize, RuleColorizer colorizer, String tableModelName) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventCountListener(EventCountListener listener) Adds an EventCountListener, to be notified when the # of events changesbooleanaddLoggerName(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.voidvoidAdds a NewKeyListener to be notified when unique Key (Property keys) arrive into this EventContainervoidvoidaddPropertyChangeListener(String propertyName, PropertyChangeListener l) private voidcheckForNewColumn(LoggingEventWrapper loggingEventWrapper) voidClears the model completelyintfindColoredRow(int startLocation, boolean searchForward) Determine next row with a non-default colorprivate voidvoidfireRowUpdated(int row, boolean checkForNewColumns) A row was updatedvoidfireTableEvent(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.intgetColumnName(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) intIf 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.intintgetRowIndex(LoggingEventWrapper loggingEventWrapper) Returns the index of the LoggingEventWrapperintReturn the visible search match countgetValueAt(int rowIndex, int columnIndex) booleanisAddRow(LoggingEventWrapper loggingEventWrapper) Adds a row to the model.booleanisCellEditable(int rowIndex, int columnIndex) booleanisSortable(int col) booleanintlocate(org.apache.log4j.rule.Rule rule, int startLocation, boolean searchForward) Locates a row number, starting from startRow, matching the rule providedvoidAllow a forced notification of the EventCountListenersvoidvoidreFilter()Force a re-processing of the table layoutvoidvoidRemoves a listener from being notified of NewKey events.voidremovePropertyFromEvents(String propName) Remove property from all events in containervoidreset()The logger names have been clearedvoidsetCyclic(boolean cyclic) Configures this model to use Cyclic or non-cyclic models.voidsetRuleMediator(RuleMediator ruleMediator) Changes the underlying display rule in use.intsize()Returns the total number of events currently in the model (all, not just filtered)voidsort()voidsortColumn(int col, boolean ascending) toString()private voidupdateEventMillisDelta(LoggingEventWrapper loggingEventWrapper, LoggingEventWrapper lastLoggingEventWrapper) intupdateEventsWithFindRule(org.apache.log4j.rule.Rule findRule) Evaluate all events against the find ruleMethods inherited from class AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener, setValueAtMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface 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:
propertyChangein interfacePropertyChangeListener
-
getMatchingEvents
- Specified by:
getMatchingEventsin interfaceEventContainer
-
reFilter
public void reFilter()Description copied from interface:EventContainerForce a re-processing of the table layout- Specified by:
reFilterin interfaceEventContainer
-
locate
public int locate(org.apache.log4j.rule.Rule rule, int startLocation, boolean searchForward) Description copied from interface:EventContainerLocates a row number, starting from startRow, matching the rule provided- Specified by:
locatein interfaceEventContainer- Parameters:
rule-startLocation-searchForward-
-
removeLoggerNameListener
- Specified by:
removeLoggerNameListenerin interfaceLoggerNameModel- Parameters:
l-
-
addLoggerName
Description copied from interface:LoggerNameModelAttempts 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:
addLoggerNamein interfaceLoggerNameModel- Parameters:
loggerName-- Returns:
-
toString
-
reset
public void reset()Description copied from interface:LoggerNameModelThe logger names have been cleared- Specified by:
resetin interfaceLoggerNameModel
-
addLoggerNameListener
- Specified by:
addLoggerNameListenerin interfaceLoggerNameModel- Parameters:
l-
-
getLoggerNames
Description copied from interface:LoggerNameModelReturns an unmodifiable Collection of the uniquely known LoggerNames within this model.- Specified by:
getLoggerNamesin interfaceLoggerNameModel- Returns:
-
addEventCountListener
Description copied from interface:EventContainerAdds an EventCountListener, to be notified when the # of events changes- Specified by:
addEventCountListenerin interfaceEventContainer- Parameters:
listener-
-
isSortable
public boolean isSortable(int col) - Specified by:
isSortablein interfaceSortTableModel
-
notifyCountListeners
public void notifyCountListeners()Description copied from interface:EventContainerAllow a forced notification of the EventCountListeners- Specified by:
notifyCountListenersin 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:
setRuleMediatorin interfaceEventContainer- Parameters:
ruleMediator-
-
sort
public void sort()- Specified by:
sortin interfaceSortTableModel
-
isSortEnabled
public boolean isSortEnabled()- Specified by:
isSortEnabledin interfaceSortTableModel
-
sortColumn
public void sortColumn(int col, boolean ascending) - Specified by:
sortColumnin interfaceSortTableModel
-
clearModel
public void clearModel()Description copied from interface:EventContainerClears the model completely- Specified by:
clearModelin interfaceEventContainer
-
getAllEvents
Description copied from interface:EventContainerReturns a copied list of all the event in the model.- Specified by:
getAllEventsin interfaceEventContainer
-
getFilteredEvents
Description copied from interface:EventContainerReturns a copied list containing the events in the model with filter applied- Specified by:
getFilteredEventsin interfaceEventContainer
-
getRowIndex
Description copied from interface:EventContainerReturns the index of the LoggingEventWrapper- Specified by:
getRowIndexin interfaceEventContainer- Parameters:
loggingEventWrapper-
-
removePropertyFromEvents
Description copied from interface:EventContainerRemove property from all events in container- Specified by:
removePropertyFromEventsin interfaceEventContainer- Parameters:
propName- the property name to remove
-
updateEventsWithFindRule
public int updateEventsWithFindRule(org.apache.log4j.rule.Rule findRule) Description copied from interface:EventContainerEvaluate all events against the find rule- Specified by:
updateEventsWithFindRulein interfaceEventContainer- Parameters:
findRule-
-
findColoredRow
public int findColoredRow(int startLocation, boolean searchForward) Description copied from interface:EventContainerDetermine next row with a non-default color- Specified by:
findColoredRowin interfaceEventContainer- Parameters:
startLocation-searchForward-- Returns:
-
getSearchMatchCount
public int getSearchMatchCount()Description copied from interface:EventContainerReturn the visible search match count- Specified by:
getSearchMatchCountin interfaceEventContainer- Returns:
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCountin interfaceTableModel
-
getColumnName
- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel
-
getRow
Description copied from interface:EventContainerReturns the vector representing the row.- Specified by:
getRowin interfaceEventContainer
-
getRowCount
public int getRowCount()- Specified by:
getRowCountin interfaceTableModel
-
getValueAt
- Specified by:
getValueAtin interfaceTableModel
-
isAddRow
Description copied from interface:EventContainerAdds a row to the model.- Specified by:
isAddRowin 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:EventContainerFire appropriate table update events for the range.- Specified by:
fireTableEventin interfaceEventContainer
-
fireRowUpdated
public void fireRowUpdated(int row, boolean checkForNewColumns) Description copied from interface:EventContainerA row was updated- Specified by:
fireRowUpdatedin interfaceEventContainer- Parameters:
row-checkForNewColumns-
-
fireNewKeyColumnAdded
- Parameters:
e-
-
getMaxSize
public int getMaxSize()Description copied from interface:EventContainerIf 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:
getMaxSizein interfaceEventContainer- Returns:
-
addNewKeyListener
Description copied from interface:EventContainerAdds a NewKeyListener to be notified when unique Key (Property keys) arrive into this EventContainer- Specified by:
addNewKeyListenerin interfaceEventContainer- Parameters:
l-
-
removeNewKeyListener
Description copied from interface:EventContainerRemoves a listener from being notified of NewKey events.- Specified by:
removeNewKeyListenerin interfaceEventContainer- Parameters:
l-
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) - Specified by:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel
-
setCyclic
public void setCyclic(boolean cyclic) Description copied from interface:EventContainerConfigures 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:
setCyclicin interfaceEventContainer- Parameters:
cyclic-
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListenerin interfaceEventContainer
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListenerin interfaceEventContainer
-
size
public int size()Description copied from interface:EventContainerReturns the total number of events currently in the model (all, not just filtered)- Specified by:
sizein interfaceEventContainer- Returns:
- size
-