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  import org.apache.log4j.spi.LoggingEvent;
22  
23  import java.beans.PropertyChangeListener;
24  
25  import java.util.List;
26  
27  
28  /***
29   * To allow pluggable TableModel implementations for Chainsaw, this interface has been factored out.
30   *
31   * This interface is still subject to change.
32   *
33   * @author Paul Smith <psmith@apache.org>
34   * @author Scott Deboy <sdeboy@apache.org>
35   * @author Stephen Pain
36   *
37   */
38  public interface EventContainer extends SortTableModel, LoggerNameModel {
39    /***
40     * Adds an EventCountListener, to be notified when the # of events changes
41     * @param listener
42     */
43    void addEventCountListener(EventCountListener listener);
44  
45    void addPropertyChangeListener(PropertyChangeListener l);
46  
47    void addPropertyChangeListener(
48      String propertyName, PropertyChangeListener l);
49  
50    /***
51     * Adds a NewKeyListener to be notified when unique Key (Property keys)
52     * arrive into this EventContainer
53     * @param l
54     */
55    void addNewKeyListener(NewKeyListener l);
56  
57    /***
58     * Removes a listener from being notified of NewKey events.
59     * @param l
60     */
61    void removeNewKeyListener(NewKeyListener l);
62  
63    /***
64     * Clears the model completely
65     *
66     */
67    void clearModel();
68  
69    List getMatchingEvents(Rule rule);
70  
71    /***
72     * Returns true if this model is Cyclic (bounded) or not.
73     * @return true/false
74     */
75    boolean isCyclic();
76  
77    /***
78     * Configures this model to use Cyclic or non-cyclic models.
79     * This method should fire a property Change event if
80     * it involves an actual change in the underlying model.
81     *
82     * This method does nothing if there is no change in proprty.
83     * @param cyclic
84     */
85    void setCyclic(boolean cyclic);
86  
87    /***
88     * If this container is in Cyclic mode, returns the Size of the cyclic buffer,
89     * otherwise this method throws an IllegalStateException, when in unlimited
90     * mode, this method has no meaning.
91     *
92     * @throws IllegalStateException if this containers isCyclic() method returns false.
93     * @return int size of the cyclic buffer
94     */
95    int getMaxSize();
96  
97    /***
98     * Locates a row number, starting from startRow, matching the rule provided
99     *
100    * @param rule
101    * @param startRow
102    * @param searchForward
103    */
104   int find(Rule rule, int startRow, boolean searchForward);
105 
106   /***
107    * Returns a copied list of all the event in the model.
108    */
109   List getAllEvents();
110 
111   /***
112    * Returns a copied list containing the events in the model with filter applied
113    */
114   List getFilteredEvents();
115   
116   /***
117    * Returns the total number of events currently in the model (all, not just filtered)
118    * @return size
119    */
120   int size();
121 
122   /***
123    * Returns the vector representing the row.
124    */
125   LoggingEvent getRow(int row);
126 
127   /***
128    * Return the last added row.
129    */
130   int getLastAdded();
131 
132   /***
133    * Adds a row to the model.
134    * @param e event
135    * @param valueIsAdjusting
136    * @return flag representing whether or not the row is being displayed (not filtered)
137    */
138   boolean isAddRow(LoggingEvent e, boolean valueIsAdjusting);
139 
140   /***
141    * Fire appropriate table update events for the range.
142    */
143   void fireTableEvent(int begin, int end, int count);
144 
145   /***
146    * Allow a forced notification of the EventCountListeners
147    *
148    */
149   void notifyCountListeners();
150 
151   /***
152    * Sets the DisplayFilter in operation
153    * @param displayRule
154    */
155   void setDisplayRule(Rule displayRule);
156 
157   /***
158    * Returns the index of the LoggingEvent
159    * @param e
160    */
161   int getRowIndex(LoggingEvent e);
162 }