You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ps...@apache.org on 2003/05/23 03:09:02 UTC

cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw ChainsawEventBatch.java LogUI.java ChainsawAppenderHandler.java ChainsawToolBarAndMenus.java

psmith      2003/05/22 18:09:01

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
                        ChainsawAppenderHandler.java
                        ChainsawToolBarAndMenus.java
  Added:       src/java/org/apache/log4j/chainsaw ChainsawEventBatch.java
  Log:
  Added event batching from the worker thread.  Now the GUI is truely
  configurably-responsive.
  
  Event counter increases as each event comes in, but the table delays
  display of the change based on the Responsiveness setting. When
  the responsiveness is set appropropriately, makes the
  GUI much more responsive while Niagra-fall-volume events stream in.
  
  Revision  Changes    Path
  1.71      +110 -63   jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java
  
  Index: LogUI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- LogUI.java	22 May 2003 07:46:29 -0000	1.70
  +++ LogUI.java	23 May 2003 01:09:00 -0000	1.71
  @@ -49,6 +49,20 @@
   
   package org.apache.log4j.chainsaw;
   
  +import org.apache.log4j.Level;
  +import org.apache.log4j.LogManager;
  +import org.apache.log4j.Priority;
  +import org.apache.log4j.UtilLoggingLevel;
  +import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  +import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
  +import org.apache.log4j.chainsaw.prefs.ProfileManager;
  +import org.apache.log4j.chainsaw.prefs.Profileable;
  +import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
  +import org.apache.log4j.chainsaw.prefs.SettingsListener;
  +import org.apache.log4j.chainsaw.prefs.SettingsManager;
  +import org.apache.log4j.helpers.LogLog;
  +import org.apache.log4j.spi.LoggingEvent;
  +
   import java.awt.BorderLayout;
   import java.awt.Component;
   import java.awt.Dimension;
  @@ -67,14 +81,19 @@
   import java.awt.event.MouseMotionAdapter;
   import java.awt.event.WindowAdapter;
   import java.awt.event.WindowEvent;
  +
   import java.beans.PropertyChangeEvent;
   import java.beans.PropertyChangeListener;
  +
   import java.io.BufferedInputStream;
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.ObjectInputStream;
  +
   import java.util.ArrayList;
  +import java.util.Collection;
  +import java.util.Collections;
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.Iterator;
  @@ -115,23 +134,12 @@
   import javax.swing.event.DocumentListener;
   import javax.swing.event.ListSelectionEvent;
   import javax.swing.event.ListSelectionListener;
  +import javax.swing.event.TableModelEvent;
  +import javax.swing.event.TableModelListener;
   import javax.swing.table.TableColumn;
   import javax.swing.table.TableColumnModel;
   import javax.swing.table.TableModel;
   
  -import org.apache.log4j.Level;
  -import org.apache.log4j.LogManager;
  -import org.apache.log4j.Priority;
  -import org.apache.log4j.UtilLoggingLevel;
  -import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  -import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
  -import org.apache.log4j.chainsaw.prefs.ProfileManager;
  -import org.apache.log4j.chainsaw.prefs.Profileable;
  -import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
  -import org.apache.log4j.chainsaw.prefs.SettingsListener;
  -import org.apache.log4j.chainsaw.prefs.SettingsManager;
  -import org.apache.log4j.helpers.LogLog;
  -
   
   /**
    * The main entry point for Chainsaw, this class represents the first frame
  @@ -483,12 +491,13 @@
     ChainsawStatusBar getStatusBar() {
       return statusBar;
     }
  -  
  +
     void showAboutBox() {
  -  	if(aboutBox == null) {
  -  		aboutBox = new ChainsawAbout(this);
  -  	}
  -  	aboutBox.setVisible(true);
  +    if (aboutBox == null) {
  +      aboutBox = new ChainsawAbout(this);
  +    }
  +
  +    aboutBox.setVisible(true);
     }
   
     /**
  @@ -557,7 +566,7 @@
      * @param v
      * @return
      */
  -  private String getTabIdentifier(Vector v) {
  +  String getTabIdentifier(Vector v) {
       int fieldIndex =
         columnNames.indexOf(ChainsawConstants.PROPERTIES_COL_NAME);
   
  @@ -653,17 +662,37 @@
     }
   
     /**
  -   * Routes a Vector of Logging Event elements into the approprate Tabbed Pane.  Include event type to control level display.
  -   * @param v
  +   * Receives a ChainsawEventBatch object and passes each identifiers
  +   * collection of events in sequence, to allow a Single tab
  +   * to receive as many events in a single hit as possible.
  +   *
  +   * This method (actually the internal addRows method) takes these
  +   * Collection of events and uses the value adjusting property
  +   * to ensure table Listeners don't constantly get notified of every single event, but
  +   * wait until the sequence is complete
  +   * @param eventBatch
      */
  -  public void receiveEvent(Vector v, String eventType) {
  -    String ident = getTabIdentifier(v);
  +  void receiveEventBatch(ChainsawEventBatch eventBatch) {
  +    for (Iterator iter = eventBatch.identifierIterator(); iter.hasNext();) {
  +      String ident = (String) iter.next();
   
  -    if (!pausedList.contains(ident)) {
  -      addRow(ident, formatFields(v), eventType);
  +      if (!pausedList.contains(ident)) {
  +        addRows(ident, eventBatch.entrySet(ident));
  +      }
       }
     }
   
  +  //  /**
  +  //   * Routes a Vector of Logging Event elements into the approprate Tabbed Pane.  Include event type to control level display.
  +  //   * @param v
  +  //   */
  +  //  public void receiveEvent(Vector v, String eventType) {
  +  //    String ident = getTabIdentifier(v);
  +  //
  +  //    if (!pausedList.contains(ident)) {
  +  //      addRow(ident, eventType, Collections.singletonList(v));
  +  //    }
  +  //  }
     public Vector getAllEvents(String ident) {
       return ((DefaultSortTableModel) tableModelMap.get(ident)).getAllEvents();
     }
  @@ -731,23 +760,25 @@
      * @param ident
      * @param v
      */
  -  private void addRow(final String ident, Vector v, String eventType) {
  +  private void addRows(final String ident, final List eventBatchEntrys) {
       final DefaultSortTableModel tableModel;
       final JSortTable table;
       final ScrollToBottom scrollToBottom;
       HashMap map = null;
   
  -    synchronized (initializationLock) {
  -      while (!isGUIFullyInitialized) {
  -        System.out.println(
  -          "Wanting to add a row, but GUI not initialized, waiting...");
  -
  -        /**
  -         * Lets wait 1 seconds and recheck.
  -         */
  -        try {
  -          initializationLock.wait(1000);
  -        } catch (InterruptedException e) {
  +    if (!isGUIFullyInitialized) {
  +      synchronized (initializationLock) {
  +        while (!isGUIFullyInitialized) {
  +          System.out.println(
  +            "Wanting to add a row, but GUI not initialized, waiting...");
  +
  +          /**
  +           * Lets wait 1 seconds and recheck.
  +           */
  +          try {
  +            initializationLock.wait(1000);
  +          } catch (InterruptedException e) {
  +          }
           }
         }
       }
  @@ -758,6 +789,9 @@
         scrollToBottom = (ScrollToBottom) scrollMap.get(ident);
         table = (JSortTable) tableMap.get(ident);
       } else {
  +      final String eventType =
  +        ((ChainsawEventBatch.Entry) eventBatchEntrys.get(0)).getEventType();
  +
         tableModel =
           new DefaultSortTableModel(
             new Vector(), new Vector(columnNames), eventType);
  @@ -786,35 +820,47 @@
         statusBar.setMessage(msg);
       }
   
  -    String level =
  -      v.get(columnNames.indexOf(ChainsawConstants.LEVEL_COL_NAME)).toString();
  +    table.getSelectionModel().setValueIsAdjusting(true);
   
  -    //add the level to the appropriate list if it didn't previously exist
  -    if (!((List) levelMap.get(eventType)).contains(level)) {
  -      ((List) levelMap.get(eventType)).add(level);
  -    }
  -
  -    //also add it to the unique values list
  -    ((HashSet) map.get(ChainsawConstants.LEVEL_COL_NAME)).add(level);
  -    ((HashSet) map.get(ChainsawConstants.LOGGER_COL_NAME)).add(
  -      v.get(columnNames.indexOf(ChainsawConstants.LOGGER_COL_NAME)));
  -    ((HashSet) map.get(ChainsawConstants.THREAD_COL_NAME)).add(
  -      v.get(columnNames.indexOf(ChainsawConstants.THREAD_COL_NAME)));
  -    ((HashSet) map.get(ChainsawConstants.NDC_COL_NAME)).add(
  -      v.get(columnNames.indexOf(ChainsawConstants.NDC_COL_NAME)));
  -    ((HashSet) map.get(ChainsawConstants.MDC_COL_NAME)).add(
  -      v.get(columnNames.indexOf(ChainsawConstants.MDC_COL_NAME)));
  -    ((HashSet) map.get(ChainsawConstants.CLASS_COL_NAME)).add(
  -      v.get(columnNames.indexOf(ChainsawConstants.CLASS_COL_NAME)));
  -    ((HashSet) map.get(ChainsawConstants.METHOD_COL_NAME)).add(
  -      v.get(columnNames.indexOf(ChainsawConstants.METHOD_COL_NAME)));
  -    ((HashSet) map.get(ChainsawConstants.FILE_COL_NAME)).add(
  -      v.get(columnNames.indexOf(ChainsawConstants.FILE_COL_NAME)));
  +    boolean rowAdded = false;
   
  -    table.getSelectionModel().setValueIsAdjusting(true);
  -    statusBar.receivedEvent();
  +    for (Iterator iter = eventBatchEntrys.iterator(); iter.hasNext();) {
  +      ChainsawEventBatch.Entry entry = (ChainsawEventBatch.Entry) iter.next();
  +      Vector v = formatFields(entry.getEventVector());
  +      final String eventType = entry.getEventType();
  +      String level =
  +        v.get(columnNames.indexOf(ChainsawConstants.LEVEL_COL_NAME)).toString();
  +
  +      //add the level to the appropriate list if it didn't previously exist
  +      if (!((List) levelMap.get(eventType)).contains(level)) {
  +        ((List) levelMap.get(eventType)).add(level);
  +      }
  +
  +      //also add it to the unique values list
  +      ((Set) map.get(ChainsawConstants.LEVEL_COL_NAME)).add(level);
  +      ((Set) map.get(ChainsawConstants.LOGGER_COL_NAME)).add(
  +        v.get(columnNames.indexOf(ChainsawConstants.LOGGER_COL_NAME)));
  +      ((Set) map.get(ChainsawConstants.THREAD_COL_NAME)).add(
  +        v.get(columnNames.indexOf(ChainsawConstants.THREAD_COL_NAME)));
  +      ((Set) map.get(ChainsawConstants.NDC_COL_NAME)).add(
  +        v.get(columnNames.indexOf(ChainsawConstants.NDC_COL_NAME)));
  +      ((Set) map.get(ChainsawConstants.MDC_COL_NAME)).add(
  +        v.get(columnNames.indexOf(ChainsawConstants.MDC_COL_NAME)));
  +      ((Set) map.get(ChainsawConstants.CLASS_COL_NAME)).add(
  +        v.get(columnNames.indexOf(ChainsawConstants.CLASS_COL_NAME)));
  +      ((Set) map.get(ChainsawConstants.METHOD_COL_NAME)).add(
  +        v.get(columnNames.indexOf(ChainsawConstants.METHOD_COL_NAME)));
  +      ((Set) map.get(ChainsawConstants.FILE_COL_NAME)).add(
  +        v.get(columnNames.indexOf(ChainsawConstants.FILE_COL_NAME)));
  +
  +      boolean isCurrentRowAdded = tableModel.isAddRow(v);
  +      rowAdded = rowAdded ? true : isCurrentRowAdded;
  +      statusBar.receivedEvent();
  +    }
  +
  +    table.getSelectionModel().setValueIsAdjusting(false);
   
  -    if (tableModel.isAddRow(v)) {
  +    if (rowAdded) {
         if (scrollToBottom.isScrolled() && !scrollToBottom.isBypassed()) {
           table.scrollToBottom(
             table.columnAtPoint(table.getVisibleRect().getLocation()));
  @@ -1499,6 +1545,7 @@
         panelMap.put(ident, this);
         entryMap.put(ident, map);
   
  +	
         tableModel.addEventCountListener(
           new EventCountListener() {
             public void eventCountChanged(int currentCount, int totalCount) {
  
  
  
  1.9       +18 -11    jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java
  
  Index: ChainsawAppenderHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ChainsawAppenderHandler.java	19 May 2003 02:59:54 -0000	1.8
  +++ ChainsawAppenderHandler.java	23 May 2003 01:09:00 -0000	1.9
  @@ -56,8 +56,10 @@
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Date;
  +import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Map;
   import java.util.Set;
   import java.util.Vector;
   
  @@ -78,6 +80,7 @@
     private LogUI logUI;
     private WorkQueue worker;
     private final Object mutex = new Object();
  +  private int sleepInterval = 1000;
   
     public ChainsawAppenderHandler(LogUI logUI, ChainsawAppender appender) {
       this.appender = appender;
  @@ -205,6 +208,14 @@
       return v;
     }
   
  +  public int getQueueInterval() {
  +    return sleepInterval;
  +  }
  +
  +  public void setQueueInterval(int interval) {
  +    sleepInterval = interval;
  +  }
  +
     /**
      * Queue of Events are placed in here, which are picked up by an
      * asychronous thread.  The WorkerThread looks for events once a second and
  @@ -257,6 +268,8 @@
   
             if (innerList.size() > 0) {
               Iterator iter = innerList.iterator();
  +            Map identifiersEventsMap = new HashMap();
  +            ChainsawEventBatch eventBatch = new ChainsawEventBatch();
   
               while (iter.hasNext()) {
                 LoggingEvent e = (LoggingEvent) iter.next();
  @@ -267,9 +280,13 @@
                   eventType = ChainsawConstants.LOG4J_EVENT_TYPE;
                 }
   
  -              logUI.receiveEvent(convert(e), eventType);
  +              Vector convertedEventVector = convert(e);
  +              String ident = logUI.getTabIdentifier(convertedEventVector);
  +              eventBatch.addEvent(ident, eventType, convertedEventVector);
               }
   
  +            logUI.receiveEventBatch(eventBatch);
  +
               innerList.clear();
             }
   
  @@ -281,14 +298,4 @@
         }
       }
     }
  -  
  -  public int getQueueInterval() {
  -  	return sleepInterval;
  -  }
  -  
  -  public void setQueueInterval(int interval) {
  -  	sleepInterval = interval;
  -  }
  -  
  -  private int sleepInterval = 1000;
   }
  
  
  
  1.28      +41 -36    jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
  
  Index: ChainsawToolBarAndMenus.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ChainsawToolBarAndMenus.java	22 May 2003 07:46:29 -0000	1.27
  +++ ChainsawToolBarAndMenus.java	23 May 2003 01:09:00 -0000	1.28
  @@ -166,7 +166,7 @@
       toggleDetailPaneAction = createToggleDetailPaneAction();
       responsiveSlider =
         new JSlider(
  -        JSlider.VERTICAL, 1, 5, logui.handler.getQueueInterval() / 1000);
  +        JSlider.VERTICAL, 0, 5000, logui.handler.getQueueInterval());
       createMenuBar();
       createToolbar();
   
  @@ -566,10 +566,10 @@
         toggleDetailPaneAction.getValue(Action.NAME));
   
       SmallButton prefsButton = new SmallButton(showPreferencesAction);
  -	SmallButton undockButton = new SmallButton(undockAction);
  -	undockButton.setText("");
  -	
  -	toolbar.add(undockButton);
  +    SmallButton undockButton = new SmallButton(undockAction);
  +    undockButton.setText("");
  +
  +    toolbar.add(undockButton);
       toolbar.add(pauseButton);
       toolbar.add(detailPaneButton);
       toolbar.add(prefsButton);
  @@ -609,14 +609,15 @@
       responsiveSlider.setAlignmentY(JComponent.CENTER_ALIGNMENT);
       responsiveSlider.setAlignmentX(JComponent.CENTER_ALIGNMENT);
   
  -    responsiveSlider.setMajorTickSpacing(1);
  +    responsiveSlider.setMinorTickSpacing(250);
  +    responsiveSlider.setMajorTickSpacing(1000);
       responsiveSlider.setToolTipText(
         "Adjust to set the responsiveness of the app.  How often the view is updated.");
       responsiveSlider.setSnapToTicks(true);
       responsiveSlider.setPaintTicks(true);
   
  -    //		responsiveSlider.setPaintLabels(true);
  -    //		responsiveSlider.setPaintTrack(true);
  +    responsiveSlider.setPaintLabels(true);
  +    responsiveSlider.setPaintTrack(true);
       responsiveSlider.setInverted(true);
       responsiveSlider.getModel().addChangeListener(
         new ChangeListener() {
  @@ -627,10 +628,9 @@
                */
             } else {
               int value = responsiveSlider.getValue();
  -            value = value * 1000;
   
               if (value == 0) {
  -              value = 250;
  +              value = 100;
               }
   
               System.out.println("Adjust responsiveness to " + value + "ms");
  @@ -639,8 +639,8 @@
           }
         });
   
  -    JLabel l1 = new JLabel("Update frequently");
  -    JLabel l2 = new JLabel("Update infrequently");
  +    JLabel l1 = new JLabel("Update frequently (100ms)");
  +    JLabel l2 = new JLabel("Update infrequently (5 seconds)");
       responsiveNessPanel.add(l1);
   
       JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
  @@ -677,8 +677,8 @@
         showPreferencesAction.getValue(Action.SHORT_DESCRIPTION).toString());
   
       JMenuItem menuUndock = new JMenuItem(undockAction);
  -	
  -	viewMenu.add(menuUndock);
  +
  +    viewMenu.add(menuUndock);
       viewMenu.add(pause);
   
       JCheckBoxMenuItem toggleDetailMenuItem =
  @@ -704,9 +704,9 @@
       viewMenu.add(menuPrefs);
   
       viewMenu.addSeparator();
  -    
  +
       viewMenu.add(new JMenuItem(clearAction));
  -	viewMenu.addSeparator();
  +    viewMenu.addSeparator();
       viewMenu.add(showToolbarCheck);
       viewMenu.add(toggleStatusBarCheck);
       viewMenu.add(menuItemClose);
  @@ -773,20 +773,20 @@
       viewMenu.addSeparator();
       viewMenu.add(lookAndFeelMenu);
   
  -	JMenu helpMenu = new JMenu("Help");
  -	helpMenu.setMnemonic('H');
  -	
  -	JMenuItem about = new JMenuItem("About Chainsaw v2...");
  -	about.setMnemonic('A');
  -	about.addActionListener(new ActionListener() {
  -
  -    public void actionPerformed(ActionEvent e) {
  -      logui.showAboutBox();
  -      
  -    }});
  -    
  +    JMenu helpMenu = new JMenu("Help");
  +    helpMenu.setMnemonic('H');
  +
  +    JMenuItem about = new JMenuItem("About Chainsaw v2...");
  +    about.setMnemonic('A');
  +    about.addActionListener(
  +      new ActionListener() {
  +        public void actionPerformed(ActionEvent e) {
  +          logui.showAboutBox();
  +        }
  +      });
  +
       helpMenu.add(about);
  -    
  +
       menuBar.add(fileMenu);
       menuBar.add(viewMenu);
       menuBar.add(activeTabMenu);
  @@ -834,14 +834,19 @@
       dockPauseButton.setText("");
   
       toolbar.add(dockPauseButton);
  -    Action dockShowPrefsAction = new AbstractAction("") {
   
  -      public void actionPerformed(ActionEvent arg0) {
  -        logPanel.showPreferences();
  -      }
  -    };
  -    dockShowPrefsAction.putValue(Action.SHORT_DESCRIPTION, showPreferencesAction.getValue(Action.SHORT_DESCRIPTION));
  -	dockShowPrefsAction.putValue(Action.SMALL_ICON, showPreferencesAction.getValue(Action.SMALL_ICON));
  +    Action dockShowPrefsAction =
  +      new AbstractAction("") {
  +        public void actionPerformed(ActionEvent arg0) {
  +          logPanel.showPreferences();
  +        }
  +      };
  +
  +    dockShowPrefsAction.putValue(
  +      Action.SHORT_DESCRIPTION,
  +      showPreferencesAction.getValue(Action.SHORT_DESCRIPTION));
  +    dockShowPrefsAction.putValue(
  +      Action.SMALL_ICON, showPreferencesAction.getValue(Action.SMALL_ICON));
   
       toolbar.add(new SmallButton(dockShowPrefsAction));
       toolbar.addSeparator();
  
  
  
  1.1                  jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawEventBatch.java
  
  Index: ChainsawEventBatch.java
  ===================================================================
  /*
   * ============================================================================
   *                   The Apache Software License, Version 1.1
   * ============================================================================
   *
   *    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modifica-
   * tion, are permitted provided that the following conditions are met:
   *
   * 1. Redistributions of  source code must  retain the above copyright  notice,
   *    this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright notice,
   *    this list of conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The end-user documentation included with the redistribution, if any, must
   *    include  the following  acknowledgment:  "This product includes  software
   *    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
   *    Alternately, this  acknowledgment may  appear in the software itself,  if
   *    and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "log4j" and  "Apache Software Foundation"  must not be used to
   *    endorse  or promote  products derived  from this  software without  prior
   *    written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products  derived from this software may not  be called "Apache", nor may
   *    "Apache" appear  in their name,  without prior written permission  of the
   *    Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software  consists of voluntary contributions made  by many individuals
   * on  behalf of the Apache Software  Foundation.  For more  information on the
   * Apache Software Foundation, please see <http://www.apache.org/>.
   *
   */
  
  package org.apache.log4j.chainsaw;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Vector;
  
  
  /**
   * A container class that contains a group of events split up
   * into branches based on Identifiers
   * @author Paul Smith <ps...@apache.org>
   *
   */
  class ChainsawEventBatch {
    private Map identEventMap = new HashMap();
  
    ChainsawEventBatch() {
    }
  
    /**
     * @param eventType
     * @param convertedEventVector
     */
    void addEvent(String ident, String eventType, Vector convertedEventVector) {
      List events = null;
  
      if (!identEventMap.containsKey(ident)) {
        events = new ArrayList();
        identEventMap.put(ident, events);
      } else {
        events = (List) identEventMap.get(ident);
      }
      
      events.add(new Entry(ident, eventType, convertedEventVector));
    }
    
    /**
     * Returns an iterator of Identifier strings that this payload contains.
     * 
     * The values returned from this iterator can be used to query the
     * 
     * @return Iterator 
     */
    Iterator identifierIterator() {
    	return identEventMap.keySet().iterator();
    }
    
    /**
     * Returns a Collection of ChainsawEventBatch.Entry objects that
     * are bound to the identifier
     * @param identifier
     * @return Collection of ChainsawEventBatch.Entry instances
     */
    List entrySet(String identifier) {
    	return (List)identEventMap.get(identifier);
    }
  
    static class Entry {
      private String eventType;
      private Vector eventVector;
      private String identifier;
  
      Entry(String identifier, String eventType, Vector eventVector) {
        this.identifier = identifier;
        this.eventType = eventType;
        this.eventVector = eventVector;
      }
  
      String getEventType() {
        return eventType;
      }
  
      Vector getEventVector() {
        return eventVector;
      }
  
      public String getIdentifier() {
        return identifier;
      }
    }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org