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 java.beans.PropertyChangeListener; 21 import java.util.List; 22 23 import org.apache.log4j.rule.Rule; 24 25 26 /** 27 * To allow pluggable TableModel implementations for Chainsaw, this interface has been factored out. 28 * 29 * This interface is still subject to change. 30 * 31 * @author Paul Smith <psmith@apache.org> 32 * @author Scott Deboy <sdeboy@apache.org> 33 * @author Stephen Pain 34 * 35 */ 36 public interface EventContainer extends SortTableModel, LoggerNameModel { 37 /** 38 * Adds an EventCountListener, to be notified when the # of events changes 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 * @param l 52 */ 53 void addNewKeyListener(NewKeyListener l); 54 55 /** 56 * Removes a listener from being notified of NewKey events. 57 * @param l 58 */ 59 void removeNewKeyListener(NewKeyListener l); 60 61 /** 62 * Clears the model completely 63 * 64 */ 65 void clearModel(); 66 67 List getMatchingEvents(Rule rule); 68 69 /** 70 * Configures this model to use Cyclic or non-cyclic models. 71 * This method should fire a property Change event if 72 * it involves an actual change in the underlying model. 73 * 74 * This method does nothing if there is no change in proprty. 75 * @param cyclic 76 */ 77 void setCyclic(boolean cyclic); 78 79 /** 80 * If this container is in Cyclic mode, returns the Size of the cyclic buffer, 81 * otherwise this method throws an IllegalStateException, when in unlimited 82 * mode, this method has no meaning. 83 * 84 * @throws IllegalStateException if this containers isCyclic() method returns false. 85 * @return int size of the cyclic buffer 86 */ 87 int getMaxSize(); 88 89 /** 90 * Locates a row number, starting from startRow, matching the rule provided 91 * 92 * @param rule 93 * @param startRow 94 * @param searchForward 95 */ 96 int locate(Rule rule, int startRow, boolean searchForward); 97 98 /** 99 * Returns a copied list of all the event in the model. 100 */ 101 List getAllEvents(); 102 103 /** 104 * Returns a copied list containing the events in the model with filter applied 105 */ 106 List getFilteredEvents(); 107 108 /** 109 * Returns the total number of events currently in the model (all, not just filtered) 110 * @return size 111 */ 112 int size(); 113 114 /** 115 * Returns the vector representing the row. 116 */ 117 LoggingEventWrapper getRow(int row); 118 119 /** 120 * Adds a row to the model. 121 * @param e event 122 * @return flag representing whether or not the row is being displayed (not filtered) 123 */ 124 boolean isAddRow(LoggingEventWrapper e); 125 126 /** 127 * Fire appropriate table update events for the range. 128 */ 129 void fireTableEvent(int begin, int end, int count); 130 131 /** 132 * A row was updated 133 * @param row 134 * @param checkForNewColumns 135 */ 136 void fireRowUpdated(int row, boolean checkForNewColumns); 137 /** 138 * Allow a forced notification of the EventCountListeners 139 * 140 */ 141 void notifyCountListeners(); 142 143 /** 144 * Force a re-processing of the table layout 145 */ 146 void reFilter(); 147 /** 148 * Sets the RuleMediator in operation 149 * @param ruleMediator 150 */ 151 void setRuleMediator(RuleMediator ruleMediator); 152 153 /** 154 * Returns the index of the LoggingEventWrapper 155 * @param loggingEventWrapper 156 */ 157 int getRowIndex(LoggingEventWrapper loggingEventWrapper); 158 159 /** 160 * Remove property from all events in container 161 * @param propName the property name to remove 162 */ 163 void removePropertyFromEvents(String propName); 164 165 /** 166 * Evaluate all events against the find rule 167 * @param findRule 168 */ 169 int updateEventsWithFindRule(Rule findRule); 170 171 /** 172 * Determine next row with a non-default color 173 * @param currentRow 174 * @param forward 175 * @return 176 */ 177 int findColoredRow(int currentRow, boolean forward); 178 179 /** 180 * Return the visible search match count 181 * 182 * @return 183 */ 184 int getSearchMatchCount(); 185 }