View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.log4j.chainsaw;
19  
20  import org.apache.log4j.rule.Rule;
21  
22  import java.beans.PropertyChangeListener;
23  import java.util.List;
24  
25  
26  /**
27   * To allow pluggable TableModel implementations for Chainsaw, this interface has been factored out.
28   * <p>
29   * This interface is still subject to change.
30   *
31   * @author Paul Smith &lt;psmith@apache.org&gt;
32   * @author Scott Deboy &lt;sdeboy@apache.org&gt;
33   * @author Stephen Pain
34   */
35  public interface EventContainer extends SortTableModel, LoggerNameModel {
36      /**
37       * Adds an EventCountListener, to be notified when the # of events changes
38       *
39       * @param listener
40       */
41      void addEventCountListener(EventCountListener listener);
42  
43      void addPropertyChangeListener(PropertyChangeListener l);
44  
45      void addPropertyChangeListener(
46          String propertyName, PropertyChangeListener l);
47  
48      /**
49       * Adds a NewKeyListener to be notified when unique Key (Property keys)
50       * arrive into this EventContainer
51       *
52       * @param l
53       */
54      void addNewKeyListener(NewKeyListener l);
55  
56      /**
57       * Removes a listener from being notified of NewKey events.
58       *
59       * @param l
60       */
61      void removeNewKeyListener(NewKeyListener l);
62  
63      /**
64       * Clears the model completely
65       */
66      void clearModel();
67  
68      List<LoggingEventWrapper> getMatchingEvents(Rule rule);
69  
70      /**
71       * Configures this model to use Cyclic or non-cyclic models.
72       * This method should fire a property Change event if
73       * it involves an actual change in the underlying model.
74       * <p>
75       * This method does nothing if there is no change in proprty.
76       *
77       * @param cyclic
78       */
79      void setCyclic(boolean cyclic);
80  
81      /**
82       * If this container is in Cyclic mode, returns the Size of the cyclic buffer,
83       * otherwise this method throws an IllegalStateException, when in unlimited
84       * mode, this method has no meaning.
85       *
86       * @return int size of the cyclic buffer
87       * @throws IllegalStateException if this containers isCyclic() method returns false.
88       */
89      int getMaxSize();
90  
91      /**
92       * Locates a row number, starting from startRow, matching the rule provided
93       *
94       * @param rule
95       * @param startRow
96       * @param searchForward
97       */
98      int locate(Rule rule, int startRow, boolean searchForward);
99  
100     /**
101      * Returns a copied list of all the event in the model.
102      */
103     List getAllEvents();
104 
105     /**
106      * Returns a copied list containing the events in the model with filter applied
107      */
108     List getFilteredEvents();
109 
110     /**
111      * Returns the total number of events currently in the model (all, not just filtered)
112      *
113      * @return size
114      */
115     int size();
116 
117     /**
118      * Returns the vector representing the row.
119      */
120     LoggingEventWrapper getRow(int row);
121 
122     /**
123      * Adds a row to the model.
124      *
125      * @param e event
126      * @return flag representing whether or not the row is being displayed (not filtered)
127      */
128     boolean isAddRow(LoggingEventWrapper e);
129 
130     /**
131      * Fire appropriate table update events for the range.
132      */
133     void fireTableEvent(int begin, int end, int count);
134 
135     /**
136      * A row was updated
137      *
138      * @param row
139      * @param checkForNewColumns
140      */
141     void fireRowUpdated(int row, boolean checkForNewColumns);
142 
143     /**
144      * Allow a forced notification of the EventCountListeners
145      */
146     void notifyCountListeners();
147 
148     /**
149      * Force a re-processing of the table layout
150      */
151     void reFilter();
152 
153     /**
154      * Sets the RuleMediator in operation
155      *
156      * @param ruleMediator
157      */
158     void setRuleMediator(RuleMediator ruleMediator);
159 
160     /**
161      * Returns the index of the LoggingEventWrapper
162      *
163      * @param loggingEventWrapper
164      */
165     int getRowIndex(LoggingEventWrapper loggingEventWrapper);
166 
167     /**
168      * Remove property from all events in container
169      *
170      * @param propName the property name to remove
171      */
172     void removePropertyFromEvents(String propName);
173 
174     /**
175      * Evaluate all events against the find rule
176      *
177      * @param findRule
178      */
179     int updateEventsWithFindRule(Rule findRule);
180 
181     /**
182      * Determine next row with a non-default color
183      *
184      * @param currentRow
185      * @param forward
186      * @return
187      */
188     int findColoredRow(int currentRow, boolean forward);
189 
190     /**
191      * Return the visible search match count
192      *
193      * @return
194      */
195     int getSearchMatchCount();
196 }