Class 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).

    • Field Detail

      • 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
      • 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 interface java.beans.PropertyChangeListener
      • reFilter

        public void reFilter()
        Description copied from interface: EventContainer
        Force a re-processing of the table layout
        Specified by:
        reFilter in interface EventContainer
      • 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 interface EventContainer
      • 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 interface LoggerNameModel
        Parameters:
        loggerName -
        Returns:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • 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 interface LoggerNameModel
        Returns:
      • 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 interface EventContainer
      • sortColumn

        public void sortColumn​(int col,
                               boolean ascending)
        Specified by:
        sortColumn in interface SortTableModel
      • 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 interface EventContainer
      • 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 interface EventContainer
      • removePropertyFromEvents

        public void removePropertyFromEvents​(java.lang.String propName)
        Description copied from interface: EventContainer
        Remove property from all events in container
        Specified by:
        removePropertyFromEvents in interface EventContainer
        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 interface EventContainer
      • 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 interface EventContainer
        Returns:
      • getColumnCount

        public int getColumnCount()
        Specified by:
        getColumnCount in interface javax.swing.table.TableModel
      • getColumnName

        public java.lang.String getColumnName​(int column)
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
      • getRowCount

        public int getRowCount()
        Specified by:
        getRowCount in interface javax.swing.table.TableModel
      • getValueAt

        public java.lang.Object getValueAt​(int rowIndex,
                                           int columnIndex)
        Specified by:
        getValueAt in interface javax.swing.table.TableModel
      • isAddRow

        public boolean isAddRow​(LoggingEventWrapper loggingEventWrapper)
        Description copied from interface: EventContainer
        Adds a row to the model.
        Specified by:
        isAddRow in interface EventContainer
        Parameters:
        loggingEventWrapper - event
        Returns:
        flag representing whether or not the row is being displayed (not filtered)
      • 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 interface EventContainer
      • fireRowUpdated

        public void fireRowUpdated​(int row,
                                   boolean checkForNewColumns)
        Description copied from interface: EventContainer
        A row was updated
        Specified by:
        fireRowUpdated in interface EventContainer
      • 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 interface EventContainer
        Returns:
      • isCellEditable

        public boolean isCellEditable​(int rowIndex,
                                      int columnIndex)
        Specified by:
        isCellEditable in interface javax.swing.table.TableModel
        Overrides:
        isCellEditable in class javax.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 interface EventContainer
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.lang.String propertyName,
                                              java.beans.PropertyChangeListener l)
        Specified by:
        addPropertyChangeListener in interface EventContainer
      • 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 interface EventContainer
        Returns:
        size