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 classChainsawCyclicBufferTableModel.ModelChanger
-
Field Summary
Fields Modifier and Type Field Description private RuleColorizercolorizerprivate java.util.List<java.lang.String>columnNamesprivate booleancurrentSortAscendingprivate intcurrentSortColumnprivate booleancyclicprivate intcyclicBufferSizeprivate static intDEFAULT_CAPACITYprivate javax.swing.event.EventListenerListeventListenerList(package private) java.util.ListfilteredListprivate org.apache.log4j.Loggerloggerprivate LoggerNameModelloggerNameModelDelegateprivate java.lang.Objectmutexprivate java.beans.PropertyChangeSupportpropertySupportprivate booleanreachedCapacityprivate org.apache.log4j.rule.RuleruleMediatorprivate booleansortEnabledprivate java.lang.StringtableModelName(package private) java.util.ListunfilteredListprivate java.util.SetuniquePropertyKeys(package private) intuniqueRow
-
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 voidaddEventCountListener(EventCountListener listener)Adds an EventCountListener, to be notified when the # of events changesbooleanaddLoggerName(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.voidaddLoggerNameListener(LoggerNameListener l)voidaddNewKeyListener(NewKeyListener l)Adds a NewKeyListener to be notified when unique Key (Property keys) arrive into this EventContainervoidaddPropertyChangeListener(java.beans.PropertyChangeListener l)voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)private voidcheckForNewColumn(LoggingEventWrapper loggingEventWrapper)voidclearModel()Clears the model completelyintfindColoredRow(int startLocation, boolean searchForward)Determine next row with a non-default colorprivate voidfireNewKeyColumnAdded(NewKeyEvent e)voidfireRowUpdated(int row, boolean checkForNewColumns)A row was updatedvoidfireTableEvent(int begin, int end, int count)Fire appropriate table update events for the range.java.util.ListgetAllEvents()Returns a copied list of all the event in the model.intgetColumnCount()java.lang.StringgetColumnName(int column)java.util.ListgetFilteredEvents()Returns a copied list containing the events in the model with filter appliedjava.util.CollectiongetLoggerNames()Returns an unmodifiable Collection of the uniquely known LoggerNames within this model.java.util.List<LoggingEventWrapper>getMatchingEvents(org.apache.log4j.rule.Rule rule)intgetMaxSize()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.LoggingEventWrappergetRow(int row)Returns the vector representing the row.intgetRowCount()intgetRowIndex(LoggingEventWrapper loggingEventWrapper)Returns the index of the LoggingEventWrapperintgetSearchMatchCount()Return the visible search match countjava.lang.ObjectgetValueAt(int rowIndex, int columnIndex)booleanisAddRow(LoggingEventWrapper loggingEventWrapper)Adds a row to the model.booleanisCellEditable(int rowIndex, int columnIndex)booleanisSortable(int col)booleanisSortEnabled()intlocate(org.apache.log4j.rule.Rule rule, int startLocation, boolean searchForward)Locates a row number, starting from startRow, matching the rule providedvoidnotifyCountListeners()Allow a forced notification of the EventCountListenersvoidpropertyChange(java.beans.PropertyChangeEvent evt)voidreFilter()Force a re-processing of the table layoutvoidremoveLoggerNameListener(LoggerNameListener l)voidremoveNewKeyListener(NewKeyListener l)Removes a listener from being notified of NewKey events.voidremovePropertyFromEvents(java.lang.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)java.lang.StringtoString()private voidupdateEventMillisDelta(LoggingEventWrapper loggingEventWrapper, LoggingEventWrapper lastLoggingEventWrapper)intupdateEventsWithFindRule(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:
propertyChangein interfacejava.beans.PropertyChangeListener
-
getMatchingEvents
public java.util.List<LoggingEventWrapper> getMatchingEvents(org.apache.log4j.rule.Rule rule)
- 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
-
removeLoggerNameListener
public void removeLoggerNameListener(LoggerNameListener l)
- Specified by:
removeLoggerNameListenerin interfaceLoggerNameModel- Parameters:
l-
-
addLoggerName
public boolean addLoggerName(java.lang.String loggerName)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
reset
public void reset()
Description copied from interface:LoggerNameModelThe logger names have been cleared- Specified by:
resetin interfaceLoggerNameModel
-
addLoggerNameListener
public void addLoggerNameListener(LoggerNameListener l)
- Specified by:
addLoggerNameListenerin interfaceLoggerNameModel- Parameters:
l-
-
getLoggerNames
public java.util.Collection getLoggerNames()
Description copied from interface:LoggerNameModelReturns an unmodifiable Collection of the uniquely known LoggerNames within this model.- Specified by:
getLoggerNamesin interfaceLoggerNameModel- Returns:
-
addEventCountListener
public void addEventCountListener(EventCountListener listener)
Description copied from interface:EventContainerAdds an EventCountListener, to be notified when the # of events changes- Specified by:
addEventCountListenerin interfaceEventContainer
-
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
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:
setRuleMediatorin interfaceEventContainer
-
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
public java.util.List getAllEvents()
Description copied from interface:EventContainerReturns a copied list of all the event in the model.- Specified by:
getAllEventsin interfaceEventContainer
-
getFilteredEvents
public java.util.List getFilteredEvents()
Description copied from interface:EventContainerReturns a copied list containing the events in the model with filter applied- Specified by:
getFilteredEventsin interfaceEventContainer
-
getRowIndex
public int getRowIndex(LoggingEventWrapper loggingEventWrapper)
Description copied from interface:EventContainerReturns the index of the LoggingEventWrapper- Specified by:
getRowIndexin interfaceEventContainer
-
removePropertyFromEvents
public void removePropertyFromEvents(java.lang.String propName)
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
-
findColoredRow
public int findColoredRow(int startLocation, boolean searchForward)Description copied from interface:EventContainerDetermine next row with a non-default color- Specified by:
findColoredRowin interfaceEventContainer- 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 interfacejavax.swing.table.TableModel
-
getColumnName
public java.lang.String getColumnName(int column)
- Specified by:
getColumnNamein interfacejavax.swing.table.TableModel- Overrides:
getColumnNamein classjavax.swing.table.AbstractTableModel
-
getRow
public LoggingEventWrapper getRow(int row)
Description copied from interface:EventContainerReturns the vector representing the row.- Specified by:
getRowin interfaceEventContainer
-
getRowCount
public int getRowCount()
- Specified by:
getRowCountin interfacejavax.swing.table.TableModel
-
getValueAt
public java.lang.Object getValueAt(int rowIndex, int columnIndex)- Specified by:
getValueAtin interfacejavax.swing.table.TableModel
-
isAddRow
public boolean isAddRow(LoggingEventWrapper loggingEventWrapper)
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
private void checkForNewColumn(LoggingEventWrapper loggingEventWrapper)
-
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
-
fireNewKeyColumnAdded
private void fireNewKeyColumnAdded(NewKeyEvent e)
- 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
public void addNewKeyListener(NewKeyListener l)
Description copied from interface:EventContainerAdds a NewKeyListener to be notified when unique Key (Property keys) arrive into this EventContainer- Specified by:
addNewKeyListenerin interfaceEventContainer
-
removeNewKeyListener
public void removeNewKeyListener(NewKeyListener l)
Description copied from interface:EventContainerRemoves a listener from being notified of NewKey events.- Specified by:
removeNewKeyListenerin interfaceEventContainer
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)- Specified by:
isCellEditablein interfacejavax.swing.table.TableModel- Overrides:
isCellEditablein classjavax.swing.table.AbstractTableModel
-
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
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
- Specified by:
addPropertyChangeListenerin interfaceEventContainer
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)- 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
-
-